Sign in

Search issue titles and bodies, change requests and comments. Private repositories you cannot read are not included.

vole
Clone

Read only, no credentials:

https://rodent.software/git/vole.git

Write over SSH with a registered key:

git clone ssh://git@0.0.0.0:2222/vole.git

A free and open-source forge that lives in your Git repo.

Build the test binary with the test run's tags

9c188795215ebff279f076b1493f494a837fedb4 · Keenan Nemetz · 6d ago · parent ac541b26

Build the test binary with the test run's tags

The integration tests run the real vole binary, but TestMain built it with a plain go build. Tags passed to go test, such as sqlite_fts5, are not inherited by that child command, so a tagged test run tested an untagged server: rebuilding the index failed with 'SQLite has no FTS5 module' and a push did not refresh the index.

Read the tags recorded in the test binary's build info and pass them to the child build in both test harnesses.

server/ssh/sshserver_test.go +20−1

@@ -11,6 +11,7 @@ import (
11 11 "os"
12 12 "os/exec"
13 13 "path/filepath"
14 "runtime/debug"
14 15 "strings"
15 16 "testing"
16 17 "time"
@@ -26,6 +27,22 @@ import (
26 27
27 28 var binPath string
28 29
30 // binaryBuildArgs returns the tags this test binary was built with, so the
31 // binary it starts is built the same way; `go test -tags sqlite_fts5` does not
32 // pass its tags on to a `go build` the test runs.
33 func binaryBuildArgs() []string {
34 info, ok := debug.ReadBuildInfo()
35 if !ok {
36 return nil
37 }
38 for _, setting := range info.Settings {
39 if setting.Key == "-tags" && setting.Value != "" {
40 return []string{"-tags", setting.Value}
41 }
42 }
43 return nil
44 }
45
29 46 // TestMain builds the real binary: installed hooks exec it, so a stub would let
30 47 // every policy test pass for the wrong reason.
31 48 func TestMain(m *testing.M) {
@@ -35,7 +52,9 @@ func TestMain(m *testing.M) {
35 52 os.Exit(1)
36 53 }
37 54 binPath = filepath.Join(dir, "vole")
38 build := exec.Command("go", "build", "-o", binPath, "github.com/rodent-software/vole/cmd/vole")
55 args := append([]string{"build"}, binaryBuildArgs()...)
56 args = append(args, "-o", binPath, "github.com/rodent-software/vole/cmd/vole")
57 build := exec.Command("go", args...)
39 58 build.Stdout, build.Stderr = os.Stdout, os.Stderr
40 59 if err := build.Run(); err != nil {
41 60 fmt.Fprintln(os.Stderr, "build vole:", err)