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

Side by Side Diff: vpython/venv/venv_test.go

Issue 2963503003: [errors] Greatly simplify common/errors package. (Closed)
Patch Set: fix nits Created 3 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 | « vpython/venv/venv_resources_test.go ('k') | vpython/wheel/wheel.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The LUCI Authors. All rights reserved. 1 // Copyright 2017 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 venv 5 package venv
6 6
7 import ( 7 import (
8 "encoding/json" 8 "encoding/json"
9 "flag" 9 "flag"
10 "fmt" 10 "fmt"
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 260
261 t.Run(fmt.Sprintf(`Testing Virtualenv for: %s`, tc.name), func(t *testing.T) { 261 t.Run(fmt.Sprintf(`Testing Virtualenv for: %s`, tc.name), func(t *testing.T) {
262 testVirtualEnvWith(t, tc.ri) 262 testVirtualEnvWith(t, tc.ri)
263 }) 263 })
264 } 264 }
265 } 265 }
266 266
267 func loadJSON(path string, dst interface{}) error { 267 func loadJSON(path string, dst interface{}) error {
268 content, err := ioutil.ReadFile(path) 268 content, err := ioutil.ReadFile(path)
269 if err != nil { 269 if err != nil {
270 » » return errors.Annotate(err).Reason("failed to open file").Err() 270 » » return errors.Annotate(err, "failed to open file").Err()
271 } 271 }
272 if err := json.Unmarshal(content, dst); err != nil { 272 if err := json.Unmarshal(content, dst); err != nil {
273 » » return errors.Annotate(err).Reason("failed to unmarshal JSON").E rr() 273 » » return errors.Annotate(err, "failed to unmarshal JSON").Err()
274 } 274 }
275 return nil 275 return nil
276 } 276 }
277 277
278 func shouldNotExist(actual interface{}, expected ...interface{}) string { 278 func shouldNotExist(actual interface{}, expected ...interface{}) string {
279 path := actual.(string) 279 path := actual.(string)
280 switch _, err := os.Stat(path); { 280 switch _, err := os.Stat(path); {
281 case err == nil: 281 case err == nil:
282 return fmt.Sprintf("Path %q should not exist, but it does.", pat h) 282 return fmt.Sprintf("Path %q should not exist, but it does.", pat h)
283 case os.IsNotExist(err): 283 case os.IsNotExist(err):
284 return "" 284 return ""
285 default: 285 default:
286 return fmt.Sprintf("Couldn't check if %q exists: %s", path, err) 286 return fmt.Sprintf("Couldn't check if %q exists: %s", path, err)
287 } 287 }
288 } 288 }
OLDNEW
« no previous file with comments | « vpython/venv/venv_resources_test.go ('k') | vpython/wheel/wheel.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698