Skip to content

Commit

Permalink
Adds changes for code generation tests configuration (#98)
Browse files Browse the repository at this point in the history
  • Loading branch information
desaikd authored Apr 9, 2024
1 parent fe2a279 commit e8c44a7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion code-gen-projects/java/code-gen-demo/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion code-gen-projects/rust/code-gen-demo/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
4 changes: 4 additions & 0 deletions tests/code-gen-tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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()
Expand All @@ -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")
Expand All @@ -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'");

Expand Down

0 comments on commit e8c44a7

Please sign in to comment.