mirror of
https://github.com/burrowers/garble
synced 2026-06-06 15:24:28 +00:00
30357af923
This lets us start taking advantage of featurs from Go 1.23, particularly tracking aliases in go/types and iterators. Note that we need to add code to properly handle or skip over the new *types.Alias type which go/types produces for Go type aliases. Also note that we actually turn this mode off entirely for now, due to the bug reported at https://go.dev/issue/70394. We don't yet remove our own alias tracking code yet due to the above. We hope to be able to remove it very soon.
88 lines
1.9 KiB
Plaintext
88 lines
1.9 KiB
Plaintext
# Test that garble keeps init functions in the order they were declared in.
|
|
|
|
exec garble build
|
|
exec ./main
|
|
cmp stderr main.stderr
|
|
|
|
[short] stop # no need to verify this with -short
|
|
|
|
go build
|
|
exec ./main
|
|
cmp stderr main.stderr
|
|
-- go.mod --
|
|
module test/main
|
|
|
|
go 1.23
|
|
-- main.go --
|
|
package main
|
|
|
|
// chungus is filled by ordered init funcs, all in a single file.
|
|
// If we change the relative order of init funcs within a file, this file will break.
|
|
var chungus []byte
|
|
|
|
func init() { chungus = append(chungus, 'B') }
|
|
func init() { chungus = append(chungus, 'i') }
|
|
func init() { chungus = append(chungus, 'g') }
|
|
func init() { chungus = append(chungus, ' ') }
|
|
func init() { chungus = append(chungus, 'C') }
|
|
func init() { chungus = append(chungus, 'h') }
|
|
func init() { chungus = append(chungus, 'u') }
|
|
func init() { chungus = append(chungus, 'n') }
|
|
func init() { chungus = append(chungus, 'g') }
|
|
func init() { chungus = append(chungus, 'u') }
|
|
func init() { chungus = append(chungus, 's') }
|
|
|
|
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
|