Skip to content

Commit

Permalink
Add test filter
Browse files Browse the repository at this point in the history
  • Loading branch information
fmeum committed Aug 29, 2024
1 parent 55cdc1f commit 2201c42
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
8 changes: 6 additions & 2 deletions go/private/actions/compilepkg.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -211,12 +211,13 @@ def emit_compilepkg(
_run_nogo(
go,
sources = sources,
cgo_go_srcs = cgo_go_srcs_for_nogo,
importpath = importpath,
importmap = importmap,
archives = archives,
recompile_internal_deps = recompile_internal_deps,
cover_mode = cover_mode,
cgo_go_srcs = cgo_go_srcs_for_nogo,
testfilter = testfilter,
out_facts = out_facts,
out_log = out_nogo_log,
out_validation = out_nogo_validation,
Expand All @@ -227,12 +228,13 @@ def _run_nogo(
go,
*,
sources,
cgo_go_srcs,
importpath,
importmap,
archives,
recompile_internal_deps,
cover_mode,
cgo_go_srcs,
testfilter,
out_facts,
out_log,
out_validation,
Expand Down Expand Up @@ -263,6 +265,8 @@ def _run_nogo(
if importmap:
args.add("-p", importmap)
args.add("-package_list", sdk.package_list)
if testfilter:
args.add("-testfilter", testfilter)

args.add_all(archives, before_each = "-facts", map_each = _facts)
args.add("-out_facts", out_facts)
Expand Down
2 changes: 1 addition & 1 deletion go/tools/builders/compilepkg.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func compilePkg(args []string) error {
return err
}

err = applyTestFilter(testFilter, srcs)
err = applyTestFilter(testFilter, &srcs)
if err != nil {
return err
}
Expand Down
6 changes: 3 additions & 3 deletions go/tools/builders/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ func filterAndSplitFiles(fileNames []string) (archiveSrcs, error) {
return res, nil
}

// applyTestFilter filters out test files from the list of sources according to
// the filter.
func applyTestFilter(testFilter string, srcs archiveSrcs) error {
// applyTestFilter filters out test files from the list of sources in place
// according to the filter.
func applyTestFilter(testFilter string, srcs *archiveSrcs) error {
// TODO(jayconrod): remove -testfilter flag. The test action should compile
// the main, internal, and external packages by calling compileArchive
// with the correct sources for each.
Expand Down
7 changes: 7 additions & 0 deletions go/tools/builders/nogo.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ func nogo(args []string) error {
var unfilteredSrcs, recompileInternalDeps multiFlag
var deps, facts archiveMultiFlag
var importPath, packagePath, nogoPath, packageListPath string
var testFilter string
var outFactsPath, outLogPath string
var coverMode string
fs.Var(&unfilteredSrcs, "src", ".go, .c, .cc, .m, .mm, .s, or .S file to be filtered and compiled")
Expand All @@ -33,6 +34,7 @@ func nogo(args []string) error {
fs.StringVar(&packageListPath, "package_list", "", "The file containing the list of standard library packages")
fs.Var(&recompileInternalDeps, "recompile_internal_deps", "The import path of the direct dependencies that needs to be recompiled.")
fs.StringVar(&coverMode, "cover_mode", "", "The coverage mode to use. Empty if coverage instrumentation should not be added.")
fs.StringVar(&testFilter, "testfilter", "off", "Controls test package filtering")
fs.StringVar(&nogoPath, "nogo", "", "The nogo binary")
fs.StringVar(&outFactsPath, "out_facts", "", "The file to emit serialized nogo facts to")
fs.StringVar(&outLogPath, "out_log", "", "The file to emit nogo logs into")
Expand All @@ -52,6 +54,11 @@ func nogo(args []string) error {
return err
}

err = applyTestFilter(testFilter, &srcs)
if err != nil {
return err
}

var goSrcs []string
haveCgo := false
for _, src := range srcs.goSrcs {
Expand Down

0 comments on commit 2201c42

Please sign in to comment.