diff --git a/compiler/compiler/src/run.rs b/compiler/compiler/src/run.rs index e1ae99dae99..c306476a7d8 100644 --- a/compiler/compiler/src/run.rs +++ b/compiler/compiler/src/run.rs @@ -318,10 +318,14 @@ pub fn run_with_ledger(config: &Config, case_sets: &[Vec]) -> Result Result<()> { // Add the program to the ledger. // Note that this function performs an additional validity check on the bytecode. - let deployment = ledger - .vm() - .deploy(&genesis_private_key, &aleo_program, None, 0, None, &mut rng) - .map_err(|e| anyhow!("Failed to deploy program {name}: {e}"))?; + // Catch panics during deployment (e.g., constraint failures during key synthesis). + let deployment = match catch_unwind(AssertUnwindSafe(|| { + ledger.vm().deploy(&genesis_private_key, &aleo_program, None, 0, None, &mut rng) + })) { + Ok(Ok(deployment)) => deployment, + Ok(Err(e)) => return Err(anyhow!("Failed to deploy program {name}: {e}").into()), + Err(e) => return Err(anyhow!("Panic during deployment of program {name}: {e:?}").into()), + }; let block = ledger .prepare_advance_to_next_beacon_block(&genesis_private_key, vec![], vec![], vec![deployment], &mut rng) .map_err(|e| anyhow!("Failed to prepare to advance block for program {name}: {e}"))?; diff --git a/errors/src/errors/cli/cli_errors.rs b/errors/src/errors/cli/cli_errors.rs index 9e3995743b1..014d08c812e 100644 --- a/errors/src/errors/cli/cli_errors.rs +++ b/errors/src/errors/cli/cli_errors.rs @@ -334,4 +334,11 @@ create_messages!( msg: format!("{msg}"), help: None, } + + @backtraced + tests_failed { + args: (failed: impl Display, total: impl Display), + msg: format!("{failed} out of {total} tests failed"), + help: None, + } ); diff --git a/leo/cli/commands/test.rs b/leo/cli/commands/test.rs index 679f3805a03..7cc4a0732df 100644 --- a/leo/cli/commands/test.rs +++ b/leo/cli/commands/test.rs @@ -178,6 +178,6 @@ fn handle_test(command: LeoTest, package: Package) -> Result<()> { } } - Ok(()) + if total_passed < total { Err(CliError::tests_failed(total - total_passed, total).into()) } else { Ok(()) } } } diff --git a/leo/tests/integration.rs b/leo/tests/integration.rs index ffa7edbc42c..cd22b1a5091 100644 --- a/leo/tests/integration.rs +++ b/leo/tests/integration.rs @@ -115,6 +115,12 @@ fn run_test(test: &Test, force_rewrite: bool) -> Option { let stderr_utf8 = std::str::from_utf8(&output.stderr).expect("stderr should be utf8"); fs::write(&stderr_path, filter_stderr(stderr_utf8).as_bytes()).expect("Failed to write STDERR"); + // Capture exit code if the command exited normally + let exitcode_path = test_context_directory.path().join("EXITCODE"); + if let Some(code) = output.status.code() { + fs::write(&exitcode_path, code.to_string().as_bytes()).expect("Failed to write EXITCODE"); + } + if force_rewrite { copy_recursively(test_context_directory.path(), &test.expectation_directory) .expect("Failed to copy directory."); diff --git a/tests/expectations/cli/network_dependency/EXITCODE b/tests/expectations/cli/network_dependency/EXITCODE new file mode 100644 index 00000000000..c227083464f --- /dev/null +++ b/tests/expectations/cli/network_dependency/EXITCODE @@ -0,0 +1 @@ +0 \ No newline at end of file diff --git a/tests/expectations/cli/program_name_mismatch/EXITCODE b/tests/expectations/cli/program_name_mismatch/EXITCODE new file mode 100644 index 00000000000..41296575091 --- /dev/null +++ b/tests/expectations/cli/program_name_mismatch/EXITCODE @@ -0,0 +1 @@ +196 \ No newline at end of file diff --git a/tests/expectations/cli/test_add/EXITCODE b/tests/expectations/cli/test_add/EXITCODE new file mode 100644 index 00000000000..c227083464f --- /dev/null +++ b/tests/expectations/cli/test_add/EXITCODE @@ -0,0 +1 @@ +0 \ No newline at end of file diff --git a/tests/expectations/cli/test_command_shortcuts/EXITCODE b/tests/expectations/cli/test_command_shortcuts/EXITCODE new file mode 100644 index 00000000000..c227083464f --- /dev/null +++ b/tests/expectations/cli/test_command_shortcuts/EXITCODE @@ -0,0 +1 @@ +0 \ No newline at end of file diff --git a/tests/expectations/cli/test_deploy/EXITCODE b/tests/expectations/cli/test_deploy/EXITCODE new file mode 100644 index 00000000000..c227083464f --- /dev/null +++ b/tests/expectations/cli/test_deploy/EXITCODE @@ -0,0 +1 @@ +0 \ No newline at end of file diff --git a/tests/expectations/cli/test_failure_exit_code/COMMANDS b/tests/expectations/cli/test_failure_exit_code/COMMANDS new file mode 100755 index 00000000000..2ee615b7deb --- /dev/null +++ b/tests/expectations/cli/test_failure_exit_code/COMMANDS @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +LEO_BIN=${1} + +${LEO_BIN} test diff --git a/tests/expectations/cli/test_failure_exit_code/EXITCODE b/tests/expectations/cli/test_failure_exit_code/EXITCODE new file mode 100644 index 00000000000..030d25b2869 --- /dev/null +++ b/tests/expectations/cli/test_failure_exit_code/EXITCODE @@ -0,0 +1 @@ +248 \ No newline at end of file diff --git a/tests/expectations/cli/test_failure_exit_code/STDERR b/tests/expectations/cli/test_failure_exit_code/STDERR new file mode 100644 index 00000000000..5d4cd7760b8 --- /dev/null +++ b/tests/expectations/cli/test_failure_exit_code/STDERR @@ -0,0 +1,136 @@ +thread `main` panicked at /home/mindtree/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/snarkvm-circuit-environment-4.4.0/src/testnet_circuit.rs:152:29: +assertion `left == right` failed: Constant constraint failed: (0 * 1) =?= 1 + left: 0 + right: 1 +stack backtrace: + 0: leo::set_panic_hook::{closure#0} + at /home/mindtree/repo/provable/leo/leo/cli/main.rs:26:50 + 1: core::ops::function::Fn<(&'a std::panic::PanicHookInfo<'b>,), Output = ()> + core::marker::Send + core::marker::Sync> as core::ops::function::Fn<(&std::panic::PanicHookInfo,)>>::call + at /rustc/1d60f9e070c1039b263e0f035c0f03dfcc610d0f/library/alloc/src/boxed.rs:2220:9 + std::panicking::panic_with_hook + at /rustc/1d60f9e070c1039b263e0f035c0f03dfcc610d0f/library/std/src/panicking.rs:833:13 + 2: std::panicking::panic_handler::{closure#0} + at /rustc/1d60f9e070c1039b263e0f035c0f03dfcc610d0f/library/std/src/panicking.rs:698:13 + 3: std::sys::backtrace::__rust_end_short_backtrace:: + at /rustc/1d60f9e070c1039b263e0f035c0f03dfcc610d0f/library/std/src/sys/backtrace.rs:176:18 + 4: __rustc::rust_begin_unwind + at /rustc/1d60f9e070c1039b263e0f035c0f03dfcc610d0f/library/std/src/panicking.rs:689:5 + 5: core::panicking::panic_fmt + at /rustc/1d60f9e070c1039b263e0f035c0f03dfcc610d0f/library/core/src/panicking.rs:80:14 + 6: core::panicking::assert_failed_inner + at /rustc/1d60f9e070c1039b263e0f035c0f03dfcc610d0f/library/core/src/panicking.rs:434:23 + 7: core::panicking::assert_failed::, snarkvm_fields::fp_256::Fp256> + at /rustc/1d60f9e070c1039b263e0f035c0f03dfcc610d0f/library/core/src/panicking.rs:394:5 + 8: ::enforce::<::assert>::{closure#0}, snarkvm_circuit_types_boolean::Boolean, snarkvm_circuit_environment::helpers::linear_combination::LinearCombination>, snarkvm_circuit_environment::helpers::linear_combination::LinearCombination>>::{closure#0}::{closure#0} + at /home/mindtree/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/snarkvm-circuit-environment-4.4.0/src/testnet_circuit.rs:152:29 + >>>>::try_with::<::enforce<::assert>::{closure#0}, snarkvm_circuit_types_boolean::Boolean, snarkvm_circuit_environment::helpers::linear_combination::LinearCombination>, snarkvm_circuit_environment::helpers::linear_combination::LinearCombination>>::{closure#0}::{closure#0}, ()> + at /rustc/1d60f9e070c1039b263e0f035c0f03dfcc610d0f/library/std/src/thread/local.rs:513:12 + >>>>::with::<::enforce<::assert>::{closure#0}, snarkvm_circuit_types_boolean::Boolean, snarkvm_circuit_environment::helpers::linear_combination::LinearCombination>, snarkvm_circuit_environment::helpers::linear_combination::LinearCombination>>::{closure#0}::{closure#0}, ()> + at /rustc/1d60f9e070c1039b263e0f035c0f03dfcc610d0f/library/std/src/thread/local.rs:477:20 + ::enforce::<::assert>::{closure#0}, snarkvm_circuit_types_boolean::Boolean, snarkvm_circuit_environment::helpers::linear_combination::LinearCombination>, snarkvm_circuit_environment::helpers::linear_combination::LinearCombination>>::{closure#0} + at /home/mindtree/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/snarkvm-circuit-environment-4.4.0/src/testnet_circuit.rs:135:33 + >>::try_with::<::enforce<::assert>::{closure#0}, snarkvm_circuit_types_boolean::Boolean, snarkvm_circuit_environment::helpers::linear_combination::LinearCombination>, snarkvm_circuit_environment::helpers::linear_combination::LinearCombination>>::{closure#0}, ()> + at /rustc/1d60f9e070c1039b263e0f035c0f03dfcc610d0f/library/std/src/thread/local.rs:513:12 + >>::with::<::enforce<::assert>::{closure#0}, snarkvm_circuit_types_boolean::Boolean, snarkvm_circuit_environment::helpers::linear_combination::LinearCombination>, snarkvm_circuit_environment::helpers::linear_combination::LinearCombination>>::{closure#0}, ()> + at /rustc/1d60f9e070c1039b263e0f035c0f03dfcc610d0f/library/std/src/thread/local.rs:477:20 + 9: ::enforce::<::assert>::{closure#0}, snarkvm_circuit_types_boolean::Boolean, snarkvm_circuit_environment::helpers::linear_combination::LinearCombination>, snarkvm_circuit_environment::helpers::linear_combination::LinearCombination>> + at /home/mindtree/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/snarkvm-circuit-environment-4.4.0/src/testnet_circuit.rs:132:20 + ::enforce::<::assert>::{closure#0}, snarkvm_circuit_types_boolean::Boolean, snarkvm_circuit_environment::helpers::linear_combination::LinearCombination>, snarkvm_circuit_environment::helpers::linear_combination::LinearCombination>> + at /home/mindtree/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/snarkvm-circuit-network-4.4.0/src/testnet_v0.rs:433:9 + ::assert::> + at /home/mindtree/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/snarkvm-circuit-environment-4.4.0/src/environment.rs:74:9 + 10: >::execute::, snarkvm_synthesizer_process::stack::registers::Registers> + at /home/mindtree/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/snarkvm-synthesizer-program-4.4.0/src/logic/instruction/operation/assert.rs:121:18 + 11: >::execute_function:: + at /home/mindtree/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/snarkvm-synthesizer-process-4.4.0/src/stack/execute.rs:325:34 + 12: >::synthesize_key:: + at /home/mindtree/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/snarkvm-synthesizer-process-4.4.0/src/stack/helpers/synthesize.rs:82:30 + >::deploy:: + at /home/mindtree/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/snarkvm-synthesizer-process-4.4.0/src/stack/deploy.rs:34:18 + >::deploy:: + at /home/mindtree/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/snarkvm-synthesizer-process-4.4.0/src/deploy.rs:33:32 + >>::deploy_raw:: + at /home/mindtree/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/snarkvm-synthesizer-4.4.0/src/vm/deploy.rs:94:43 + >>::deploy:: + at /home/mindtree/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/snarkvm-synthesizer-4.4.0/src/vm/deploy.rs:35:35 + 13: leo_compiler::run::run_with_ledger::{closure#3}::{closure#0} + at /home/mindtree/repo/provable/leo/compiler/compiler/src/run.rs:323:29 + >::call_once + at /rustc/1d60f9e070c1039b263e0f035c0f03dfcc610d0f/library/core/src/ops/function.rs:250:5 + as core::ops::function::FnOnce<()>>::call_once + at /rustc/1d60f9e070c1039b263e0f035c0f03dfcc610d0f/library/core/src/panic/unwind_safe.rs:274:9 + std::panicking::catch_unwind::do_call::, core::result::Result, anyhow::Error>> + at /rustc/1d60f9e070c1039b263e0f035c0f03dfcc610d0f/library/std/src/panicking.rs:581:40 + std::panicking::catch_unwind::, anyhow::Error>, core::panic::unwind_safe::AssertUnwindSafe> + at /rustc/1d60f9e070c1039b263e0f035c0f03dfcc610d0f/library/std/src/panicking.rs:544:19 + std::panic::catch_unwind::, core::result::Result, anyhow::Error>> + at /rustc/1d60f9e070c1039b263e0f035c0f03dfcc610d0f/library/std/src/panic.rs:359:14 + leo_compiler::run::run_with_ledger::{closure#3} + at /home/mindtree/repo/provable/leo/compiler/compiler/src/run.rs:322:36 + 14: leo_compiler::run::run_with_ledger + at /home/mindtree/repo/provable/leo/compiler/compiler/src/run.rs:348:9 + 15: leo_lang::cli::commands::test::handle_test + at /home/mindtree/repo/provable/leo/leo/cli/commands/test.rs:128:20 + ::apply + at /home/mindtree/repo/provable/leo/leo/cli/commands/test.rs:60:9 + 16: ::execute + at /home/mindtree/repo/provable/leo/leo/cli/commands/mod.rs:129:24 + ::try_execute + at /home/mindtree/repo/provable/leo/leo/cli/commands/mod.rs:143:14 + 17: leo_lang::cli::cli::run_with_args + at /home/mindtree/repo/provable/leo/leo/cli/cli.rs:179:47 + 18: leo::main::{closure#0} + at /home/mindtree/repo/provable/leo/leo/cli/main.rs:47:53 + >::with:: + at /home/mindtree/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/scoped-tls-1.0.1/src/lib.rs:171:13 + 19: leo_span::symbol::create_session_if_not_set_then::<(), leo::main::{closure#0}>::{closure#0} + at /home/mindtree/repo/provable/leo/compiler/span/src/symbol.rs:450:53 + >::set::::{closure#0}, ()> + at /home/mindtree/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/scoped-tls-1.0.1/src/lib.rs:137:9 + 20: leo_span::symbol::create_session_if_not_set_then::<(), leo::main::{closure#0}> + at /home/mindtree/repo/provable/leo/compiler/span/src/symbol.rs:450:25 + leo::main + at /home/mindtree/repo/provable/leo/leo/cli/main.rs:47:5 + 21: >::call_once + at /rustc/1d60f9e070c1039b263e0f035c0f03dfcc610d0f/library/core/src/ops/function.rs:250:5 + std::sys::backtrace::__rust_begin_short_backtrace:: + at /rustc/1d60f9e070c1039b263e0f035c0f03dfcc610d0f/library/std/src/sys/backtrace.rs:160:18 + 22: std::rt::lang_start::<()>::{closure#0} + at /rustc/1d60f9e070c1039b263e0f035c0f03dfcc610d0f/library/std/src/rt.rs:206:18 + 23: <&dyn core::ops::function::Fn<(), Output = i32> + core::panic::unwind_safe::RefUnwindSafe + core::marker::Sync as core::ops::function::FnOnce<()>>::call_once + at /rustc/1d60f9e070c1039b263e0f035c0f03dfcc610d0f/library/core/src/ops/function.rs:287:21 + std::panicking::catch_unwind::do_call::<&dyn core::ops::function::Fn<(), Output = i32> + core::panic::unwind_safe::RefUnwindSafe + core::marker::Sync, i32> + at /rustc/1d60f9e070c1039b263e0f035c0f03dfcc610d0f/library/std/src/panicking.rs:581:40 + std::panicking::catch_unwind:: + core::panic::unwind_safe::RefUnwindSafe + core::marker::Sync> + at /rustc/1d60f9e070c1039b263e0f035c0f03dfcc610d0f/library/std/src/panicking.rs:544:19 + std::panic::catch_unwind::<&dyn core::ops::function::Fn<(), Output = i32> + core::panic::unwind_safe::RefUnwindSafe + core::marker::Sync, i32> + at /rustc/1d60f9e070c1039b263e0f035c0f03dfcc610d0f/library/std/src/panic.rs:359:14 + std::rt::lang_start_internal::{closure#0} + at /rustc/1d60f9e070c1039b263e0f035c0f03dfcc610d0f/library/std/src/rt.rs:175:24 + std::panicking::catch_unwind::do_call:: + at /rustc/1d60f9e070c1039b263e0f035c0f03dfcc610d0f/library/std/src/panicking.rs:581:40 + std::panicking::catch_unwind:: + at /rustc/1d60f9e070c1039b263e0f035c0f03dfcc610d0f/library/std/src/panicking.rs:544:19 + std::panic::catch_unwind:: + at /rustc/1d60f9e070c1039b263e0f035c0f03dfcc610d0f/library/std/src/panic.rs:359:14 + std::rt::lang_start_internal + at /rustc/1d60f9e070c1039b263e0f035c0f03dfcc610d0f/library/std/src/rt.rs:171:5 + 24: std::rt::lang_start::<()> + at /rustc/1d60f9e070c1039b263e0f035c0f03dfcc610d0f/library/std/src/rt.rs:205:5 + 25: __libc_start_call_main + 26: __libc_start_main_alias_1 + 27: _start + +error: internal compiler error: unexpected panic + +note: the compiler unexpectedly panicked. this is a bug. + +note: we would appreciate a bug report: https://github.com/ProvableHQ/leo/issues/new?labels=bug,panic&template=bug.md&title=[Bug] + +note: leo-lang 3.4.0 running on Linux 6.12.58 + +note: compiler args: /home/mindtree/repo/provable/leo/target/debug/leo test + +note: compiler flags: CLI { debug: false, quiet: false, command: Test { command: LeoTest { test_name: "", compiler_options: BuildOptions { offline: false, enable_ast_spans: false, enable_dce: true, conditional_block_max_depth: 10, disable_conditional_branch_type_checking: false, enable_initial_ast_snapshot: false, enable_all_ast_snapshots: false, ast_snapshots: [], build_tests: false, no_cache: false, no_local: false }, env_override: EnvOptions { private_key: None, network: None, endpoint: None, devnet: false, consensus_heights: None } } }, path: None, home: None } + +Panic during deployment of program test_failure: Any { .. } diff --git a/tests/expectations/cli/test_failure_exit_code/STDOUT b/tests/expectations/cli/test_failure_exit_code/STDOUT new file mode 100644 index 00000000000..e7f96b8e353 --- /dev/null +++ b/tests/expectations/cli/test_failure_exit_code/STDOUT @@ -0,0 +1,11 @@ +⚠️ No network specified, defaulting to 'testnet'. +⚠️ No endpoint specified, defaulting to 'https://api.explorer.provable.com/v1'. + Leo 2 statements before dead code elimination. + Leo 2 statements after dead code elimination. + Leo The program checksum is: '[169u8, 44u8, 143u8, 18u8, 47u8, 196u8, 2u8, 77u8, 84u8, 100u8, 131u8, 15u8, 54u8, 173u8, 74u8, 56u8, 55u8, 110u8, 248u8, 62u8, 168u8, 75u8, 162u8, 68u8, 220u8, 201u8, 90u8, 144u8, 1u8, 150u8, 69u8, 68u8]'. + Leo ✅ Compiled 'test_failure_exit_code.aleo' into Aleo instructions. + Leo 3 statements before dead code elimination. + Leo 3 statements after dead code elimination. + Leo The program checksum is: '[102u8, 47u8, 165u8, 186u8, 89u8, 127u8, 235u8, 8u8, 218u8, 104u8, 153u8, 232u8, 55u8, 84u8, 184u8, 59u8, 59u8, 81u8, 222u8, 235u8, 199u8, 43u8, 69u8, 129u8, 112u8, 197u8, 74u8, 39u8, 13u8, 220u8, 22u8, 196u8]'. + Leo ✅ Compiled 'test_failure.aleo' into Aleo instructions. + Leo Loading the ledger from storage... diff --git a/tests/expectations/cli/test_failure_exit_code/contents/.gitignore b/tests/expectations/cli/test_failure_exit_code/contents/.gitignore new file mode 100644 index 00000000000..e4f154aa009 --- /dev/null +++ b/tests/expectations/cli/test_failure_exit_code/contents/.gitignore @@ -0,0 +1,5 @@ +outputs/ +build/ +*.avm +*.prover +*.verifier diff --git a/tests/expectations/cli/test_failure_exit_code/contents/program.json b/tests/expectations/cli/test_failure_exit_code/contents/program.json new file mode 100644 index 00000000000..8441689f82c --- /dev/null +++ b/tests/expectations/cli/test_failure_exit_code/contents/program.json @@ -0,0 +1,6 @@ +{ + "program": "test_failure_exit_code.aleo", + "version": "1.0.0", + "description": "Test program for exit code verification", + "license": "MIT" +} diff --git a/tests/expectations/cli/test_failure_exit_code/contents/src/main.leo b/tests/expectations/cli/test_failure_exit_code/contents/src/main.leo new file mode 100644 index 00000000000..baaa5ab92af --- /dev/null +++ b/tests/expectations/cli/test_failure_exit_code/contents/src/main.leo @@ -0,0 +1,8 @@ +program test_failure_exit_code.aleo { + transition main() -> u8 { + return 42u8; + } + + @noupgrade + async constructor() {} +} diff --git a/tests/expectations/cli/test_failure_exit_code/contents/tests/test_failure.leo b/tests/expectations/cli/test_failure_exit_code/contents/tests/test_failure.leo new file mode 100644 index 00000000000..0274446eb87 --- /dev/null +++ b/tests/expectations/cli/test_failure_exit_code/contents/tests/test_failure.leo @@ -0,0 +1,9 @@ +// Test to verify that test failures exit with non-zero exit code +import test_failure_exit_code.aleo; + +program test_failure.aleo { + @test + transition test_should_fail() { + assert_eq(1u8, 2u8); + } +} diff --git a/tests/expectations/cli/test_simple_build/EXITCODE b/tests/expectations/cli/test_simple_build/EXITCODE new file mode 100644 index 00000000000..c227083464f --- /dev/null +++ b/tests/expectations/cli/test_simple_build/EXITCODE @@ -0,0 +1 @@ +0 \ No newline at end of file diff --git a/tests/tests/cli/test_failure_exit_code/COMMANDS b/tests/tests/cli/test_failure_exit_code/COMMANDS new file mode 100755 index 00000000000..2ee615b7deb --- /dev/null +++ b/tests/tests/cli/test_failure_exit_code/COMMANDS @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +LEO_BIN=${1} + +${LEO_BIN} test diff --git a/tests/tests/cli/test_failure_exit_code/contents/.gitignore b/tests/tests/cli/test_failure_exit_code/contents/.gitignore new file mode 100644 index 00000000000..e4f154aa009 --- /dev/null +++ b/tests/tests/cli/test_failure_exit_code/contents/.gitignore @@ -0,0 +1,5 @@ +outputs/ +build/ +*.avm +*.prover +*.verifier diff --git a/tests/tests/cli/test_failure_exit_code/contents/program.json b/tests/tests/cli/test_failure_exit_code/contents/program.json new file mode 100644 index 00000000000..8441689f82c --- /dev/null +++ b/tests/tests/cli/test_failure_exit_code/contents/program.json @@ -0,0 +1,6 @@ +{ + "program": "test_failure_exit_code.aleo", + "version": "1.0.0", + "description": "Test program for exit code verification", + "license": "MIT" +} diff --git a/tests/tests/cli/test_failure_exit_code/contents/src/main.leo b/tests/tests/cli/test_failure_exit_code/contents/src/main.leo new file mode 100644 index 00000000000..baaa5ab92af --- /dev/null +++ b/tests/tests/cli/test_failure_exit_code/contents/src/main.leo @@ -0,0 +1,8 @@ +program test_failure_exit_code.aleo { + transition main() -> u8 { + return 42u8; + } + + @noupgrade + async constructor() {} +} diff --git a/tests/tests/cli/test_failure_exit_code/contents/tests/test_failure.leo b/tests/tests/cli/test_failure_exit_code/contents/tests/test_failure.leo new file mode 100644 index 00000000000..0274446eb87 --- /dev/null +++ b/tests/tests/cli/test_failure_exit_code/contents/tests/test_failure.leo @@ -0,0 +1,9 @@ +// Test to verify that test failures exit with non-zero exit code +import test_failure_exit_code.aleo; + +program test_failure.aleo { + @test + transition test_should_fail() { + assert_eq(1u8, 2u8); + } +}