| OLD | NEW |
| 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 Loading... |
| 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 } |
| OLD | NEW |