aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/internal/script/scripttest/run.go
diff options
context:
space:
mode:
authorThan McIntosh <thanm@google.com>2024-07-30 14:20:53 +0000
committerThan McIntosh <thanm@google.com>2024-07-31 13:21:20 +0000
commit8246171baee397165318638390c37e07b5b3ebc7 (patch)
treee8b680035b2347524fce388ecd916729cd107117 /src/cmd/internal/script/scripttest/run.go
parentb60f88d81022e4172e44aef2f0bdade87ed6916d (diff)
downloadgo-8246171baee397165318638390c37e07b5b3ebc7.tar.xz
cmd: add README generation for compiler + linker script tests
Add in automatic README generation and README consistency checking for the cmd/compile and cmd/link script tests. This code is adapted from the similar facility in cmd/go (e.g. scriptreadme_test.go); the README helps folks writing new tests understand the mechanics. Updates #68606. Change-Id: I8ff7ff8e814abd4385bd670440511b2c60a4cef6 Reviewed-on: https://go-review.googlesource.com/c/go/+/601756 Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Diffstat (limited to 'src/cmd/internal/script/scripttest/run.go')
-rw-r--r--src/cmd/internal/script/scripttest/run.go23
1 files changed, 20 insertions, 3 deletions
diff --git a/src/cmd/internal/script/scripttest/run.go b/src/cmd/internal/script/scripttest/run.go
index 29eb6f88f2..8dff13e22e 100644
--- a/src/cmd/internal/script/scripttest/run.go
+++ b/src/cmd/internal/script/scripttest/run.go
@@ -34,7 +34,7 @@ type ToolReplacement struct {
// is that we'll be called from the top level cmd/X dir for tool X,
// and that instead of executing the install tool X we'll use the
// test binary instead.
-func RunToolScriptTest(t *testing.T, repls []ToolReplacement, pattern string) {
+func RunToolScriptTest(t *testing.T, repls []ToolReplacement, scriptsdir string, fixReadme bool) {
// Nearly all script tests involve doing builds, so don't
// bother here if we don't have "go build".
testenv.MustHaveGoBuild(t)
@@ -125,9 +125,9 @@ func RunToolScriptTest(t *testing.T, repls []ToolReplacement, pattern string) {
// Add in commands for "go" and "cc".
testgo := filepath.Join(tgr, "bin", "go")
gocmd := script.Program(testgo, interrupt, gracePeriod)
- cccmd := script.Program(goEnv("CC"), interrupt, gracePeriod)
addcmd("go", gocmd)
- addcmd("cc", cccmd)
+ cmdExec := cmds["exec"]
+ addcmd("cc", scriptCC(cmdExec, goEnv("CC")))
// Add various helpful conditions related to builds and toolchain use.
goHostOS, goHostArch := goEnv("GOHOSTOS"), goEnv("GOHOSTARCH")
@@ -153,8 +153,13 @@ func RunToolScriptTest(t *testing.T, repls []ToolReplacement, pattern string) {
Quiet: !testing.Verbose(),
}
+ t.Run("README", func(t *testing.T) {
+ checkScriptReadme(t, engine, env, scriptsdir, gotool, fixReadme)
+ })
+
// ... and kick off tests.
ctx := context.Background()
+ pattern := filepath.Join(scriptsdir, "*.txt")
RunTests(t, ctx, engine, env, pattern)
}
@@ -253,3 +258,15 @@ func tempEnvName() string {
return "TMPDIR"
}
}
+
+// scriptCC runs the platform C compiler.
+func scriptCC(cmdExec script.Cmd, ccexe string) script.Cmd {
+ return script.Command(
+ script.CmdUsage{
+ Summary: "run the platform C compiler",
+ Args: "args...",
+ },
+ func(s *script.State, args ...string) (script.WaitFunc, error) {
+ return cmdExec.Run(s, append([]string{ccexe}, args...)...)
+ })
+}