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

Side by Side Diff: appengine/cmd/milo/swarming/build.go

Issue 2150933004: milo: dedup testdata (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-go@master
Patch Set: Created 4 years, 5 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 unified diff | Download patch
« no previous file with comments | « appengine/cmd/milo/frontend/testdata/buildbucket ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The LUCI Authors. All rights reserved. 1 // Copyright 2015 The LUCI Authors. All rights reserved.
2 // Use of this source code is governed under the Apache License, Version 2.0 2 // Use of this source code is governed under the Apache License, Version 2.0
3 // that can be found in the LICENSE file. 3 // that can be found in the LICENSE file.
4 4
5 package swarming 5 package swarming
6 6
7 import ( 7 import (
8 "bytes" 8 "bytes"
9 "encoding/json" 9 "encoding/json"
10 "fmt" 10 "fmt"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 sc, err := swarming.New(client) 53 sc, err := swarming.New(client)
54 if err != nil { 54 if err != nil {
55 return nil, err 55 return nil, err
56 } 56 }
57 sc.BasePath = fmt.Sprintf("https://%s/_ah/api/swarming/v1/", server) 57 sc.BasePath = fmt.Sprintf("https://%s/_ah/api/swarming/v1/", server)
58 return sc, nil 58 return sc, nil
59 } 59 }
60 60
61 func getDebugTaskOutput(taskID string) (string, error) { 61 func getDebugTaskOutput(taskID string) (string, error) {
62 // Read the debug file instead. 62 // Read the debug file instead.
63 » logFilename := filepath.Join("testdata", taskID) 63
64 » // ../swarming below assumes that
65 » // - this code is not executed by tests outside of this dir
66 » // - this dir is a sibling of frontend dir
67 » logFilename := filepath.Join("..", "swarming", "testdata", taskID)
64 b, err := ioutil.ReadFile(logFilename) 68 b, err := ioutil.ReadFile(logFilename)
65 if err != nil { 69 if err != nil {
66 return "", err 70 return "", err
67 } 71 }
68 return string(b), nil 72 return string(b), nil
69 } 73 }
70 74
71 func getTaskOutput(sc *swarming.Service, taskID string) (string, error) { 75 func getTaskOutput(sc *swarming.Service, taskID string) (string, error) {
72 res, err := sc.Task.Stdout(taskID).Do() 76 res, err := sc.Task.Stdout(taskID).Do()
73 if err != nil { 77 if err != nil {
74 return "", err 78 return "", err
75 } 79 }
76 return res.Output, nil 80 return res.Output, nil
77 } 81 }
78 82
79 func getDebugSwarmingResult( 83 func getDebugSwarmingResult(
80 taskID string) (*swarming.SwarmingRpcsTaskResult, error) { 84 taskID string) (*swarming.SwarmingRpcsTaskResult, error) {
81 85
82 » logFilename := filepath.Join("testdata", taskID) 86 » // ../swarming below assumes that
87 » // - this code is not executed by tests outside of this dir
88 » // - this dir is a sibling of frontend dir
89 » logFilename := filepath.Join("..", "swarming", "testdata", taskID)
83 swarmFilename := fmt.Sprintf("%s.swarm", logFilename) 90 swarmFilename := fmt.Sprintf("%s.swarm", logFilename)
84 s, err := ioutil.ReadFile(swarmFilename) 91 s, err := ioutil.ReadFile(swarmFilename)
85 if err != nil { 92 if err != nil {
86 return nil, err 93 return nil, err
87 } 94 }
88 sr := &swarming.SwarmingRpcsTaskResult{} 95 sr := &swarming.SwarmingRpcsTaskResult{}
89 if err := json.Unmarshal(s, sr); err != nil { 96 if err := json.Unmarshal(s, sr); err != nil {
90 return nil, err 97 return nil, err
91 } 98 }
92 return sr, nil 99 return sr, nil
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 // Supports server aliases. 346 // Supports server aliases.
340 func taskPageURL(swarmingHostname, taskID string) string { 347 func taskPageURL(swarmingHostname, taskID string) string {
341 return fmt.Sprintf("https://%s/user/task/%s", swarmingHostname, taskID) 348 return fmt.Sprintf("https://%s/user/task/%s", swarmingHostname, taskID)
342 } 349 }
343 350
344 // botPageURL returns a URL to a human-consumable page of a swarming bot. 351 // botPageURL returns a URL to a human-consumable page of a swarming bot.
345 // Supports server aliases. 352 // Supports server aliases.
346 func botPageURL(swarmingHostname, botID string) string { 353 func botPageURL(swarmingHostname, botID string) string {
347 return fmt.Sprintf("https://%s/restricted/bot/%s", swarmingHostname, bot ID) 354 return fmt.Sprintf("https://%s/restricted/bot/%s", swarmingHostname, bot ID)
348 } 355 }
OLDNEW
« no previous file with comments | « appengine/cmd/milo/frontend/testdata/buildbucket ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698