Commit Graph

62 Commits

Author SHA1 Message Date
Daniel Martí
19e4c098cd make selection of packages configurable via GOPRIVATE
Carefully select a default that will do the right thing when inside a
module, as well as when building ad-hoc packages.

This means we no longer need to look at the compiler's -std flag, which
is nice.

Also replace foo.com/ with test/, as per golang/go#37641.

Fixes #7.
2020-04-28 21:42:39 +01:00
Daniel Martí
d72c00eafd support building modules which require other modules
We use 'go list -json -export' to locate required modules. This works
fine to locate direct module dependencies; since we're building in the
current module, we run 'go list' in the correct directory.

However, if we're building one of those module dependencies, and it has
other module dependencies of its own, we would fail with cryptic errors
like:

	typecheck error: [...] go list error: updates to go.sum needed, disabled by -mod=readonly

This is because we would try to run 'go list' outside of the main
module, probably inside the module cache. Instead, use a $GARBLE_DIR env
var from the top-level 'garble build' call to always run 'go list' in
the original directory.

We add a few small modules to properly test this.

Updates #9.
2020-04-04 20:30:48 +01:00
Daniel Martí
308e984293 don't use regexes when searching binaries for strings
This is a bit simpler, and saves us a small amount of CPU work in the
tests.
2020-02-23 12:57:39 +01:00
Daniel Martí
b10cce34f8 parse boolean flags differently from string flags
This is important, because "-std -foo" and "-buildid -foo" are entirely
different cases. The first is equivalent to "-std=true -foo" since the
flag is boolean, but the second is equivalent to "-buildid=-foo" since
the flag isn't boolean.

We can keep track of which of the flags we're interested in are boolean,
which isn't much extra work. Also add unit tests; the build ID is a
hash, so it's very hard to write an end-to-end test that reliably has an
ID starting with a dash.
2020-02-16 17:54:24 +00:00
Daniel Martí
a6d2891a90 switch to gotooltest 2020-02-08 23:15:52 +00:00
Daniel Martí
5556be7402 make the tool work on Windows, enable tests
The tests required a few last tweaks to work on Windows.
2019-12-09 16:47:59 +00:00
Daniel Martí
0058dfc12a make output binaries deterministic
We were leaking temporary file paths, which is no longer the case.
2019-12-09 13:57:03 +00:00
Daniel Martí
22e7e4e848 add a bincmp builtin test command
To be used soon for reproducible builds.
2019-12-09 13:00:36 +00:00
Daniel Martí
ab560ff007 start testing on GitHub Actions
No windows yet, because a few portability issues remain.
2019-12-09 12:44:43 +00:00
Daniel Martí
e08dd99c1e introduce a binary grep command for the tests
The problem with the "grep" built-in command is that it prints the
entire data if there is an error. We don't want megabytes of binary
output for a test.
2019-12-09 12:21:48 +00:00
Daniel Martí
63f58242fb move garble binary setup with $PATH to Setup
This way, it's ready for multiple scripts.
2019-12-08 18:03:52 +00:00
Daniel Martí
f5f72ef626 initial commit 2019-12-08 11:52:40 +00:00