Skip to content

Commit e41e510

Browse files
aykevldeadprogram
authored andcommitted
main: add -target flag to tests
This makes it easy to test one particular architecture, for example: go test -v -target=hifive1-qemu This speeds up testing and allows testing targets that are not included in the test by default (such as RISC-V tests on Linux).
1 parent ca03b8d commit e41e510

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

main_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package main
66
import (
77
"bufio"
88
"bytes"
9+
"flag"
910
"fmt"
1011
"io/ioutil"
1112
"os"
@@ -25,6 +26,8 @@ import (
2526

2627
const TESTDATA = "testdata"
2728

29+
var testTarget = flag.String("target", "", "override test target")
30+
2831
func TestCompiler(t *testing.T) {
2932
matches, err := filepath.Glob(filepath.Join(TESTDATA, "*.go"))
3033
if err != nil {
@@ -44,6 +47,14 @@ func TestCompiler(t *testing.T) {
4447

4548
sort.Strings(matches)
4649

50+
if *testTarget != "" {
51+
// This makes it possible to run one specific test (instead of all),
52+
// which is especially useful to quickly check whether some changes
53+
// affect a particular target architecture.
54+
runPlatTests(*testTarget, matches, t)
55+
return
56+
}
57+
4758
if runtime.GOOS != "windows" {
4859
t.Run("Host", func(t *testing.T) {
4960
runPlatTests("", matches, t)

0 commit comments

Comments
 (0)