| OLD | NEW |
| 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 isolate | 5 package isolate |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "fmt" | |
| 9 "log" | 8 "log" |
| 10 "path" | 9 "path" |
| 11 "runtime" | 10 "runtime" |
| 12 "strings" | 11 "strings" |
| 13 | 12 |
| 14 "github.com/luci/luci-go/common/errors" | 13 "github.com/luci/luci-go/common/errors" |
| 15 ) | 14 ) |
| 16 | 15 |
| 17 // TODO(tandrii): Remove this hacky stuff. | 16 // TODO(tandrii): Remove this hacky stuff. |
| 18 // hacky stuff for faster debugging. | 17 // hacky stuff for faster debugging. |
| 19 func assertNoError(err error) { | 18 func assertNoError(err error) { |
| 20 if err == nil { | 19 if err == nil { |
| 21 return | 20 return |
| 22 } | 21 } |
| 23 » log.Panic(errors.RenderStack(fmt.Errorf("assertion failed due to error:
%s", err)).ToLines()) | 22 » log.Panic(errors.RenderStack(errors.Annotate(err, "assertion failed").Er
r())) |
| 24 } | 23 } |
| 25 | 24 |
| 26 func assert(condition bool, info ...interface{}) { | 25 func assert(condition bool, info ...interface{}) { |
| 27 if condition { | 26 if condition { |
| 28 return | 27 return |
| 29 } | 28 } |
| 30 if len(info) == 0 { | 29 if len(info) == 0 { |
| 31 » » log.Panic(errors.RenderStack(errors.New("assertion failed")).ToL
ines()) | 30 » » log.Panic(errors.RenderStack(errors.New("assertion failed"))) |
| 32 } else if format, ok := info[0].(string); ok { | 31 } else if format, ok := info[0].(string); ok { |
| 33 » » log.Panic(errors.RenderStack(fmt.Errorf("assertion failed: "+for
mat, info[1:]...)).ToLines()) | 32 » » log.Panic(errors.RenderStack(errors.Reason("assertion failed: "+
format, info[1:]...).Err())) |
| 34 } | 33 } |
| 35 } | 34 } |
| 36 | 35 |
| 37 // uniqueMergeSortedStrings merges two sorted sets of string (as slices) and rem
oves duplicates. | 36 // uniqueMergeSortedStrings merges two sorted sets of string (as slices) and rem
oves duplicates. |
| 38 func uniqueMergeSortedStrings(ls, rs []string) []string { | 37 func uniqueMergeSortedStrings(ls, rs []string) []string { |
| 39 varSet := make([]string, len(ls)+len(rs)) | 38 varSet := make([]string, len(ls)+len(rs)) |
| 40 for i := 0; ; i++ { | 39 for i := 0; ; i++ { |
| 41 if len(ls) == 0 { | 40 if len(ls) == 0 { |
| 42 rs, ls = ls, rs | 41 rs, ls = ls, rs |
| 43 } | 42 } |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 } | 131 } |
| 133 return string(buf), nil | 132 return string(buf), nil |
| 134 } | 133 } |
| 135 return targ[t0:], nil | 134 return targ[t0:], nil |
| 136 } | 135 } |
| 137 | 136 |
| 138 // IsWindows returns True when running on the best OS there is. | 137 // IsWindows returns True when running on the best OS there is. |
| 139 func IsWindows() bool { | 138 func IsWindows() bool { |
| 140 return runtime.GOOS == "windows" | 139 return runtime.GOOS == "windows" |
| 141 } | 140 } |
| OLD | NEW |