fix: -update flag

Carlos Alexandro Becker created

Change summary

testscript/script_test.go                        | 6 +++++-
testscript/testdata/script/settings.txtar        | 5 +++++
testscript/testdata/script/user_management.txtar | 1 +
3 files changed, 11 insertions(+), 1 deletion(-)

Detailed changes

testscript/script_test.go 🔗

@@ -2,6 +2,7 @@ package testscript
 
 import (
 	"context"
+	"flag"
 	"fmt"
 	"path/filepath"
 	"testing"
@@ -12,7 +13,10 @@ import (
 	"github.com/rogpeppe/go-internal/testscript"
 )
 
+var update = flag.Bool("update", false, "update script files")
+
 func TestScript(t *testing.T) {
+	flag.Parse()
 	key, err := filepath.Abs("./testdata/admin1")
 	if err != nil {
 		t.Fatal(err)
@@ -20,7 +24,7 @@ func TestScript(t *testing.T) {
 
 	testscript.Run(t, testscript.Params{
 		Dir:           "testdata/script",
-		UpdateScripts: true,
+		UpdateScripts: *update,
 		Cmds: map[string]func(ts *testscript.TestScript, neg bool, args []string){
 			"soft": func(ts *testscript.TestScript, _ bool, args []string) {
 				args = append([]string{

testscript/testdata/script/settings.txtar 🔗

@@ -1,14 +1,19 @@
+# vi: set ft=conf
+# check default allow-keyless
 soft settings allow-keyless true
 soft settings allow-keyless
 cmp stdout allow-keyless1.txt
 
+# change allow-keyless and check
 soft settings allow-keyless false
 soft settings allow-keyless
 cmp stdout allow-keyless2.txt
 
+# check default anon-access
 soft settings anon-access
 cmp stdout anon-access1.txt
 
+# chaneg anon-access to all available options, and check them
 soft settings anon-access no-access
 soft settings anon-access
 cmp stdout anon-access2.txt