Skip to content

Commit cba92fb

Browse files
authored
testscript: add Defer method (#50)
This allows commands and setup code to add actions that will be performed at the end of the test. This allows us to (for example) start a network server in the setup phase of a script and shut it down afterwards. Also rename the "scripts" directory to the more conventional "testdata".
1 parent f22f413 commit cba92fb

File tree

15 files changed

+47
-3
lines changed

15 files changed

+47
-3
lines changed

testscript/doc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ To invoke the tests, call testscript.Run. For example:
1010
1111
func TestFoo(t *testing.T) {
1212
testscript.Run(t, testscript.Params{
13-
Dir: "scripts",
13+
Dir: "testdata",
1414
})
1515
}
1616
File renamed without changes.
File renamed without changes.

testscript/testdata/defer.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
testdefer
2+
testdefer
3+
testdefer
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)