Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move legacy reproducibility test to new setup #1585

Merged
merged 5 commits into from
Jul 16, 2018
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,19 @@ test_chdir_remote()
load("@io_bazel_rules_go//tests/integration/popular_repos:popular_repos.bzl", "popular_repos")

popular_repos()

# For manual testing against an LLVM toolchain.
# Use --crosstool_top=@llvm_toolchain//:toolchain
http_archive(
name = "com_grail_bazel_toolchain",
sha256 = "282c67435ebbb612c8a68f3b17f14713e66cbbb863cdd7e206acbd0a2c3f7842",
strip_prefix = "bazel-toolchain-a964325290a98766305ec2d8963b1749fe612533",
urls = ["https://github.com/grailbio/bazel-toolchain/archive/a964325290a98766305ec2d8963b1749fe612533.tar.gz"],
)

load("@com_grail_bazel_toolchain//toolchain:configure.bzl", "llvm_toolchain")

llvm_toolchain(
name = "llvm_toolchain",
llvm_version = "6.0.0",
)
2 changes: 1 addition & 1 deletion go/tools/builders/cgo.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ func fixupLineComments(filename, srcDir string, cFile bool) error {
for i, line := range lines {
if cFile {
if strings.HasPrefix(line, cFileLinePrefix) {
lines[i] = strings.Replace(line, srcDir, "", 1)
lines[i] = strings.Replace(line, srcDir+string(os.PathSeparator), "", 1)
}
} else {
if strings.HasPrefix(line, goFileTrim) {
Expand Down
2 changes: 1 addition & 1 deletion go/tools/builders/stdlib.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func run(args []string) error {
os.Setenv("PATH", strings.Join(absPaths, string(os.PathListSeparator)))

// Strip path prefix from source files in debug information.
os.Setenv("CGO_CFLAGS", os.Getenv("CGO_CFLAGS")+" -fdebug-prefix-map="+abs(".")+"=")
os.Setenv("CGO_CFLAGS", os.Getenv("CGO_CFLAGS")+" -fdebug-prefix-map="+abs(".")+string(os.PathSeparator)+"=")

// Build the commands needed to build the std library in the right mode
installArgs := goenv.goCmd("install", "-toolexec", abs(*filterBuildid))
Expand Down
23 changes: 0 additions & 23 deletions tests/legacy/reproducible_binary/BUILD.bazel

This file was deleted.

25 changes: 0 additions & 25 deletions tests/legacy/reproducible_binary/hello.go

This file was deleted.

11 changes: 10 additions & 1 deletion tests/reproducibility/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
load("@io_bazel_rules_go//go:def.bzl", "go_test")
load("@io_bazel_rules_go//tests:bazel_tests.bzl", "bazel_test", "md5_sum")

go_test(
name = "go_default_test",
srcs = ["reproducible_binary_test.go"],
args = ["$(location //tests/reproducibility/cgo)"],
data = ["//tests/reproducibility/cgo"],
rundir = ".", # run in repo root instead of test dir
)

# A test script that, when run, builds the given targets in a clean build state
# with sandboxed strategy, and outputs their md5 digests from the build with
# ___MD5___ prefix to each line.
Expand Down Expand Up @@ -35,6 +44,7 @@ print_digests
"@io_bazel_rules_go//tests/reproducibility/cgo",
],
tags = ["manual"],
args = ["--compilation_mode=dbg"],
)

# A test that runs the above test script twice and diffs the output.
Expand All @@ -48,6 +58,5 @@ sh_test(
"bazel",
"exclusive",
"local",
"manual",
],
)
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,16 @@ func TestStandardPath(t *testing.T) {
}
}

// TestSandbox checks that the bazel-sandbox path does not appear in strings
// from the binary.
func TestSandboxPath(t *testing.T) {
for _, s := range allStrings {
if bytes.Contains(s, []byte("bazel-sandbox")) {
t.Errorf("binary contains bazel sandbox path: %s", s)
}
}
}

// TestUserNameAndHome checks the user name and home directory do not
// appear in strings from the binary.
func TestUserNameAndHome(t *testing.T) {
Expand Down