rust/testing¶
In [ ]:
open rust.rust_operators
In [ ]:
//// test
open testing
run_tests'¶
In [ ]:
inl run_tests' tests =
(!\($'"true; () //"') : bool) |> ignore
inl fields = reflection.get_record_fields tests
fields
|> listm.iter fun name, (fn : string -> ()) =>
!\($'"} /* /*"')
(!\($'$"*/ #[test] fn " + !name + "() { //"') : bool) |> ignore
fn name
fields
|> listm.iter fun _ =>
!\($'"{ //"') : ()
In [ ]:
//// test
inl run test =
if env.get_environment_variable "TEST" = "1"
then ()
else
runtime.execution_options fun x => { x with
command = "cargo test -- --show-output"
working_directory = file_system.get_source_directory () |> Some |> optionm'.box
environment_variables = ;[ "TEST", "1" ]
}
|> runtime.execute_with_options
|> fun exit_code, result =>
exit_code |> _assert_eq 0i32
result |> _assert sm'.contains "test result: ok. 1 passed; 0 failed; 0 ignored;"
$'let tests () = !test ()' : ()
In [ ]:
//// test
///! rust -d encoding_rs encoding_rs_io
fun () =>
run_tests' {
a = _assert_eq "a"
}
|> run
00:00:00 d #1 runtime.execute_with_options / { file_name = cargo; arguments = ["test", "--", "--show-output"]; options = { command = cargo test -- --show-output; cancellation_token = None; environment_variables = Array(MutCell([("TEST", "1")])); on_line = None; stdin = None; trace = true; working_directory = Some( "/home/runner/work/polyglot/polyglot/target/spiral_builder/spiral_builder/packages/Rust/1076de5133da778c16b63f97779dd39e0dcfc2ce9b189fbfef65812c9c2faf12", ) } } 00:00:00 v #2 ! Compiling spiral_builder_1076de5133da778c16b63f97779dd39e0dcfc2ce9b189fbfef65812c9c2faf12 v0.0.1 (/home/runner/work/polyglot/polyglot/target/spiral_builder/spiral_builder/packages/Rust/1076de5133da778c16b63f97779dd39e0dcfc2ce9b189fbfef65812c9c2faf12) 00:00:00 v #3 ! Finished `test` profile [unoptimized + debuginfo] target(s) in 0.51s 00:00:00 v #4 ! Running unittests spiral_builder.rs (/home/runner/work/polyglot/polyglot/target/spiral_builder/spiral_builder/target/debug/deps/spiral_builder_1076de5133da778c16b63f97779dd39e0dcfc2ce9b189fbfef65812c9c2faf12-3951055826ab745b) 00:00:00 v #5 > 00:00:00 v #6 > running 1 test 00:00:00 v #7 > test module_7e2cd9e0::Spiral_builder::a ... ok 00:00:00 v #8 > 00:00:00 v #9 > successes: 00:00:00 v #10 > 00:00:00 v #11 > ---- module_7e2cd9e0::Spiral_builder::a stdout ---- 00:00:00 v #12 > __assert_eq / actual: "a" / expected: "a" 00:00:00 v #13 > 00:00:00 v #14 > 00:00:00 v #15 > successes: 00:00:00 v #16 > module_7e2cd9e0::Spiral_builder::a 00:00:00 v #17 > 00:00:00 v #18 > test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s 00:00:00 v #19 > 00:00:00 v #20 runtime.execute_with_options / result / { exit_code = 0; std_trace_length = 944 } __assert_eq / actual: 0 / expected: 0 __assert / actual: "test result: ok. 1 passed; 0 failed; 0 ignored;" / expected: " Compiling spiral_builder_1076de5133da778c16b63f97779dd39e0dcfc2ce9b189fbfef65812c9c2faf12 v0.0.1 (/home/runner/work/polyglot/polyglot/target/spiral_builder/spiral_builder/packages/Rust/1076de5133da778c16b63f97779dd39e0dcfc2ce9b189fbfef65812c9c2faf12) Finished `test` profile [unoptimized + debuginfo] target(s) in 0.51s Running unittests spiral_builder.rs (/home/runner/work/polyglot/polyglot/target/spiral_builder/spiral_builder/target/debug/deps/spiral_builder_1076de5133da778c16b63f97779dd39e0dcfc2ce9b189fbfef65812c9c2faf12-3951055826ab745b) running 1 test test module_7e2cd9e0::Spiral_builder::a ... ok successes: ---- module_7e2cd9e0::Spiral_builder::a stdout ---- __assert_eq / actual: "a" / expected: "a" successes: module_7e2cd9e0::Spiral_builder::a test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s "
run_tests¶
In [ ]:
inl run_tests tests : () =
real
inl tests =
real_core.record_map
fun { key value } =>
(fun _ => value ()) : string -> ()
tests
run_tests' `(`tests) tests
In [ ]:
//// test
///! rust -d encoding_rs encoding_rs_io
fun () =>
run_tests {
a = fun () => "a" |> _assert_eq "a"
}
|> run
00:00:00 d #1 runtime.execute_with_options / { file_name = cargo; arguments = ["test", "--", "--show-output"]; options = { command = cargo test -- --show-output; cancellation_token = None; environment_variables = Array(MutCell([("TEST", "1")])); on_line = None; stdin = None; trace = true; working_directory = Some( "/home/runner/work/polyglot/polyglot/target/spiral_builder/spiral_builder/packages/Rust/1076de5133da778c16b63f97779dd39e0dcfc2ce9b189fbfef65812c9c2faf12", ) } } 00:00:00 v #2 ! Compiling spiral_builder_1076de5133da778c16b63f97779dd39e0dcfc2ce9b189fbfef65812c9c2faf12 v0.0.1 (/home/runner/work/polyglot/polyglot/target/spiral_builder/spiral_builder/packages/Rust/1076de5133da778c16b63f97779dd39e0dcfc2ce9b189fbfef65812c9c2faf12) 00:00:00 v #3 ! Finished `test` profile [unoptimized + debuginfo] target(s) in 0.51s 00:00:00 v #4 ! Running unittests spiral_builder.rs (/home/runner/work/polyglot/polyglot/target/spiral_builder/spiral_builder/target/debug/deps/spiral_builder_1076de5133da778c16b63f97779dd39e0dcfc2ce9b189fbfef65812c9c2faf12-3951055826ab745b) 00:00:00 v #5 > 00:00:00 v #6 > running 1 test 00:00:00 v #7 > test module_7e2cd9e0::Spiral_builder::a ... ok 00:00:00 v #8 > 00:00:00 v #9 > successes: 00:00:00 v #10 > 00:00:00 v #11 > ---- module_7e2cd9e0::Spiral_builder::a stdout ---- 00:00:00 v #12 > __assert_eq / actual: "a" / expected: "a" 00:00:00 v #13 > 00:00:00 v #14 > 00:00:00 v #15 > successes: 00:00:00 v #16 > module_7e2cd9e0::Spiral_builder::a 00:00:00 v #17 > 00:00:00 v #18 > test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s 00:00:00 v #19 > 00:00:00 v #20 runtime.execute_with_options / result / { exit_code = 0; std_trace_length = 944 } __assert_eq / actual: 0 / expected: 0 __assert / actual: "test result: ok. 1 passed; 0 failed; 0 ignored;" / expected: " Compiling spiral_builder_1076de5133da778c16b63f97779dd39e0dcfc2ce9b189fbfef65812c9c2faf12 v0.0.1 (/home/runner/work/polyglot/polyglot/target/spiral_builder/spiral_builder/packages/Rust/1076de5133da778c16b63f97779dd39e0dcfc2ce9b189fbfef65812c9c2faf12) Finished `test` profile [unoptimized + debuginfo] target(s) in 0.51s Running unittests spiral_builder.rs (/home/runner/work/polyglot/polyglot/target/spiral_builder/spiral_builder/target/debug/deps/spiral_builder_1076de5133da778c16b63f97779dd39e0dcfc2ce9b189fbfef65812c9c2faf12-3951055826ab745b) running 1 test test module_7e2cd9e0::Spiral_builder::a ... ok successes: ---- module_7e2cd9e0::Spiral_builder::a stdout ---- __assert_eq / actual: "a" / expected: "a" successes: module_7e2cd9e0::Spiral_builder::a test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s "
run_tests_log¶
In [ ]:
inl run_tests_log tests : () =
real
inl tests =
real_core.record_map
fun { key value } =>
(fun _ => value false) : () -> ()
tests
run_tests `(`tests) tests
In [ ]:
//// test
///! rust -d encoding_rs encoding_rs_io
fun () =>
run_tests_log {
a = _assert_eq false
}
|> run
00:00:00 d #1 runtime.execute_with_options / { file_name = cargo; arguments = ["test", "--", "--show-output"]; options = { command = cargo test -- --show-output; cancellation_token = None; environment_variables = Array(MutCell([("TEST", "1")])); on_line = None; stdin = None; trace = true; working_directory = Some( "/home/runner/work/polyglot/polyglot/target/spiral_builder/spiral_builder/packages/Rust/e50987d9a623df9d5d394b63f4f6ff359c135ba0868eead9118910bfc1f7c419", ) } } 00:00:00 v #2 ! Compiling spiral_builder_e50987d9a623df9d5d394b63f4f6ff359c135ba0868eead9118910bfc1f7c419 v0.0.1 (/home/runner/work/polyglot/polyglot/target/spiral_builder/spiral_builder/packages/Rust/e50987d9a623df9d5d394b63f4f6ff359c135ba0868eead9118910bfc1f7c419) 00:00:00 v #3 ! Finished `test` profile [unoptimized + debuginfo] target(s) in 0.51s 00:00:00 v #4 ! Running unittests spiral_builder.rs (/home/runner/work/polyglot/polyglot/target/spiral_builder/spiral_builder/target/debug/deps/spiral_builder_e50987d9a623df9d5d394b63f4f6ff359c135ba0868eead9118910bfc1f7c419-a9910d1c2e43ebb7) 00:00:00 v #5 > 00:00:00 v #6 > running 1 test 00:00:00 v #7 > test module_7e2cd9e0::Spiral_builder::a ... ok 00:00:00 v #8 > 00:00:00 v #9 > successes: 00:00:00 v #10 > 00:00:00 v #11 > ---- module_7e2cd9e0::Spiral_builder::a stdout ---- 00:00:00 v #12 > __assert_eq / actual: false / expected: false 00:00:00 v #13 > 00:00:00 v #14 > 00:00:00 v #15 > successes: 00:00:00 v #16 > module_7e2cd9e0::Spiral_builder::a 00:00:00 v #17 > 00:00:00 v #18 > test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s 00:00:00 v #19 > 00:00:00 v #20 runtime.execute_with_options / result / { exit_code = 0; std_trace_length = 948 } __assert_eq / actual: 0 / expected: 0 __assert / actual: "test result: ok. 1 passed; 0 failed; 0 ignored;" / expected: " Compiling spiral_builder_e50987d9a623df9d5d394b63f4f6ff359c135ba0868eead9118910bfc1f7c419 v0.0.1 (/home/runner/work/polyglot/polyglot/target/spiral_builder/spiral_builder/packages/Rust/e50987d9a623df9d5d394b63f4f6ff359c135ba0868eead9118910bfc1f7c419) Finished `test` profile [unoptimized + debuginfo] target(s) in 0.51s Running unittests spiral_builder.rs (/home/runner/work/polyglot/polyglot/target/spiral_builder/spiral_builder/target/debug/deps/spiral_builder_e50987d9a623df9d5d394b63f4f6ff359c135ba0868eead9118910bfc1f7c419-a9910d1c2e43ebb7) running 1 test test module_7e2cd9e0::Spiral_builder::a ... ok successes: ---- module_7e2cd9e0::Spiral_builder::a stdout ---- __assert_eq / actual: false / expected: false successes: module_7e2cd9e0::Spiral_builder::a test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s "