-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: run on more platforms, avoid shell scripts
- run all tests on all platforms. - enable more CI checks on more platforms. Turns out I just missed quite a few. - replace `test.sh` with `test.go`, which will be useful in #165.
- Loading branch information
Showing
12 changed files
with
181 additions
and
171 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,24 @@ | ||
try-import %workspace%/.bazelrc.ci | ||
|
||
test --sandbox_default_allow_network=false | ||
test --test_output=errors | ||
common --enable_platform_specific_config | ||
|
||
build --incompatible_disallow_empty_glob | ||
build --verbose_failures | ||
build --worker_sandboxing | ||
|
||
# TODO: turn this back on when Zig can build CGo (https://github.com/uber/hermetic_cc_toolchain/issues/10) | ||
#build --action_env BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1 | ||
build --sandbox_add_mount_pair=/tmp | ||
build --sandbox_add_mount_pair=/var/tmp | ||
|
||
build --experimental_output_directory_naming_scheme=diff_against_dynamic_baseline | ||
build:darwin_toolchains --extra_toolchains @zig_sdk//toolchain:darwin_amd64,@zig_sdk//toolchain:darwin_arm64 | ||
|
||
build:linux --sandbox_add_mount_pair=/tmp | ||
build:macos --sandbox_add_mount_pair=/var/tmp | ||
build:windows --sandbox_add_mount_pair=C:\Temp | ||
|
||
build:macos_toolchains --extra_toolchains @zig_sdk//toolchain:darwin_amd64,@zig_sdk//toolchain:darwin_arm64 | ||
build:macos_toolchains --action_env BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1 | ||
build:macos_toolchains --build_tag_filters= | ||
|
||
build:linux --config=macos_toolchains | ||
build:windows --config=macos_toolchains | ||
build:macos --build_tag_filters=-darwin_c | ||
|
||
test --sandbox_default_allow_network=false | ||
test --test_output=errors |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,17 @@ | ||
# Copyright 2023 Uber Technologies, Inc. | ||
# Licensed under the MIT License | ||
test --sandbox_default_allow_network=false | ||
test --test_output=errors | ||
try-import %workspace%/../../.bazelrc.ci | ||
|
||
common --enable_platform_specific_config | ||
|
||
build --incompatible_disallow_empty_glob | ||
build --verbose_failures | ||
build --worker_sandboxing | ||
build --experimental_output_directory_naming_scheme=diff_against_dynamic_baseline | ||
|
||
build --action_env BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1 | ||
|
||
build --sandbox_add_mount_pair=/tmp | ||
build --sandbox_add_mount_pair=/var/tmp | ||
build:linux --sandbox_add_mount_pair=/tmp | ||
build:macos --sandbox_add_mount_pair=/var/tmp | ||
build:windows --sandbox_add_mount_pair=C:\Temp | ||
|
||
build --experimental_output_directory_naming_scheme=diff_against_dynamic_baseline | ||
test --sandbox_default_allow_network=false | ||
test --test_output=errors |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,17 @@ | ||
# Copyright 2023 Uber Technologies, Inc. | ||
# Licensed under the MIT License | ||
test --sandbox_default_allow_network=false | ||
test --test_output=errors | ||
try-import %workspace%/../../.bazelrc.ci | ||
|
||
common --enable_platform_specific_config | ||
|
||
build --incompatible_disallow_empty_glob | ||
build --verbose_failures | ||
build --worker_sandboxing | ||
|
||
build --experimental_output_directory_naming_scheme=diff_against_dynamic_baseline | ||
build --action_env BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1 | ||
build:linux --sandbox_add_mount_pair=/tmp | ||
build:macos --sandbox_add_mount_pair=/var/tmp | ||
build:windows --sandbox_add_mount_pair=C:\Temp | ||
|
||
build --sandbox_add_mount_pair=/tmp | ||
build --sandbox_add_mount_pair=/var/tmp | ||
build --experimental_output_directory_naming_scheme=diff_against_dynamic_baseline | ||
test --sandbox_default_allow_network=false | ||
test --test_output=errors |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,101 @@ | ||
load("@hermetic_cc_toolchain//rules:platform.bzl", "platform_binary") | ||
load("@rules_go//go:def.bzl", "go_library", "go_test") | ||
|
||
cc_binary( | ||
name = "which_libc", | ||
srcs = ["main.c"], | ||
) | ||
|
||
_LINUX_AMD64 = [ | ||
"@platforms//os:linux", | ||
"@platforms//cpu:x86_64", | ||
] | ||
|
||
_DARWIN_AMD64 = [ | ||
"@platforms//os:macos", | ||
"@platforms//cpu:x86_64", | ||
] | ||
|
||
_DARWIN_ARM64 = [ | ||
"@platforms//os:macos", | ||
"@platforms//cpu:aarch64", | ||
] | ||
|
||
_WINDOWS_AMD64 = [ | ||
"@platforms//os:windows", | ||
"@platforms//cpu:x86_64", | ||
] | ||
|
||
[ | ||
( | ||
platform_binary( | ||
name = "which_libc_{}".format(name), | ||
src = "which_libc", | ||
platform = platform, | ||
tags = tags, | ||
), | ||
sh_test( | ||
go_test( | ||
name = "test_libc_{}".format(name), | ||
srcs = ["test.sh"], | ||
data = ["which_libc_{}".format(name)], | ||
data = [":which_libc_{}".format(name)], | ||
embed = [":c_test"], | ||
env = { | ||
"WANT": want, | ||
"BINARY": "$(location which_libc_{})".format(name), | ||
"BINARY": "$(rlocationpath which_libc_{})".format(name), | ||
}, | ||
target_compatible_with = compatible_with, | ||
), | ||
) | ||
for name, platform, want in [ | ||
("linux_amd64_musl", "//libc_aware/platform:linux_amd64_musl", "linux non-glibc"), | ||
("linux_amd64_gnu.2.28", "//libc_aware/platform:linux_amd64_gnu.2.28", "linux glibc_2.28"), | ||
("linux_amd64", "//platform:linux_amd64", "linux glibc_2.28"), | ||
] | ||
] | ||
|
||
[ | ||
( | ||
platform_binary( | ||
name = "which_libc_{}".format(name), | ||
src = "which_libc", | ||
platform = platform, | ||
tags = tags, | ||
for name, platform, compatible_with, want, tags in [ | ||
( | ||
"linux_amd64_musl", | ||
"//libc_aware/platform:linux_amd64_musl", | ||
_LINUX_AMD64, | ||
"^linux non-glibc", | ||
[], | ||
), | ||
( | ||
"linux_amd64_gnu.2.28", | ||
"//libc_aware/platform:linux_amd64_gnu.2.28", | ||
_LINUX_AMD64, | ||
"^linux glibc_2.28", | ||
[], | ||
), | ||
( | ||
"linux_amd64", | ||
"//platform:linux_amd64", | ||
_LINUX_AMD64, | ||
"^linux glibc_2.28", | ||
[], | ||
), | ||
( | ||
"windows_amd64", | ||
"//platform:windows_amd64", | ||
_WINDOWS_AMD64, | ||
"^windows ", | ||
[], | ||
), | ||
) | ||
for name, platform, tags in [ | ||
( | ||
"darwin_amd64", | ||
"//platform:darwin_amd64", | ||
_DARWIN_AMD64, | ||
"^macos non-glibc", | ||
["darwin_c"], | ||
), | ||
( | ||
"darwin_arm64", | ||
"//platform:darwin_arm64", | ||
_DARWIN_ARM64, | ||
"^macos non-glibc", | ||
["darwin_c"], | ||
), | ||
("windows_amd64", "//platform:windows_amd64", []), | ||
("windows_arm64", "//platform:windows_arm64", []), | ||
] | ||
] | ||
|
||
go_library( | ||
name = "c_test", | ||
srcs = ["c_test.go"], | ||
deps = [ | ||
"@com_github_stretchr_testify//assert", | ||
"@rules_go//go/runfiles", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package c_test | ||
|
||
import ( | ||
"os" | ||
"os/exec" | ||
"testing" | ||
|
||
"github.com/bazelbuild/rules_go/go/runfiles" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestYadda(t *testing.T) { | ||
want := os.Getenv("WANT") | ||
|
||
binary, err := runfiles.Rlocation(os.Getenv("BINARY")) | ||
if err != nil { | ||
t.Fatalf("unable to locate guest binary: %v", err) | ||
} | ||
|
||
got, err := exec.Command(binary).CombinedOutput() | ||
if err != nil { | ||
t.Fatalf("run %q: %v", binary, err) | ||
} | ||
|
||
assert.Regexp(t, string(want), string(got)) | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.