diff --git a/testscript/testdata/testscript_update_script.txt b/testscript/testdata/testscript_update_script.txt index db481ec8..b53e42fb 100644 --- a/testscript/testdata/testscript_update_script.txt +++ b/testscript/testdata/testscript_update_script.txt @@ -1,6 +1,6 @@ unquote scripts/testscript.txt unquote testscript-new.txt -testscript-update scripts +testscript -update scripts cmp scripts/testscript.txt testscript-new.txt -- scripts/testscript.txt -- diff --git a/testscript/testdata/testscript_update_script_actual_is_file.txt b/testscript/testdata/testscript_update_script_actual_is_file.txt index 297c7aa4..ff1dc373 100644 --- a/testscript/testdata/testscript_update_script_actual_is_file.txt +++ b/testscript/testdata/testscript_update_script_actual_is_file.txt @@ -1,6 +1,6 @@ unquote scripts/testscript.txt unquote testscript-new.txt -testscript-update scripts +testscript -update scripts cmp scripts/testscript.txt testscript-new.txt -- scripts/testscript.txt -- diff --git a/testscript/testdata/testscript_update_script_expected_not_in_archive.txt b/testscript/testdata/testscript_update_script_expected_not_in_archive.txt index cda575c9..7832159c 100644 --- a/testscript/testdata/testscript_update_script_expected_not_in_archive.txt +++ b/testscript/testdata/testscript_update_script_expected_not_in_archive.txt @@ -2,7 +2,7 @@ unquote scripts/testscript.txt cp scripts/testscript.txt unchanged -! testscript-update scripts +! testscript -update scripts cmp scripts/testscript.txt unchanged -- scripts/testscript.txt -- diff --git a/testscript/testdata/testscript_update_script_quote.txt b/testscript/testdata/testscript_update_script_quote.txt index a634b8b8..b1b7b039 100644 --- a/testscript/testdata/testscript_update_script_quote.txt +++ b/testscript/testdata/testscript_update_script_quote.txt @@ -1,6 +1,6 @@ unquote scripts/testscript.txt unquote testscript-new.txt -testscript-update scripts +testscript -update scripts cmp scripts/testscript.txt testscript-new.txt -- scripts/testscript.txt -- diff --git a/testscript/testdata/testscript_update_script_stderr.txt b/testscript/testdata/testscript_update_script_stderr.txt index 66882b83..808ebe0b 100644 --- a/testscript/testdata/testscript_update_script_stderr.txt +++ b/testscript/testdata/testscript_update_script_stderr.txt @@ -1,6 +1,6 @@ unquote scripts/testscript.txt unquote testscript-new.txt -testscript-update scripts +testscript -update scripts cmp scripts/testscript.txt testscript-new.txt -- scripts/testscript.txt -- diff --git a/testscript/testscript_test.go b/testscript/testscript_test.go index 0fef259c..faf1e54c 100644 --- a/testscript/testscript_test.go +++ b/testscript/testscript_test.go @@ -7,6 +7,7 @@ package testscript import ( "bytes" "errors" + "flag" "fmt" "io/ioutil" "os" @@ -133,7 +134,8 @@ func TestScripts(t *testing.T) { // TODO set temp directory. testDeferCount := 0 Run(t, Params{ - Dir: "testdata", + UpdateScripts: os.Getenv("TESTSCRIPT_UPDATE") != "", + Dir: "testdata", Cmds: map[string]func(ts *TestScript, neg bool, args []string){ "setSpecialVal": setSpecialVal, "ensureSpecialVal": ensureSpecialVal, @@ -176,12 +178,19 @@ func TestScripts(t *testing.T) { ts.Fatalf("reading %q; got %q want %q", args[0], got, want) } }, - "testscript-update": func(ts *TestScript, neg bool, args []string) { + "testscript": func(ts *TestScript, neg bool, args []string) { // Run testscript in testscript. Oooh! Meta! - if len(args) != 1 { - ts.Fatalf("testscript