Files
garble/testdata/script/debugdir.txtar
T
Paul Scheduikat 53c5f022b4 Make -debugdir also output the unobfuscated source tree
This makes the unobfuscated state easily accessible, for debugging.

Obfuscated code is output to: `./<debugdir>/garbled`
The original source code is output to:
`./<debugdir>/source`

Also enable caching for debugdir to allow for faster iteration.
2026-03-01 22:55:02 +00:00

66 lines
2.4 KiB
Plaintext

exec garble -debugdir=debug1 build
exists 'debug1/source/test/main/imported/imported.go' 'debug1/source/test/main/main.go' 'debug1/source/reflect/type.go'
exists 'debug1/source/runtime/error.go' 'debug1/source/runtime/funcdata.h' 'debug1/source/runtime/asm.s'
[amd64] exists 'debug1/source/runtime/cpuflags_amd64.go' 'debug1/source/runtime/asm_amd64.s'
[!amd64] ! exists 'debug1/source/runtime/cpuflags_amd64.go' 'debug1/source/runtime/asm_amd64.s'
exists 'debug1/garbled/test/main/imported/imported.go' 'debug1/garbled/test/main/main.go' 'debug1/garbled/reflect/type.go'
exists 'debug1/garbled/runtime/error.go' 'debug1/garbled/runtime/funcdata.h' 'debug1/garbled/runtime/asm.s'
[amd64] exists 'debug1/garbled/runtime/cpuflags_amd64.go' 'debug1/garbled/runtime/asm_amd64.s'
[!amd64] ! exists 'debug1/garbled/runtime/cpuflags_amd64.go' 'debug1/garbled/runtime/asm_amd64.s'
grep ImportedFunc $WORK/debug1/source/test/main/imported/imported.go
grep ImportedFunc $WORK/debug1/source/test/main/main.go
grep 'some comment' $WORK/debug1/source/test/main/main.go
! grep ImportedFunc $WORK/debug1/garbled/test/main/imported/imported.go
! grep ImportedFunc $WORK/debug1/garbled/test/main/main.go
! grep 'some comment' $WORK/debug1/garbled/test/main/main.go
# We should refuse to delete non-empty directories which weren't created
# by an earlier invocation of garble -debugdir, as that could lead to data loss.
! exec garble -debugdir=notdebug build
stderr 'debugdir "notdebug" has unknown contents; empty it first'
exists notdebug/important_data.txt
exists notdebug/subdir/important_data.txt
[short] stop
# Sources from previous builds should be deleted
cp $WORK/debug1/garbled/test/main/main.go $WORK/debug1/some_file_from_prev_build.go
exec garble -debugdir=debug1 build
! exists $WORK/debug1/some_file_from_prev_build.go
exists 'debug1/source/test/main/main.go' 'debug1/garbled/test/main/main.go'
-- notdebug/important_data.txt --
This file should not be deleted by -debugdir.
-- notdebug/subdir/important_data.txt --
This file should not be deleted by -debugdir.
-- go.mod --
module test/main
go 1.23
-- main.go --
package main
import (
"reflect"
"test/main/imported" // some comment
)
type someType int // some comment
var someVar = 0
type someStruct struct {
someField int // some comment
}
func main() {
imported.ImportedFunc()
reflect.TypeOf(123)
}
-- imported/imported.go --
package imported
func ImportedFunc() {}