From 20cdd2dc322eb5db6ad31430507a893430855618 Mon Sep 17 00:00:00 2001 From: Khushboo Desai Date: Tue, 9 Apr 2024 16:07:26 -0700 Subject: [PATCH] Adds changes for code generation tests configuration --- code-gen-projects/java/code-gen-demo/build.gradle.kts | 2 +- code-gen-projects/rust/code-gen-demo/build.rs | 2 +- tests/code-gen-tests.rs | 4 ++++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/code-gen-projects/java/code-gen-demo/build.gradle.kts b/code-gen-projects/java/code-gen-demo/build.gradle.kts index df43c6a..fb52d99 100644 --- a/code-gen-projects/java/code-gen-demo/build.gradle.kts +++ b/code-gen-projects/java/code-gen-demo/build.gradle.kts @@ -37,7 +37,7 @@ tasks { inputs.files(ionSchemaSourceCodeDir) outputs.file(generatedIonSchemaModelDir) - val ionCli = "../../../target/debug/ion" + val ionCli = System.getenv("ION_CLI") ?: "ion" commandLine(ionCli) .args( diff --git a/code-gen-projects/rust/code-gen-demo/build.rs b/code-gen-projects/rust/code-gen-demo/build.rs index 1bd119d..d684a2b 100644 --- a/code-gen-projects/rust/code-gen-demo/build.rs +++ b/code-gen-projects/rust/code-gen-demo/build.rs @@ -9,7 +9,7 @@ fn main() { let out_dir = env::var("OUT_DIR").unwrap(); // Invoke cargo CLI - let ion_cli = "../../../target/debug/ion"; + let ion_cli = env::var("ION_CLI").unwrap_or("ion".to_string()); println!("cargo:warn=Running command: {}", ion_cli); let mut cmd = std::process::Command::new(ion_cli); cmd.arg("beta") diff --git a/tests/code-gen-tests.rs b/tests/code-gen-tests.rs index cee1486..3c79a22 100644 --- a/tests/code-gen-tests.rs +++ b/tests/code-gen-tests.rs @@ -10,6 +10,7 @@ fn roundtrip_tests_for_generated_code_gradle() -> Result<()> { // so simply running the tests on this project builds the project, generates code and runs tests // absolute paths for gradle project and executables + let ion_executable = env!("CARGO_BIN_EXE_ion"); let test_crate_path = format!( "{}/code-gen-projects/java/code-gen-demo", env!("CARGO_MANIFEST_DIR") @@ -19,6 +20,7 @@ fn roundtrip_tests_for_generated_code_gradle() -> Result<()> { // Clean and Test let gradle_output = std::process::Command::new(gradle_executable) .current_dir(&test_crate_path) + .env("ION_CLI", ion_executable) .arg("clean") .arg("test") .output() @@ -41,6 +43,7 @@ fn roundtrip_tests_for_generated_code_cargo() -> Result<()> { // so simply running the tests on this project builds the project, generates code and runs tests // absolute paths for crate and executables + let ion_executable = env!("CARGO_BIN_EXE_ion"); let test_crate_path = format!( "{}/code-gen-projects/rust/code-gen-demo", env!("CARGO_MANIFEST_DIR") @@ -66,6 +69,7 @@ fn roundtrip_tests_for_generated_code_cargo() -> Result<()> { let cargo_test_output = std::process::Command::new(cargo_executable) .current_dir(&test_crate_path) .arg("test") + .env("ION_CLI", ion_executable) .output() .expect("failed to execute 'cargo test'");