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/integration_test.go +21−1

@@ -16,6 +16,7 @@ import (
16 16 "os"
17 17 "os/exec"
18 18 "path/filepath"
19 "runtime/debug"
19 20 "strings"
20 21 "sync"
21 22 "syscall"
@@ -133,6 +134,23 @@ case "$cmd" in
133 134 esac
134 135 `
135 136
137 // binaryBuildArgs returns the tags this test binary was built with, so the
138 // binary it starts is built the same way. `go test -tags sqlite_fts5` passes its
139 // tags to the test binary but not to a `go build` it runs; without this the
140 // child has no FTS5 and a test that rebuilds the index fails.
141 func binaryBuildArgs() []string {
142 info, ok := debug.ReadBuildInfo()
143 if !ok {
144 return nil
145 }
146 for _, setting := range info.Settings {
147 if setting.Key == "-tags" && setting.Value != "" {
148 return []string{"-tags", setting.Value}
149 }
150 }
151 return nil
152 }
153
136 154 // Every test here calls t.Parallel(). These are integration tests: each one starts a
137 155 // server, pushes over SSH and runs `git` subprocesses, so it spends almost all of its
138 156 // time waiting on child processes and almost none of it on CPU. Serially that is ~150
@@ -154,7 +172,9 @@ func TestMain(m *testing.M) {
154 172 os.Exit(1)
155 173 }
156 174 binPath = filepath.Join(dir, "vole")
157 build := exec.Command("go", "build", "-o", binPath, "github.com/rodent-software/vole/cmd/vole")
175 args := append([]string{"build"}, binaryBuildArgs()...)
176 args = append(args, "-o", binPath, "github.com/rodent-software/vole/cmd/vole")
177 build := exec.Command("go", args...)
158 178 build.Stdout, build.Stderr = os.Stdout, os.Stderr
159 179 if err := build.Run(); err != nil {
160 180 fmt.Fprintln(os.Stderr, "build vole:", err)