Skip to content

Commit

Permalink
Clean up test targets to avoid RBE failure
Browse files Browse the repository at this point in the history
  • Loading branch information
UebelAndre committed Jun 13, 2023
1 parent a8e99dc commit 5723f6e
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 33 deletions.
16 changes: 10 additions & 6 deletions .bazelci/presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ tasks:
- "-//test/conflicting_deps:conflicting_deps_test"
# TODO: This test does not work on RBE
- "-//test/versioned_dylib:versioned_dylib_test"
# TODO: rule_test does not work on RBE
- "-//test/rust:hello_lib_rule_test"
- "-//test/rust:hello_world_rule_test"
- "-//test/rustc_env_files:output_test"
post_shell_commands: *coverage_validation_post_shell_commands
macos:
build_targets: *default_macos_targets
Expand Down Expand Up @@ -118,8 +122,7 @@ tasks:
build_targets: *default_linux_targets
test_targets:
- "--" # Allows negative patterns; hack for https://github.com/bazelbuild/continuous-integration/pull/245
- "..."
- "//test/..."
- "//..."
- "-//test/conflicting_deps:conflicting_deps_test"
# TODO: This test does not work on RBE
- "-//test/versioned_dylib:versioned_dylib_test"
Expand All @@ -133,8 +136,7 @@ tasks:
build_targets: *default_linux_targets
test_targets:
- "--" # Allows negative patterns; hack for https://github.com/bazelbuild/continuous-integration/pull/245
- "..."
- "//test/..."
- "//..."
- "-//test/conflicting_deps:conflicting_deps_test"
# TODO: This test does not work on RBE
- "-//test/versioned_dylib:versioned_dylib_test"
Expand Down Expand Up @@ -319,11 +321,12 @@ tasks:
working_directory: examples
build_flags:
- "--repo_env=CC=clang"
- "--config=rustfmt"
- "--config=clippy"
build_targets:
- "//..."
test_targets:
- "//..."
build_flags: *aspects_flags
ubuntu2004_examples_clang_lld:
name: Examples with Clang and LLD
platform: ubuntu2004
Expand All @@ -333,11 +336,12 @@ tasks:
build_flags:
- "--repo_env=CC=clang"
- "--linkopt=-fuse-ld=lld"
- "--config=rustfmt"
- "--config=clippy"
build_targets:
- "//..."
test_targets:
- "//..."
build_flags: *aspects_flags
ubuntu2004_examples_rolling:
name: "Examples with Rolling Bazel Version"
platform: ubuntu2004
Expand Down
19 changes: 0 additions & 19 deletions test/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,19 +0,0 @@
load(
"@bazel_tools//tools/build_rules:test_rules.bzl",
"rule_test",
)

rule_test(
name = "hello_lib_rule_test",
generates = ["libhello_lib-683707109.rlib"],
rule = "//test/rust:hello_lib",
)

rule_test(
name = "hello_world_rule_test",
generates = select({
"//rust/platform:windows": ["hello_world.exe"],
"//conditions:default": ["hello_world"],
}),
rule = "//test/rust:hello_world",
)
16 changes: 16 additions & 0 deletions test/rust/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
load("@bazel_tools//tools/build_rules:test_rules.bzl", "rule_test")
load("//rust:defs.bzl", "rust_binary", "rust_library", "rust_test")

package(default_visibility = ["//visibility:public"])
Expand All @@ -24,3 +25,18 @@ rust_test(
name = "hello_lib_test",
crate = ":hello_lib",
)

rule_test(
name = "hello_lib_rule_test",
generates = ["libhello_lib-683707109.rlib"],
rule = ":hello_lib",
)

rule_test(
name = "hello_world_rule_test",
generates = select({
"//rust/platform:windows": ["hello_world.exe"],
"//conditions:default": ["hello_world"],
}),
rule = "//test/rust:hello_world",
)
6 changes: 4 additions & 2 deletions test/rustc_env_files/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@ write_file(
],
)

sh_test(
rust_test(
name = "output_test",
srcs = ["output_test.sh"],
srcs = ["output_test.rs"],
args = ["$(rootpath :hello_env)"],
data = [":hello_env"],
edition = "2018",
use_libtest_harness = False,
)

rust_library(
Expand Down
18 changes: 18 additions & 0 deletions test/rustc_env_files/output_test.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
use std::process;

fn main() {
let binary = std::env::args().nth(1).expect("No argument was provided");

let output = process::Command::new(binary)
.output()
.expect("Failed to spawn process");
if !output.status.success() {
eprintln!("Failed to execute binary");
eprintln!("{}", std::str::from_utf8(&output.stdout).unwrap());
eprintln!("{}", std::str::from_utf8(&output.stderr).unwrap());
process::exit(output.status.code().unwrap());
}

let stdout = std::str::from_utf8(&output.stdout).unwrap().trim();
assert_eq!("Howdy from version 1.2.3", stdout);
}
6 changes: 0 additions & 6 deletions test/rustc_env_files/output_test.sh

This file was deleted.

0 comments on commit 5723f6e

Please sign in to comment.