Skip to content

Commit ade3067

Browse files
committed
testsuite: move Go code to top-level folder
As described in https://golang.org/cmd/cgo/ , Cgo only notices changes to .c and .h files in the same folder. Move the testsuite to the top-level folder to get rid of the manual cache cleaning which made running the tests so much slower. golang/go#24355
1 parent 60776a3 commit ade3067

5 files changed

+13
-15
lines changed

Makefile

+1-4
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,4 @@ format: earlyoom
8181
clang-format -i *.h *.c
8282

8383
test: earlyoom
84-
# Go does not notice when the C code changes, so we have to
85-
# use `go clean` and `go test -a`.
86-
# See https://github.com/golang/go/issues/24355 .
87-
cd tests && go clean -cache -testcache . && go test -a -v
84+
go test -v

tests/c_wrappers.go renamed to testsuite_c_wrappers.go

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1-
package tests
1+
package earlyoom_testsuite
22

33
import (
44
"fmt"
55
"os"
66
)
77

8-
// #cgo CFLAGS: -std=gnu99
9-
// #include "../globals.c"
10-
// #include "../sanitize.c"
11-
// #include "../msg.c"
12-
// #include "../meminfo.c"
8+
// #cgo CFLAGS: -std=gnu99 -DCGO
9+
// #include "meminfo.h"
10+
// #include "kill.h"
11+
// #include "msg.h"
1312
import "C"
1413

1514
func sanitize(s string) string {

tests/cli_test.go renamed to testsuite_cli_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package tests
1+
package earlyoom_testsuite
22

33
import (
44
"fmt"
@@ -154,7 +154,7 @@ func TestCli(t *testing.T) {
154154
}
155155

156156
func TestRss(t *testing.T) {
157-
cmd := exec.Command("../earlyoom")
157+
cmd := exec.Command(earlyoomBinary)
158158
err := cmd.Start()
159159
if err != nil {
160160
t.Fatal(err)

tests/helpers.go renamed to testsuite_helpers.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package tests
1+
package earlyoom_testsuite
22

33
import (
44
"bytes"
@@ -16,10 +16,12 @@ type exitVals struct {
1616
stderr string
1717
}
1818

19+
const earlyoomBinary = "./earlyoom"
20+
1921
// runEarlyoom runs earlyoom with a timeout
2022
func runEarlyoom(t *testing.T, args ...string) exitVals {
2123
var stdoutBuf, stderrBuf bytes.Buffer
22-
cmd := exec.Command("../earlyoom", args...)
24+
cmd := exec.Command(earlyoomBinary, args...)
2325
cmd.Stdout = &stdoutBuf
2426
cmd.Stderr = &stderrBuf
2527

tests/unit_test.go renamed to testsuite_unit_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package tests
1+
package earlyoom_testsuite
22

33
import (
44
"os"

0 commit comments

Comments
 (0)