Merge pull request #303 from colincross/blueprint_tests

Revert changes that broke the build or tests
This commit is contained in:
colincross 2020-06-11 16:34:45 -07:00 committed by GitHub
commit 743261c07e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 34 deletions

View file

@ -333,11 +333,13 @@ func (g *goPackage) GenerateBuildActions(ctx blueprint.ModuleContext) {
testSrcs = append(g.properties.TestSrcs, g.properties.Linux.TestSrcs...) testSrcs = append(g.properties.TestSrcs, g.properties.Linux.TestSrcs...)
} }
testArchiveFile := filepath.Join(testRoot(ctx, g.config), if g.config.runGoTests {
filepath.FromSlash(g.properties.PkgPath)+".a") testArchiveFile := filepath.Join(testRoot(ctx, g.config),
g.testResultFile = buildGoTest(ctx, testRoot(ctx, g.config), testArchiveFile, filepath.FromSlash(g.properties.PkgPath)+".a")
g.properties.PkgPath, srcs, genSrcs, g.testResultFile = buildGoTest(ctx, testRoot(ctx, g.config), testArchiveFile,
testSrcs) g.properties.PkgPath, srcs, genSrcs,
testSrcs)
}
buildGoPackage(ctx, g.pkgRoot, g.properties.PkgPath, g.archiveFile, buildGoPackage(ctx, g.pkgRoot, g.properties.PkgPath, g.archiveFile,
srcs, genSrcs) srcs, genSrcs)
@ -434,10 +436,9 @@ func (g *goBinary) GenerateBuildActions(ctx blueprint.ModuleContext) {
testSrcs = append(g.properties.TestSrcs, g.properties.Linux.TestSrcs...) testSrcs = append(g.properties.TestSrcs, g.properties.Linux.TestSrcs...)
} }
testDeps := buildGoTest(ctx, testRoot(ctx, g.config), testArchiveFile,
name, srcs, genSrcs, testSrcs)
if g.config.runGoTests { if g.config.runGoTests {
deps = append(deps, testDeps...) deps = buildGoTest(ctx, testRoot(ctx, g.config), testArchiveFile,
name, srcs, genSrcs, testSrcs)
} }
buildGoPackage(ctx, objDir, "main", archiveFile, srcs, genSrcs) buildGoPackage(ctx, objDir, "main", archiveFile, srcs, genSrcs)
@ -450,9 +451,7 @@ func (g *goBinary) GenerateBuildActions(ctx blueprint.ModuleContext) {
linkDeps = append(linkDeps, dep.GoPackageTarget()) linkDeps = append(linkDeps, dep.GoPackageTarget())
libDir := dep.GoPkgRoot() libDir := dep.GoPkgRoot()
libDirFlags = append(libDirFlags, "-L "+libDir) libDirFlags = append(libDirFlags, "-L "+libDir)
if g.config.runGoTests { deps = append(deps, dep.GoTestTargets()...)
deps = append(deps, dep.GoTestTargets()...)
}
}) })
linkArgs := map[string]string{} linkArgs := map[string]string{}
@ -636,22 +635,17 @@ func (s *singleton) GenerateBuildActions(ctx blueprint.SingletonContext) {
var primaryBuilders []*goBinary var primaryBuilders []*goBinary
// blueprintTools contains blueprint go binaries that will be built in StageMain // blueprintTools contains blueprint go binaries that will be built in StageMain
var blueprintTools []string var blueprintTools []string
// blueprintTests contains the result files from the tests ctx.VisitAllModulesIf(isBootstrapBinaryModule,
var blueprintTests []string func(module blueprint.Module) {
ctx.VisitAllModules(func(module blueprint.Module) { binaryModule := module.(*goBinary)
if binaryModule, ok := module.(*goBinary); ok {
if binaryModule.properties.Tool_dir { if binaryModule.properties.Tool_dir {
blueprintTools = append(blueprintTools, binaryModule.InstallPath()) blueprintTools = append(blueprintTools, binaryModule.InstallPath())
} }
if binaryModule.properties.PrimaryBuilder { if binaryModule.properties.PrimaryBuilder {
primaryBuilders = append(primaryBuilders, binaryModule) primaryBuilders = append(primaryBuilders, binaryModule)
} }
} })
if packageModule, ok := module.(goPackageProducer); ok {
blueprintTests = append(blueprintTests, packageModule.GoTestTargets()...)
}
})
var extraSharedFlagArray []string var extraSharedFlagArray []string
if s.config.runGoTests { if s.config.runGoTests {
@ -765,14 +759,6 @@ func (s *singleton) GenerateBuildActions(ctx blueprint.SingletonContext) {
Outputs: []string{"blueprint_tools"}, Outputs: []string{"blueprint_tools"},
Inputs: blueprintTools, Inputs: blueprintTools,
}) })
// Add a phony target for running all of the tests
ctx.Build(pctx, blueprint.BuildParams{
Rule: blueprint.Phony,
Outputs: []string{"blueprint_tests"},
Inputs: blueprintTests,
})
} }
} }

View file

@ -41,10 +41,10 @@ var (
traceFile string traceFile string
runGoTests bool runGoTests bool
noGC bool noGC bool
moduleListFile string
emptyNinjaFile bool emptyNinjaFile bool
BuildDir string BuildDir string
ModuleListFile string
NinjaBuildDir string NinjaBuildDir string
SrcDir string SrcDir string
@ -105,9 +105,9 @@ func Main(ctx *blueprint.Context, config interface{}, extraNinjaFileDeps ...stri
} }
SrcDir = filepath.Dir(flag.Arg(0)) SrcDir = filepath.Dir(flag.Arg(0))
if ModuleListFile != "" { if moduleListFile != "" {
ctx.SetModuleListFile(ModuleListFile) ctx.SetModuleListFile(moduleListFile)
extraNinjaFileDeps = append(extraNinjaFileDeps, ModuleListFile) extraNinjaFileDeps = append(extraNinjaFileDeps, moduleListFile)
} else { } else {
fatalf("-l <moduleListFile> is required and must be nonempty") fatalf("-l <moduleListFile> is required and must be nonempty")
} }
@ -133,7 +133,7 @@ func Main(ctx *blueprint.Context, config interface{}, extraNinjaFileDeps ...stri
topLevelBlueprintsFile: flag.Arg(0), topLevelBlueprintsFile: flag.Arg(0),
emptyNinjaFile: emptyNinjaFile, emptyNinjaFile: emptyNinjaFile,
runGoTests: runGoTests, runGoTests: runGoTests,
moduleListFile: ModuleListFile, moduleListFile: moduleListFile,
} }
ctx.RegisterBottomUpMutator("bootstrap_plugin_deps", pluginDeps) ctx.RegisterBottomUpMutator("bootstrap_plugin_deps", pluginDeps)