From 87ebebb520af0cc1fbb0978025a416aa8c5a2300 Mon Sep 17 00:00:00 2001 From: Paul Scheduikat Date: Sun, 15 Jun 2025 18:25:20 +0200 Subject: [PATCH] format testscript files with gofmt --- CONTRIBUTING.md | 3 ++ testdata/script/asm.txtar | 1 + testdata/script/atomic.txtar | 1 + testdata/script/cache.txtar | 10 ++++++ testdata/script/cgo.txtar | 3 ++ testdata/script/ctrlflow.txtar | 45 ++++++++++++++------------- testdata/script/gogarble.txtar | 6 +++- testdata/script/goversion.txtar | 4 +-- testdata/script/implement.txtar | 20 ++++++------ testdata/script/imports.txtar | 12 +++++-- testdata/script/init.txtar | 12 +++++++ testdata/script/ldflags.txtar | 2 ++ testdata/script/linkname.txtar | 15 ++++++++- testdata/script/linkname_forbid.txtar | 2 +- testdata/script/list_error.txtar | 2 ++ testdata/script/literals.txtar | 45 ++++++++++++++------------- testdata/script/plugin.txtar | 3 ++ testdata/script/position.txtar | 1 + testdata/script/reflect.txtar | 21 ++++++------- testdata/script/reverse.txtar | 4 ++- testdata/script/seed-cache.txtar | 1 + testdata/script/seed.txtar | 5 +-- testdata/script/syntax.txtar | 7 +++-- testdata/script/test.txtar | 10 ++++++ testdata/script/tiny.txtar | 2 +- 25 files changed, 159 insertions(+), 78 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0583b5f..f452563 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -18,6 +18,9 @@ Just the usual `go test ./...`; many of the tests are in `testdata/scripts/`, which allows laying out files and shell-like steps to run as part of the test. +For editor support of testscript files in vscode (highlighting and formatting), install the +[vscode-testscript](https://marketplace.visualstudio.com/items?itemName=twpayne.vscode-testscript) extension. + Note that the tests do real builds, so they are quite slow; on an average laptop, `go test` can take over thirty seconds. Here are some tips: diff --git a/testdata/script/asm.txtar b/testdata/script/asm.txtar index 0bb5756..30b785d 100644 --- a/testdata/script/asm.txtar +++ b/testdata/script/asm.txtar @@ -62,6 +62,7 @@ func main() { println(imported.AddImpl(3, 4)) } + -- garble_main_amd64.s -- #include "garble_define_amd64.h" diff --git a/testdata/script/atomic.txtar b/testdata/script/atomic.txtar index 813c240..cbf87ad 100644 --- a/testdata/script/atomic.txtar +++ b/testdata/script/atomic.txtar @@ -47,5 +47,6 @@ func main() { wg.Wait() println(unalignedUint64.u64.Load()) } + -- main.stderr -- 20 diff --git a/testdata/script/cache.txtar b/testdata/script/cache.txtar index 6f5c2ec..651b058 100644 --- a/testdata/script/cache.txtar +++ b/testdata/script/cache.txtar @@ -43,6 +43,7 @@ func main() { level1b.Print() level1c.Print() } + -- level1a/pkg.go -- package level1a @@ -52,14 +53,17 @@ import ( ) func Print() { println(level2x.Value, level2y.Value) } + -- level1a/level2x/pkg.go -- package level2x var Value = "1a/2x" + -- level1a/level2y/pkg.go -- package level2y var Value = "1a/2y" + -- level1b/pkg.go -- package level1b @@ -69,14 +73,17 @@ import ( ) func Print() { println(level2x.Value, level2y.Value) } + -- level1b/level2x/pkg.go -- package level2x var Value = "1b/2x" + -- level1b/level2y/pkg.go -- package level2y var Value = "1b/2y" + -- level1c/pkg.go -- package level1c @@ -86,14 +93,17 @@ import ( ) func Print() { println(level2x.Value, level2y.Value) } + -- level1c/level2x/pkg.go -- package level2x var Value = "1c/2x" + -- level1c/level2y/pkg.go -- package level2y var Value = "1c/2y" + -- main.stderr -- 1a/2x 1a/2y 1b/2x 1b/2y diff --git a/testdata/script/cgo.txtar b/testdata/script/cgo.txtar index a032659..53a7ec5 100644 --- a/testdata/script/cgo.txtar +++ b/testdata/script/cgo.txtar @@ -43,6 +43,7 @@ func main() { imported.RegularFunc() cgoFunc() } + -- imported/imported_regular.go -- package imported @@ -58,6 +59,7 @@ func RegularFunc() { fmt.Println("regular filename:", filename) } } + -- cgo_main.go -- package main @@ -112,6 +114,7 @@ func goCallback() { func printString(cs *C.char) { fmt.Println(C.GoString(cs)) } + -- separate.h -- void separateFunction(); -- separate.c -- diff --git a/testdata/script/ctrlflow.txtar b/testdata/script/ctrlflow.txtar index ed31589..e26b34a 100644 --- a/testdata/script/ctrlflow.txtar +++ b/testdata/script/ctrlflow.txtar @@ -46,37 +46,38 @@ func func1() {} //garble:controlflow flatten_passes=1 junk_jumps=max block_splits=max flatten_hardening=xor func xorHardeningTest(i int) int { - if i == 0 { - return 1 - } - return i * 2; + if i == 0 { + return 1 + } + return i * 2 } //garble:controlflow flatten_passes=1 junk_jumps=max block_splits=max flatten_hardening=delegate_table func delegateHardeningTest(i int) int { - if i == 0 { - return 1 - } - return i * 3; + if i == 0 { + return 1 + } + return i * 3 } -//garble:controlflow flatten_passes=1 junk_jumps=max block_splits=max flatten_hardening=xor,delegate_table // Trigger multiple hardening using multiple anonymous functions +// +//garble:controlflow flatten_passes=1 junk_jumps=max block_splits=max flatten_hardening=xor,delegate_table func multiHardeningTest(i int) int { - notZero := func(i int) bool { - return i != 0 - } - isZero := func(i int) bool { - return i == 0 - } - multiply := func(i int) int { - return i * 4 - } + notZero := func(i int) bool { + return i != 0 + } + isZero := func(i int) bool { + return i == 0 + } + multiply := func(i int) int { + return i * 4 + } - if !notZero(i) && isZero(i) { - return 1 - } - return multiply(i); + if !notZero(i) && isZero(i) { + return 1 + } + return multiply(i) } //garble:controlflow diff --git a/testdata/script/gogarble.txtar b/testdata/script/gogarble.txtar index 512ced0..984392e 100644 --- a/testdata/script/gogarble.txtar +++ b/testdata/script/gogarble.txtar @@ -65,6 +65,7 @@ go 1.23 package main func main() {} + -- importer/importer.go -- package main @@ -74,10 +75,12 @@ func main() { println(imported.LongString) println("some long string to not obfuscate") } + -- imported/imported.go -- package imported var LongString = "some long string to obfuscate" + -- stdimporter/main.go -- package main @@ -87,8 +90,8 @@ import ( "os" "runtime" "runtime/debug" - "time" "syscall" + "time" ) func main() { @@ -106,6 +109,7 @@ func main() { syscall.Listen(0, 1) } } + -- stdimporter.stdout -- runtime.GOROOT: "" runtime.Version: "unknown" diff --git a/testdata/script/goversion.txtar b/testdata/script/goversion.txtar index 2fcb6d5..0bac878 100644 --- a/testdata/script/goversion.txtar +++ b/testdata/script/goversion.txtar @@ -96,9 +96,9 @@ import ( func main() { if len(os.Args) > 0 && os.Args[1] == "env" { - enc, _ := json.Marshal(struct{ + enc, _ := json.Marshal(struct { GOVERSION string - } { + }{ GOVERSION: os.Getenv("TOOLCHAIN_GOVERSION"), }) fmt.Printf("%s\n", enc) diff --git a/testdata/script/implement.txtar b/testdata/script/implement.txtar index 0b7d75f..8750485 100644 --- a/testdata/script/implement.txtar +++ b/testdata/script/implement.txtar @@ -47,14 +47,14 @@ var _ privateInterface = T("") type StructUnnamed = struct { Foo int Bar []*struct { - Nested *[]string + Nested *[]string NestedTagged string - NestedAlias int64 // we can skip the alias too + NestedAlias int64 // we can skip the alias too } Named lib3.Named lib3.StructEmbed Tagged string // no field tag - Alias int64 // we can skip the alias too + Alias int64 // we can skip the alias too } var _ = lib1.Struct1(lib2.Struct2{}) @@ -88,14 +88,14 @@ import "test/main/lib3" type Struct1 struct { Foo int Bar []*struct { - Nested *[]string + Nested *[]string NestedTagged string `json:"tagged1"` - NestedAlias alias1 + NestedAlias alias1 } Named lib3.Named lib3.StructEmbed Tagged string `json:"tagged1"` - Alias alias1 + Alias alias1 } type alias1 = int64 @@ -108,17 +108,18 @@ import "test/main/lib3" type Struct2 struct { Foo int Bar []*struct { - Nested *[]string + Nested *[]string NestedTagged string `json:"tagged2"` - NestedAlias alias2 + NestedAlias alias2 } Named lib3.Named lib3.StructEmbed Tagged string `json:"tagged2"` - Alias alias2 + Alias alias2 } type alias2 = int64 + -- lib3/lib3.go -- package lib3 @@ -127,6 +128,7 @@ type Named int type StructEmbed struct { Baz any } + -- main.stdout -- String method for foo unexported method for foo diff --git a/testdata/script/imports.txtar b/testdata/script/imports.txtar index 257275d..a855317 100644 --- a/testdata/script/imports.txtar +++ b/testdata/script/imports.txtar @@ -72,14 +72,14 @@ rsc.io/testonly v1.0.0/go.mod h1:OqmGbIFOcF+XrFReLOGZ6BhMM7uMBiQwZsyNmh74SzY= package main import ( - "fmt" "database/sql" + "fmt" "test/main/importedpkg" - "rsc.io/quote" garbletest "gopkg.in/garbletest.v2" garbletestconst "gopkg.in/garbletestconst.v2" + "rsc.io/quote" ) func main() { @@ -95,12 +95,14 @@ func main() { fmt.Println(garbletestconst.StrConst) fmt.Println(sql.Drivers()[0]) } + -- notag_fail.go -- //go:build !buildtag package main var foo int = "should be omitted by -tags" + -- withtag_success.go -- //go:build buildtag @@ -109,6 +111,7 @@ package main import "fmt" func init() { fmt.Println("buildtag init func") } + -- differentpkg_unnamed.go -- package main @@ -119,12 +122,14 @@ import ( var _ = actualpkgname.Noop var _ = goextension.Noop + -- differentpkg_named.go -- package main import named "test/main/different-pkg-name" var _ = named.Noop + -- importedpkg/imported.go -- package importedpkg @@ -172,10 +177,12 @@ import ( var _ indirect.Indirect var _ = another.Blank + -- importedpkg/another/pkg.go -- package another const Blank = 3 + -- importedpkg/indirect/indirect.go -- package indirect @@ -192,6 +199,7 @@ var Noop int package goextension var Noop int + -- main.stdout -- buildtag init func imported var value diff --git a/testdata/script/init.txtar b/testdata/script/init.txtar index d50923a..75edce7 100644 --- a/testdata/script/init.txtar +++ b/testdata/script/init.txtar @@ -36,52 +36,64 @@ func main() { println(string(chungus)) println(string(yoshi)) } + -- y.go -- package main // yoshi is filled by ordered init funcs, all in different files. // If we change the relative order of filenames when sorted, this file will break. var yoshi []byte + -- y0.go -- package main func init() { yoshi = append(yoshi, 'B') } + -- y1.go -- package main func init() { yoshi = append(yoshi, 'E') } + -- y2.go -- package main func init() { yoshi = append(yoshi, 'E') } + -- y3.go -- package main func init() { yoshi = append(yoshi, 'G') } + -- y4.go -- package main func init() { yoshi = append(yoshi, ' ') } + -- y5.go -- package main func init() { yoshi = append(yoshi, 'Y') } + -- y6.go -- package main func init() { yoshi = append(yoshi, 'O') } + -- y7.go -- package main func init() { yoshi = append(yoshi, 'S') } + -- y8.go -- package main func init() { yoshi = append(yoshi, 'H') } + -- y9.go -- package main func init() { yoshi = append(yoshi, 'I') } + -- main.stderr -- Big Chungus BEEG YOSHI diff --git a/testdata/script/ldflags.txtar b/testdata/script/ldflags.txtar index dd361bd..6de2e91 100644 --- a/testdata/script/ldflags.txtar +++ b/testdata/script/ldflags.txtar @@ -57,6 +57,7 @@ func main() { fmt.Printf("should be kept: %q, %q\n", notReplacedBefore, notReplacedAfter) fmt.Printf("no longer unset: %q\n", imported.ExportedUnset) } + -- imported/imported.go -- package imported @@ -65,6 +66,7 @@ var ( otherVar int ) + -- main.stdout -- version: "v1.22.33" becomes empty: "" diff --git a/testdata/script/linkname.txtar b/testdata/script/linkname.txtar index 0dd794c..da65ada 100644 --- a/testdata/script/linkname.txtar +++ b/testdata/script/linkname.txtar @@ -43,39 +43,48 @@ import ( ) // A linkname to an external obfuscated func. +// //go:linkname obfuscatedFunc test/main/imported.ObfuscatedFuncImpl func obfuscatedFunc() string // A linkname to an external obfuscated method. +// //go:linkname obfuscatedMethod test/main/imported.Receiver.obfuscatedMethod func obfuscatedMethod(imported.Receiver) string // A linkname to an external unobfuscated method. +// //go:linkname unobfuscatedMethod test/main/imported.Receiver.UnobfuscatedMethod func unobfuscatedMethod(imported.Receiver) string // A linkname to an external obfuscated pointer method, with an extra parameter. +// //go:linkname obfuscatedPointerMethod test/main/imported.(*Receiver).obfuscatedPointerMethod func obfuscatedPointerMethod(*imported.Receiver, string) string // Similar to the above, but for std, plus having to define a type. // Some libraries do abuse reflect in this way, unfortunately. type rtype struct{} + //go:linkname rtype_ptrTo reflect.(*rtype).ptrTo func rtype_ptrTo(*rtype) *rtype + //go:linkname rtype_NumMethod reflect.(*rtype).NumMethod func rtype_NumMethod(*rtype) int // A linkname to an entirely made up name, implemented elsewhere. +// //go:linkname renamedFunc madeup.newName func renamedFunc() string // A linkname to an external non-obfuscated func in another // module whose package path has a dot in it. +// //go:linkname tagline big.chungus/meme.chungify func tagline() string // A linkname to an external non-obfuscated func with receiver which is also non-obfuscated +// //go:linkname changeThing test/main/imported.(*channel).changeThing func changeThing(c unsafe.Pointer, to string) @@ -108,6 +117,7 @@ func main() { println(a.DoThing()) } + -- imported/imported.go -- package imported @@ -144,7 +154,7 @@ func ObfuscatedFuncImpl() string { return "obfuscated func" } -type Receiver struct{ +type Receiver struct { Field string } @@ -167,8 +177,10 @@ func renamedFunc() string { // A linkname to an external non-obfuscated func. // Different from byteIndex, as we call this from an importer package. +// //go:linkname ByteIndex strings.IndexByte func ByteIndex(s string, c byte) int + -- big.chungus/meme/go.mod -- module test/main @@ -179,6 +191,7 @@ package meme func chungify() string { return "featuring Dante from the Devil May Cry series" } + -- main.stderr -- obfuscated func obfuscated method: field value diff --git a/testdata/script/linkname_forbid.txtar b/testdata/script/linkname_forbid.txtar index 119645e..6a4703e 100644 --- a/testdata/script/linkname_forbid.txtar +++ b/testdata/script/linkname_forbid.txtar @@ -23,7 +23,7 @@ import _ "unsafe" // Note that it doesn't matter that the struct here is empty, // as the linknames below only use pointers to it. -type moduledata struct {} +type moduledata struct{} //go:linkname lastmoduledatap runtime.lastmoduledatap var lastmoduledatap *moduledata diff --git a/testdata/script/list_error.txtar b/testdata/script/list_error.txtar index 9c7b151..333b838 100644 --- a/testdata/script/list_error.txtar +++ b/testdata/script/list_error.txtar @@ -15,12 +15,14 @@ package broken // A broken package will list in JSON form like: // {..., "Incomplete": true, "Error": {...}, ...} var x string = 123 + -- imports_broken/imports.go -- package imports_broken // Importing a broken package will list in JSON form like: // {..., "Incomplete": false, ...} import _ "test/main/broken" + -- imports_missing/imports.go -- package imports_missing diff --git a/testdata/script/literals.txtar b/testdata/script/literals.txtar index 8c4c173..542fe18 100644 --- a/testdata/script/literals.txtar +++ b/testdata/script/literals.txtar @@ -72,9 +72,9 @@ import ( "test/main/imp" . "test/main/imp_const" . "test/main/imp_func" - . "test/main/imp_var" - . "test/main/imp_type" . "test/main/imp_struct" + . "test/main/imp_type" + . "test/main/imp_var" ) type structTest struct { @@ -336,17 +336,17 @@ func shadowTest() { } func dotImportTest() { - println(DotImportedStr) - println(DotImportedFunc()) - println(DotImportedVar) - println(DotImportedType("str as dot imported type")) - println(DotImportedStruct.Str) + println(DotImportedStr) + println(DotImportedFunc()) + println(DotImportedVar) + println(DotImportedType("str as dot imported type")) + println(DotImportedStruct.Str) } func multipleTimeImportTest() { - regularAndUnusedRenamed() - regularAndUnusedDotImport() - unusedRegularAndDotImport() + regularAndUnusedRenamed() + regularAndUnusedDotImport() + unusedRegularAndDotImport() } func noop(...any) {} @@ -355,45 +355,46 @@ func noop(...any) {} package main import ( - "test/main/imp_mult" - imp_mult2 "test/main/imp_mult" + "test/main/imp_mult" + imp_mult2 "test/main/imp_mult" ) func regularAndUnusedRenamed() { - imp_mult.MultDummy() - noop(imp_mult.MultImpStr, imp_mult2.MultImpStr) + imp_mult.MultDummy() + noop(imp_mult.MultImpStr, imp_mult2.MultImpStr) } -- regular_and_unused_dotimport.go -- package main import ( - "test/main/imp_mult" - . "test/main/imp_mult" + "test/main/imp_mult" + . "test/main/imp_mult" ) func regularAndUnusedDotImport() { - imp_mult.MultDummy() - noop(imp_mult.MultImpStr, MultImpStr) + imp_mult.MultDummy() + noop(imp_mult.MultImpStr, MultImpStr) } -- unused_regular_and_dotimport.go -- package main import ( - "test/main/imp_mult" - . "test/main/imp_mult" + "test/main/imp_mult" + . "test/main/imp_mult" ) func unusedRegularAndDotImport() { - MultDummy() - noop(imp_mult.MultImpStr, MultImpStr) + MultDummy() + noop(imp_mult.MultImpStr, MultImpStr) } -- imp/imported.go -- package imported type ImportedType int + -- imp_const/imported.go -- package imp_const diff --git a/testdata/script/plugin.txtar b/testdata/script/plugin.txtar index e0c9750..bf0219b 100644 --- a/testdata/script/plugin.txtar +++ b/testdata/script/plugin.txtar @@ -37,10 +37,12 @@ var PublicVar int = lib.ImportedFunc() func privateFunc(n int) { println("Hello, number", n) } func PublicFunc() { privateFunc(PublicVar) } + -- plugin/lib/lib.go -- package lib func ImportedFunc() int { return 4 } + -- main.go -- package main @@ -62,5 +64,6 @@ func main() { *v.(*int) = 7 f.(func())() } + -- main.stderr -- Hello, number 7 diff --git a/testdata/script/position.txtar b/testdata/script/position.txtar index 9bd145c..983b2a2 100644 --- a/testdata/script/position.txtar +++ b/testdata/script/position.txtar @@ -68,6 +68,7 @@ func issue_573(s struct{ f int }) { var _ *int = &s.f /*x*/ } + -- garble_other_filename.go -- package main diff --git a/testdata/script/reflect.txtar b/testdata/script/reflect.txtar index eaeab59..936d5ae 100644 --- a/testdata/script/reflect.txtar +++ b/testdata/script/reflect.txtar @@ -30,10 +30,10 @@ import ( "math/big" "os" "reflect" - "unsafe" "strings" "sync" "text/template" + "unsafe" "test/main/importedpkg" "test/main/importedpkg2" @@ -66,7 +66,7 @@ func main() { // Another common library, text/template. tmpl := template.Must(template.New("").Parse("Hello {{.Name}}.")) - _ = tmpl.Execute(os.Stdout, struct{Name string}{Name: "Dave"}) + _ = tmpl.Execute(os.Stdout, struct{ Name string }{Name: "Dave"}) fmt.Println() // Always print a newline. // Another complex case, involving embedding and another package. @@ -133,20 +133,20 @@ func main() { // Local names not used in reflection should not be in the final binary, // even if they are embedded in a struct and become a field name. - type unexportedLocalObfuscated struct { LocalObfuscatedA int } - type ExportedLocalObfuscated struct { LocalObfuscatedB int } + type unexportedLocalObfuscated struct{ LocalObfuscatedA int } + type ExportedLocalObfuscated struct{ LocalObfuscatedB int } type EmbeddingObfuscated struct { unexportedLocalObfuscated ExportedLocalObfuscated } // Ensure the types are kept in the binary. Use an anonymous type too. _ = fmt.Sprintf("%#v", EmbeddingObfuscated{}) - _ = fmt.Sprintf("%#v", struct{ExportedLocalObfuscated}{}) + _ = fmt.Sprintf("%#v", struct{ ExportedLocalObfuscated }{}) // reflection can see all type names, even local ones, so they cannot be obfuscated. { - type TypeOfNamedField struct { NamedReflectionField int } - type TypeOfEmbeddedField struct { EmbeddedReflectionField int } + type TypeOfNamedField struct{ NamedReflectionField int } + type TypeOfEmbeddedField struct{ EmbeddedReflectionField int } type TypeOfParent struct { ReflectionField TypeOfNamedField TypeOfEmbeddedField @@ -178,7 +178,7 @@ func main() { type EmbeddingIndirect struct { // With field names, to test selectors above. - With importedpkg.AliasIndirectNamedWithReflect + With importedpkg.AliasIndirectNamedWithReflect Without importedpkg.AliasIndirectNamedWithoutReflect // Embedding used to crash garble, too. @@ -348,7 +348,6 @@ func reflectUnrelatedConv() { } - type StatUser struct { Id int64 `gorm:"primaryKey"` User_Id int64 @@ -545,7 +544,7 @@ var ReflectInDefinedVar = ReflectInDefined{ExportedField2: 9000} var _ = reflect.TypeOf(ReflectInDefinedVar) -var _ = reflect.TypeOf([]*struct{EmbeddingOuter}{}) +var _ = reflect.TypeOf([]*struct{ EmbeddingOuter }{}) type EmbeddingOuter struct { EmbeddingInner @@ -563,7 +562,7 @@ type UnnamedWithDownstreamReflect = struct { } type ( - AliasIndirectNamedWithReflect = indirect.IndirectNamedWithReflect + AliasIndirectNamedWithReflect = indirect.IndirectNamedWithReflect AliasIndirectNamedWithoutReflect = indirect.IndirectNamedWithoutReflect ) diff --git a/testdata/script/reverse.txtar b/testdata/script/reverse.txtar index ac90275..f8c31db 100644 --- a/testdata/script/reverse.txtar +++ b/testdata/script/reverse.txtar @@ -74,6 +74,7 @@ func unexportedMainFunc() { } anonFunc() } + -- lib/long_lib.go -- package lib @@ -85,7 +86,7 @@ import ( "runtime/debug" ) -type ExportedLibType struct{ +type ExportedLibType struct { ExportedLibField int } @@ -118,6 +119,7 @@ func printStackTrace(w io.Writer) error { _, err := w.Write(bytes.Join(stackLines, []byte("\n"))) return err } + -- reverse.stdout -- lib filename: test/main/lib/long_lib.go diff --git a/testdata/script/seed-cache.txtar b/testdata/script/seed-cache.txtar index 335aa11..dd5bf0b 100644 --- a/testdata/script/seed-cache.txtar +++ b/testdata/script/seed-cache.txtar @@ -49,6 +49,7 @@ package main import garbletest "gopkg.in/garbletest.v2" func main() { garbletest.Test() } + -- mod2/go.mod -- module test/main/mod2 diff --git a/testdata/script/seed.txtar b/testdata/script/seed.txtar index 6e9fcdd..71c2da0 100644 --- a/testdata/script/seed.txtar +++ b/testdata/script/seed.txtar @@ -134,10 +134,10 @@ func mainFunc() { for _, name := range hashedNames { name = name[len("main."):] if len(name) < 6 { - panic("ended up with a hashed name that's too short: "+name) + panic("ended up with a hashed name that's too short: " + name) } if len(name) > 12 { - panic("ended up with a hashed name that's too long: "+name) + panic("ended up with a hashed name that's too long: " + name) } count[len(name)]++ if count[len(name)] >= 14 { @@ -218,6 +218,7 @@ func CallerFuncName() string { fn := runtime.FuncForPC(pc) return fn.Name() } + -- main.stderr -- teststring imported var value diff --git a/testdata/script/syntax.txtar b/testdata/script/syntax.txtar index eb5dc80..13876a2 100644 --- a/testdata/script/syntax.txtar +++ b/testdata/script/syntax.txtar @@ -23,6 +23,7 @@ package extra func Func() string { return "This is a separate module to obfuscate." } + -- go.mod -- module test/main @@ -129,7 +130,7 @@ func main() { _ = sub.EmbeddingExternalForeignAlias{ ExternalForeignAlias: nil, - Reader: nil, + Reader: nil, } var emb sub.EmbeddingAlias @@ -185,7 +186,7 @@ var someGlobalVar2 = "2" func Test() { var A, B, C, D, E string noop(A, B, C, D, E) - if someGlobalVar0 != "0" || someGlobalVar1 != "1" || someGlobalVar2 != "2"{ + if someGlobalVar0 != "0" || someGlobalVar1 != "1" || someGlobalVar2 != "2" { panic("name collision detected") } } @@ -221,7 +222,7 @@ type foreignAlias = io.Reader var _ = embeddingForeignAlias{ foreignAlias: nil, - Reader: nil, + Reader: nil, } // Similar to embeddingForeignAlias, diff --git a/testdata/script/test.txtar b/testdata/script/test.txtar index d104f7d..17d0c38 100644 --- a/testdata/script/test.txtar +++ b/testdata/script/test.txtar @@ -70,6 +70,7 @@ func OriginalFuncName() string { fn := runtime.FuncForPC(pc) return fn.Name() } + -- bar_test.go -- package bar @@ -82,6 +83,7 @@ func TestFoo(t *testing.T) { } t.Logf("package bar, func name: %s", OriginalFuncName()) } + -- bar_separate_test.go -- package bar_test @@ -107,6 +109,7 @@ func TestWithFlag(t *testing.T) { t.Skip() } } + -- main_test.go -- package bar @@ -118,34 +121,41 @@ import ( func TestMain(m *testing.M) { os.Exit(m.Run()) } + -- somemain/main.go -- package main func main() {} + -- somemaintest/main.go -- package main func main() {} + -- somemaintest/main_test.go -- package main import "testing" func TestMain(t *testing.T) {} + -- sometest/foo_test.go -- package sometest import "testing" func TestFoo(t *testing.T) {} + -- exporttest/foo.go -- package exporttest type foo int + -- exporttest/export_test.go -- package exporttest type Foo = foo + -- exporttest/foo_test.go -- package exporttest_test diff --git a/testdata/script/tiny.txtar b/testdata/script/tiny.txtar index 9114746..c7d99c0 100644 --- a/testdata/script/tiny.txtar +++ b/testdata/script/tiny.txtar @@ -36,7 +36,7 @@ import ( "runtime" ) -type testStruct struct {} +type testStruct struct{} func (testStruct) unexportedFunc() { println("dummy") }