projects/aports·blob master · refs

52 lines · 1.1 KiB

1Run integration tests against the dstask binary produced in the build step.
2
3--- a/integration/main_test.go
4+++ b/integration/main_test.go
5@@ -6,46 +6,14 @@ import (
6 "log"
7 "os"
8 "os/exec"
9- "runtime"
10 "testing"
11
12 "github.com/naggie/dstask"
13 "gotest.tools/assert"
14 )
15
16-func TestMain(m *testing.M) {
17- binary := binaryPath()
18-
19- if err := compile(binary); err != nil {
20- log.Fatalf("compile error: %v", err)
21- }
22-
23- cleanup := func() {
24- if err := os.Remove(binary); err != nil {
25- log.Panicf("could not remove integration test binary %s", binary)
26- }
27- }
28-
29- exitCode := m.Run()
30-
31- cleanup()
32- os.Exit(exitCode)
33-}
34-
35-func compile(outputPath string) error {
36- // We expect to execute in the ./integration directory, and we will output
37- // our test binary there.
38- cmd := exec.Command("go", "build", "-mod=vendor", "-o", outputPath, "../cmd/dstask/main.go")
39-
40- return cmd.Run()
41-}
42-
43 func binaryPath() string {
44- if runtime.GOOS == "windows" {
45- return "./dstask.exe"
46- }
47-
48- return "./dstask"
49+ return "../bin/dstask"
50 }
51
52 // Create a callable closure that will run our test binary against a