diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml index 8eec83ae11..1395d9b68d 100644 --- a/.bazelci/presubmit.yml +++ b/.bazelci/presubmit.yml @@ -64,7 +64,6 @@ tasks: - "--" # Allows negative patterns; hack for https://github.com/bazelbuild/continuous-integration/pull/245 - "..." - "-//bindgen/..." - - "-//test/test_env/..." - "-//test/proto/..." - "-//tools/rust_analyzer/..." - "-//test/rustfmt/..." diff --git a/rust/private/rustc.bzl b/rust/private/rustc.bzl index 5474b749ea..802bc92518 100644 --- a/rust/private/rustc.bzl +++ b/rust/private/rustc.bzl @@ -503,7 +503,11 @@ def construct_arguments( if rust_common.crate_info in data: dep_crate_info = data[rust_common.crate_info] if dep_crate_info.type == "bin": - env["CARGO_BIN_EXE_" + dep_crate_info.output.basename] = dep_crate_info.output.short_path + # Trying to make CARGO_BIN_EXE_{} canonical across platform by strip out extension if exists + env_basename = dep_crate_info.output.basename + if len(dep_crate_info.output.extension) > 0: + env_basename = env_basename[:-(1 + len(dep_crate_info.output.extension))] + env["CARGO_BIN_EXE_" + env_basename] = dep_crate_info.output.short_path # Update environment with user provided variables. env.update(expand_dict_value_locations( diff --git a/test/test_env/tests/run.rs b/test/test_env/tests/run.rs index 1abaa7ab09..8eec9fa121 100644 --- a/test/test_env/tests/run.rs +++ b/test/test_env/tests/run.rs @@ -15,10 +15,14 @@ fn run() { // Test the behavior of `rootpath` and that a binary can be found relative to current_dir let hello_world_bin = std::path::PathBuf::from(std::env::var_os("HELLO_WORLD_BIN_ROOTPATH").unwrap()); - assert_eq!( - hello_world_bin.as_path(), - std::path::Path::new("test/test_env/hello-world"), - ); + + let expected_hello_world_bin = if cfg!(windows) { + std::path::Path::new("test/test_env/hello-world.exe") + } else { + std::path::Path::new("test/test_env/hello-world") + }; + + assert_eq!(hello_world_bin.as_path(), expected_hello_world_bin); assert!(!hello_world_bin.is_absolute()); assert!(hello_world_bin.exists());