Skip to content

Commit

Permalink
Remove blacklist from //test/runtimes
Browse files Browse the repository at this point in the history
Updates google#2972

PiperOrigin-RevId: 316534165
  • Loading branch information
prattmic authored and gvisor-bot committed Jun 15, 2020
1 parent eb6d3d7 commit 885605c
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 42 deletions.
10 changes: 5 additions & 5 deletions test/runtimes/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,30 @@ package(licenses = ["notice"])

runtime_test(
name = "go1.12",
blacklist_file = "blacklist_go1.12.csv",
exclude_file = "exclude_go1.12.csv",
lang = "go",
)

runtime_test(
name = "java11",
blacklist_file = "blacklist_java11.csv",
exclude_file = "exclude_java11.csv",
lang = "java",
)

runtime_test(
name = "nodejs12.4.0",
blacklist_file = "blacklist_nodejs12.4.0.csv",
exclude_file = "exclude_nodejs12.4.0.csv",
lang = "nodejs",
)

runtime_test(
name = "php7.3.6",
blacklist_file = "blacklist_php7.3.6.csv",
exclude_file = "exclude_php7.3.6.csv",
lang = "php",
)

runtime_test(
name = "python3.7.3",
blacklist_file = "blacklist_python3.7.3.csv",
exclude_file = "exclude_python3.7.3.csv",
lang = "python",
)
22 changes: 11 additions & 11 deletions test/runtimes/defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ def _runtime_test_impl(ctx):
"--image",
ctx.attr.image,
]
if ctx.attr.blacklist_file:
if ctx.attr.exclude_file:
args += [
"--blacklist_file",
ctx.files.blacklist_file[0].short_path,
"--exclude_file",
ctx.files.exclude_file[0].short_path,
]

# Build a runner.
Expand All @@ -28,7 +28,7 @@ def _runtime_test_impl(ctx):
return [DefaultInfo(
executable = runner,
runfiles = ctx.runfiles(
files = ctx.files._runner + ctx.files.blacklist_file + ctx.files._proctor,
files = ctx.files._runner + ctx.files.exclude_file + ctx.files._proctor,
collect_default = True,
collect_data = True,
),
Expand All @@ -43,7 +43,7 @@ _runtime_test = rule(
"lang": attr.string(
mandatory = True,
),
"blacklist_file": attr.label(
"exclude_file": attr.label(
mandatory = False,
allow_single_file = True,
),
Expand All @@ -68,12 +68,12 @@ def runtime_test(name, **kwargs):
**kwargs
)

def blacklist_test(name, blacklist_file):
"""Test that a blacklist parses correctly."""
def exclude_test(name, exclude_file):
"""Test that a exclude file parses correctly."""
go_test(
name = name + "_blacklist_test",
name = name + "_exclude_test",
library = ":runner",
srcs = ["blacklist_test.go"],
args = ["--blacklist_file", "test/runtimes/" + blacklist_file],
data = [blacklist_file],
srcs = ["exclude_test.go"],
args = ["--exclude_file", "test/runtimes/" + exclude_file],
data = [exclude_file],
)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions test/runtimes/runner/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ go_binary(
)

go_test(
name = "blacklist_test",
name = "exclude_test",
size = "small",
srcs = ["blacklist_test.go"],
srcs = ["exclude_test.go"],
library = ":runner",
)
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ func TestMain(m *testing.M) {
os.Exit(m.Run())
}

// Test that the blacklist parses without error.
// Test that the exclude file parses without error.
func TestBlacklists(t *testing.T) {
bl, err := getBlacklist()
ex, err := getExcludes()
if err != nil {
t.Fatalf("error parsing blacklist: %v", err)
t.Fatalf("error parsing exclude file: %v", err)
}
if *blacklistFile != "" && len(bl) == 0 {
t.Errorf("got empty blacklist for file %q", *blacklistFile)
if *excludeFile != "" && len(ex) == 0 {
t.Errorf("got empty excludes for file %q", *excludeFile)
}
}
38 changes: 19 additions & 19 deletions test/runtimes/runner/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ import (
)

var (
lang = flag.String("lang", "", "language runtime to test")
image = flag.String("image", "", "docker image with runtime tests")
blacklistFile = flag.String("blacklist_file", "", "file containing blacklist of tests to exclude, in CSV format with fields: test name, bug id, comment")
lang = flag.String("lang", "", "language runtime to test")
image = flag.String("image", "", "docker image with runtime tests")
excludeFile = flag.String("exclude_file", "", "file containing list of tests to exclude, in CSV format with fields: test name, bug id, comment")
)

// Wait time for each test to run.
Expand All @@ -52,10 +52,10 @@ func main() {
// defered functions before exiting. It returns an exit code that should be
// passed to os.Exit.
func runTests() int {
// Get tests to blacklist.
blacklist, err := getBlacklist()
// Get tests to exclude..
excludes, err := getExcludes()
if err != nil {
fmt.Fprintf(os.Stderr, "Error getting blacklist: %s\n", err.Error())
fmt.Fprintf(os.Stderr, "Error getting exclude list: %s\n", err.Error())
return 1
}

Expand All @@ -66,7 +66,7 @@ func runTests() int {
// Get a slice of tests to run. This will also start a single Docker
// container that will be used to run each test. The final test will
// stop the Docker container.
tests, err := getTests(d, blacklist)
tests, err := getTests(d, excludes)
if err != nil {
fmt.Fprintf(os.Stderr, "%s\n", err.Error())
return 1
Expand All @@ -77,7 +77,7 @@ func runTests() int {
}

// getTests executes all tests as table tests.
func getTests(d *dockerutil.Docker, blacklist map[string]struct{}) ([]testing.InternalTest, error) {
func getTests(d *dockerutil.Docker, excludes map[string]struct{}) ([]testing.InternalTest, error) {
// Start the container.
d.CopyFiles("/proctor", "test/runtimes/proctor/proctor")
if err := d.Spawn(dockerutil.RunOpts{
Expand Down Expand Up @@ -108,9 +108,9 @@ func getTests(d *dockerutil.Docker, blacklist map[string]struct{}) ([]testing.In
itests = append(itests, testing.InternalTest{
Name: tc,
F: func(t *testing.T) {
// Is the test blacklisted?
if _, ok := blacklist[tc]; ok {
t.Skipf("SKIP: blacklisted test %q", tc)
// Is the test excluded?
if _, ok := excludes[tc]; ok {
t.Skipf("SKIP: excluded test %q", tc)
}

var (
Expand Down Expand Up @@ -143,14 +143,14 @@ func getTests(d *dockerutil.Docker, blacklist map[string]struct{}) ([]testing.In
return itests, nil
}

// getBlacklist reads the blacklist file and returns a set of test names to
// getBlacklist reads the exclude file and returns a set of test names to
// exclude.
func getBlacklist() (map[string]struct{}, error) {
blacklist := make(map[string]struct{})
if *blacklistFile == "" {
return blacklist, nil
func getExcludes() (map[string]struct{}, error) {
excludes := make(map[string]struct{})
if *excludeFile == "" {
return excludes, nil
}
f, err := os.Open(*blacklistFile)
f, err := os.Open(*excludeFile)
if err != nil {
return nil, err
}
Expand All @@ -171,9 +171,9 @@ func getBlacklist() (map[string]struct{}, error) {
if err != nil {
return nil, err
}
blacklist[record[0]] = struct{}{}
excludes[record[0]] = struct{}{}
}
return blacklist, nil
return excludes, nil
}

// testDeps implements testing.testDeps (an unexported interface), and is
Expand Down

0 comments on commit 885605c

Please sign in to comment.