mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-16 10:43:29 +00:00
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).
This commit is contained in:
committed by
Ron Evans
parent
ca03b8d442
commit
e41e5106cc
@@ -6,6 +6,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
@@ -25,6 +26,8 @@ import (
|
|||||||
|
|
||||||
const TESTDATA = "testdata"
|
const TESTDATA = "testdata"
|
||||||
|
|
||||||
|
var testTarget = flag.String("target", "", "override test target")
|
||||||
|
|
||||||
func TestCompiler(t *testing.T) {
|
func TestCompiler(t *testing.T) {
|
||||||
matches, err := filepath.Glob(filepath.Join(TESTDATA, "*.go"))
|
matches, err := filepath.Glob(filepath.Join(TESTDATA, "*.go"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -44,6 +47,14 @@ func TestCompiler(t *testing.T) {
|
|||||||
|
|
||||||
sort.Strings(matches)
|
sort.Strings(matches)
|
||||||
|
|
||||||
|
if *testTarget != "" {
|
||||||
|
// This makes it possible to run one specific test (instead of all),
|
||||||
|
// which is especially useful to quickly check whether some changes
|
||||||
|
// affect a particular target architecture.
|
||||||
|
runPlatTests(*testTarget, matches, t)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if runtime.GOOS != "windows" {
|
if runtime.GOOS != "windows" {
|
||||||
t.Run("Host", func(t *testing.T) {
|
t.Run("Host", func(t *testing.T) {
|
||||||
runPlatTests("", matches, t)
|
runPlatTests("", matches, t)
|
||||||
|
|||||||
Reference in New Issue
Block a user