Updates #14069 Change-Id: I134a90db561dacc4b1c1c66ccadac135b5d64cf3 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>main
parent
bb3d0cae5f
commit
d62baa45e6
@ -0,0 +1,17 @@ |
||||
// Copyright (c) Tailscale Inc & AUTHORS
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
//go:build tailscale_go && android
|
||||
|
||||
package version |
||||
|
||||
import "fmt" |
||||
|
||||
func init() { |
||||
// For official Android builds using the tailscale_go toolchain,
|
||||
// panic if the builder is screwed up we fail to stamp a valid
|
||||
// version string.
|
||||
if !isValidLongWithTwoRepos(Long()) { |
||||
panic(fmt.Sprintf("malformed version.Long value %q", Long())) |
||||
} |
||||
} |
||||
@ -0,0 +1,28 @@ |
||||
// Copyright (c) Tailscale Inc & AUTHORS
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
package version |
||||
|
||||
import "testing" |
||||
|
||||
func TestIsValidLongWithTwoRepos(t *testing.T) { |
||||
tests := []struct { |
||||
long string |
||||
want bool |
||||
}{ |
||||
{"1.2.3-t01234abcde-g01234abcde", true}, |
||||
{"1.2.259-t01234abcde-g01234abcde", true}, // big patch version
|
||||
{"1.2.3-t01234abcde", false}, // missing repo
|
||||
{"1.2.3-g01234abcde", false}, // missing repo
|
||||
{"1.2.3-g01234abcde", false}, // missing repo
|
||||
{"-t01234abcde-g01234abcde", false}, |
||||
{"1.2.3", false}, |
||||
{"1.2.3-t01234abcde-g", false}, |
||||
{"1.2.3-t01234abcde-gERRBUILDINFO", false}, |
||||
} |
||||
for _, tt := range tests { |
||||
if got := isValidLongWithTwoRepos(tt.long); got != tt.want { |
||||
t.Errorf("IsValidLongWithTwoRepos(%q) = %v; want %v", tt.long, got, tt.want) |
||||
} |
||||
} |
||||
} |
||||
Loading…
Reference in new issue