Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1337)

Unified Diff: milo/appengine/job_source/buildbot/build.go

Issue 2944983003: [milo] {buildbucket,buildbot,swarming,logdog} -> backends/*. (Closed)
Patch Set: fix the tests Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « milo/appengine/frontend/main_test.go ('k') | milo/appengine/job_source/buildbot/build_test.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: milo/appengine/job_source/buildbot/build.go
diff --git a/milo/appengine/buildbot/build.go b/milo/appengine/job_source/buildbot/build.go
similarity index 97%
rename from milo/appengine/buildbot/build.go
rename to milo/appengine/job_source/buildbot/build.go
index 1d88681de1e3d1e6f65cb10094e320d21c25313f..52bc2e64b8ade8d3db254a86b398b9f284461a20 100644
--- a/milo/appengine/buildbot/build.go
+++ b/milo/appengine/job_source/buildbot/build.go
@@ -447,44 +447,45 @@ func sourcestamp(c context.Context, b *buildbotBuild) *resp.SourceStamp {
return ss
}
-func getDebugBuild(c context.Context, builder string, buildNum int) (*buildbotBuild, error) {
+func renderBuild(c context.Context, b *buildbotBuild) *resp.MiloBuild {
+ // Modify the build for rendering.
+ updatePostProcessBuild(b)
+
+ // TODO(hinoka): Do all fields concurrently.
+ return &resp.MiloBuild{
+ SourceStamp: sourcestamp(c, b),
+ Summary: summary(c, b),
+ Components: components(b),
+ PropertyGroup: properties(b),
+ Blame: blame(b),
+ }
+}
+
+// DebugBuild fetches a debugging build for testing.
+func DebugBuild(c context.Context, relBuildbotDir string, builder string, buildNum int) (*resp.MiloBuild, error) {
fname := fmt.Sprintf("%s.%d.json", builder, buildNum)
// ../buildbot below assumes that
// - this code is not executed by tests outside of this dir
// - this dir is a sibling of frontend dir
- path := filepath.Join("..", "buildbot", "testdata", fname)
+ path := filepath.Join(relBuildbotDir, "testdata", fname)
raw, err := ioutil.ReadFile(path)
if err != nil {
return nil, err
}
b := &buildbotBuild{}
- return b, json.Unmarshal(raw, b)
+ if err := json.Unmarshal(raw, b); err != nil {
+ return nil, err
+ }
+ return renderBuild(c, b), nil
}
-// build fetches a buildbot build and translates it into a miloBuild.
+// Build fetches a buildbot build and translates it into a miloBuild.
func Build(c context.Context, master, builder string, buildNum int) (*resp.MiloBuild, error) {
- var b *buildbotBuild
- var err error
- if master == "debug" {
- b, err = getDebugBuild(c, builder, buildNum)
- } else {
- b, err = getBuild(c, master, builder, buildNum)
- }
+ b, err := getBuild(c, master, builder, buildNum)
if err != nil {
return nil, err
}
-
- // Modify the build for rendering.
- updatePostProcessBuild(b)
-
- // TODO(hinoka): Do all fields concurrently.
- return &resp.MiloBuild{
- SourceStamp: sourcestamp(c, b),
- Summary: summary(c, b),
- Components: components(b),
- PropertyGroup: properties(b),
- Blame: blame(b),
- }, nil
+ return renderBuild(c, b), nil
}
// updatePostProcessBuild transforms a build from its raw JSON format into the
« no previous file with comments | « milo/appengine/frontend/main_test.go ('k') | milo/appengine/job_source/buildbot/build_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698