build/toolbase/gotoolchain: init
Another piece of the toolbase puzzle, this one is a library which
provides information about the Go SDK picked by Bazel/rules_go, and
allows to build tools that call the `go` tool.
This is effectively the logic from //build/fietsje:def.bzl, but
rewritten to be reusable. In a later CL, we will make Fietsje use this
logic instead of its existing starlark/shell magic.
Change-Id: I2be723089410c81843b54df77bcd665a4e050cbb
Reviewed-on: https://review.monogon.dev/c/monogon/+/329
Reviewed-by: Mateusz Zalega <mateusz@monogon.tech>
diff --git a/build/toolbase/gotoolchain/toolchain_test.go b/build/toolbase/gotoolchain/toolchain_test.go
new file mode 100644
index 0000000..7b93d6d
--- /dev/null
+++ b/build/toolbase/gotoolchain/toolchain_test.go
@@ -0,0 +1,22 @@
+package gotoolchain
+
+import (
+ "os"
+ "os/exec"
+ "path"
+ "testing"
+)
+
+func TestGoToolRuns(t *testing.T) {
+ cmd := exec.Command(Go, "version")
+ if out, err := cmd.CombinedOutput(); err != nil {
+ t.Fatalf("Failed to run `go version`: %q, %v", string(out), err)
+ }
+}
+
+func TestGorootContainsRoot(t *testing.T) {
+ rootfile := path.Join(Root, "ROOT")
+ if _, err := os.Stat(rootfile); err != nil {
+ t.Fatalf("ROOT not found in %s", Root)
+ }
+}