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 all 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 = "aafea89b6abe75205418c0d2127252948afe6c7f2287a79b67aab3e0c3676c4f",
strip_prefix = "bazel-toolchain-d0a5b0af3102c7c607f2cf098421fcdbaeaaaf19",
urls = ["https://github.com/grailbio/bazel-toolchain/archive/d0a5b0af3102c7c607f2cf098421fcdbaeaaaf19.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.

13 changes: 12 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,9 @@ print_digests
"@io_bazel_rules_go//tests/reproducibility/cgo",
],
tags = ["manual"],
# dbg builds are not reproducible with llvm 6.0 and below (default on macOS).
# https://bugs.llvm.org/show_bug.cgi?id=38050
#args = ["--compilation_mode=dbg"],
)

# A test that runs the above test script twice and diffs the output.
Expand All @@ -48,6 +60,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