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

Side by Side Diff: client/logdog/annotee/annotation/annotation_test.go

Issue 2069283002: milo: fix step duration (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-go@master
Patch Set: simplify step duration computation Created 4 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package annotation 5 package annotation
6 6
7 import ( 7 import (
8 "bufio" 8 "bufio"
9 "flag" 9 "flag"
10 "fmt" 10 "fmt"
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 if !touched.Has(path) { 112 if !touched.Has(path) {
113 merr = append(merr, fmt.Errorf("superfluous test data [% s]", path)) 113 merr = append(merr, fmt.Errorf("superfluous test data [% s]", path))
114 } 114 }
115 } 115 }
116 if merr != nil { 116 if merr != nil {
117 return merr 117 return merr
118 } 118 }
119 return nil 119 return nil
120 } 120 }
121 121
122 // playAnnotationScript loads an annotation script from "path" and plays it 122 // playAnnotationScript loads named annotation script and plays it
123 // through the supplied State line-by-line. 123 // through the supplied State line-by-line. Returns path to the annotation
124 // script.
124 // 125 //
125 // Empty lines and lines beginning with "#" are ignored. Preceding whitespace 126 // Empty lines and lines beginning with "#" are ignored. Preceding whitespace
126 // is discarded. 127 // is discarded.
127 func playAnnotationScript(t *testing.T, name string, st *State) (string, error) { 128 func playAnnotationScript(t *testing.T, name string, st *State) (string, error) {
128 tc := st.Clock.(testclock.TestClock) 129 tc := st.Clock.(testclock.TestClock)
129 130
130 path := filepath.Join(testDataDir, fmt.Sprintf("%s.annotations.txt", nor malize(name))) 131 path := filepath.Join(testDataDir, fmt.Sprintf("%s.annotations.txt", nor malize(name)))
131 f, err := os.Open(path) 132 f, err := os.Open(path)
132 if err != nil { 133 if err != nil {
133 t.Errorf("Failed to open annotations source [%s]: %v", path, err ) 134 t.Errorf("Failed to open annotations source [%s]: %v", path, err )
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 testCases := []testCase{ 285 testCases := []testCase{
285 {"default", &Execution{ 286 {"default", &Execution{
286 Name: "testcommand", 287 Name: "testcommand",
287 Command: []string{"testcommand", "foo", "bar"}, 288 Command: []string{"testcommand", "foo", "bar"},
288 Dir: "/path/to/dir", 289 Dir: "/path/to/dir",
289 Env: map[string]string{ 290 Env: map[string]string{
290 "FOO": "BAR", 291 "FOO": "BAR",
291 "BAZ": "QUX", 292 "BAZ": "QUX",
292 }, 293 },
293 }}, 294 }},
295 {"timestamps", nil},
294 {"coverage", nil}, 296 {"coverage", nil},
295 } 297 }
296 298
297 if *generate { 299 if *generate {
298 touched := stringset.New(0) 300 touched := stringset.New(0)
299 for _, tc := range testCases { 301 for _, tc := range testCases {
300 if err := tc.generate(t, startTime, touched); err != nil { 302 if err := tc.generate(t, startTime, touched); err != nil {
301 t.Fatalf("Failed to generate %q: %v\n", tc.name, err) 303 t.Fatalf("Failed to generate %q: %v\n", tc.name, err)
302 } 304 }
303 } 305 }
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 353
352 Convey(`Append to a closed State is a no-op.`, func() { 354 Convey(`Append to a closed State is a no-op.`, func() {
353 st := testCases[0].state(startTime) 355 st := testCases[0].state(startTime)
354 st.Finish() 356 st.Finish()
355 sclone := st 357 sclone := st
356 So(st.Append("asdf"), ShouldBeNil) 358 So(st.Append("asdf"), ShouldBeNil)
357 So(st, ShouldResemble, sclone) 359 So(st, ShouldResemble, sclone)
358 }) 360 })
359 }) 361 })
360 } 362 }
OLDNEW
« no previous file with comments | « client/logdog/annotee/annotation/annotation.go ('k') | client/logdog/annotee/annotation/test_data/timestamps.annotations.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698