From a0c62e686e3d226fa2231d17915f3af46340d0cc Mon Sep 17 00:00:00 2001 From: Pavel Marek Date: Fri, 29 Sep 2023 14:10:15 +0200 Subject: [PATCH 1/6] Enable Enso asserts via ENSO_ENABLE_ASSERTIONS env var in CI --- build/build/src/enso.rs | 4 +++- build/build/src/paths.rs | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/build/build/src/enso.rs b/build/build/src/enso.rs index b1258c19c1db..40f03754c938 100644 --- a/build/build/src/enso.rs +++ b/build/build/src/enso.rs @@ -1,6 +1,6 @@ use crate::prelude::*; -use crate::paths::Paths; +use crate::paths::{ENSO_ENABLE_ASSERTIONS, Paths}; use crate::paths::ENSO_META_TEST_ARGS; use crate::paths::ENSO_META_TEST_COMMAND; use crate::postgres; @@ -119,6 +119,8 @@ impl BuiltEnso { ENSO_META_TEST_COMMAND.set(&self.wrapper_script_path())?; ENSO_META_TEST_ARGS.set(&format!("{} --run", ir_caches.flag()))?; + ENSO_ENABLE_ASSERTIONS.set(&"true".to_string())?; + // Prepare Engine Test Environment if let Ok(gdoc_key) = std::env::var("GDOC_KEY") { let google_api_test_data_dir = diff --git a/build/build/src/paths.rs b/build/build/src/paths.rs index afd5bab79df6..c52809a091b1 100644 --- a/build/build/src/paths.rs +++ b/build/build/src/paths.rs @@ -29,6 +29,9 @@ ide_ci::define_env_var! { /// Arguments to the engine runner. /// See: ENSO_META_TEST_ARGS, String; + + /// If Enso-specific assertions should be enabled. + ENSO_ENABLE_ASSERTIONS, String; } pub const EDITION_FILE_ARTIFACT_NAME: &str = "Edition File"; From 824c368f176b5b497c0016e54137ebc35d03175b Mon Sep 17 00:00:00 2001 From: Pavel Marek Date: Mon, 2 Oct 2023 14:14:13 +0200 Subject: [PATCH 2/6] Add Asserts_Spec tests --- test/Tests/src/Runtime/Asserts_Spec.enso | 27 ++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 test/Tests/src/Runtime/Asserts_Spec.enso diff --git a/test/Tests/src/Runtime/Asserts_Spec.enso b/test/Tests/src/Runtime/Asserts_Spec.enso new file mode 100644 index 000000000000..d99d7c93d4d2 --- /dev/null +++ b/test/Tests/src/Runtime/Asserts_Spec.enso @@ -0,0 +1,27 @@ +from Standard.Base import all + +from Standard.Base.Errors.Common import Assert_Error + +from Standard.Test import Test, Test_Suite +import Standard.Test.Extensions + +foreign js js_check = """ + 4 == 2 + 2 + +on_ci = if env.get "ENSO_RUNNER_CONTAINER_NAME" . is_nothing . not then Nothing else "Not in CI" + +spec = Test.group "Asserts" pending=on_ci <| + Test.specify "should be enabled on the CI" <| + p = Panic.catch Assert_Error (Runtime.assert False) err-> + err.payload + Meta.type_of p . should_be Assert_Error + + Test.specify "should be able to take foreign functions as expressions" <| + ret = Runtime.assert js_check + ret . should_be Nothing + + Test.specify "should be able to take lambdas as expressions" <| + Runtime.assert <| + 4 == 2 + 2 + +main = Test_Suite.run_main spec From 722d7ae17ef4febc5d19ba73856c6d7a153951d2 Mon Sep 17 00:00:00 2001 From: Pavel Marek Date: Mon, 2 Oct 2023 15:06:58 +0200 Subject: [PATCH 3/6] fmt --- build/build/src/enso.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build/build/src/enso.rs b/build/build/src/enso.rs index 40f03754c938..99214b441c2a 100644 --- a/build/build/src/enso.rs +++ b/build/build/src/enso.rs @@ -1,6 +1,7 @@ use crate::prelude::*; -use crate::paths::{ENSO_ENABLE_ASSERTIONS, Paths}; +use crate::paths::Paths; +use crate::paths::ENSO_ENABLE_ASSERTIONS; use crate::paths::ENSO_META_TEST_ARGS; use crate::paths::ENSO_META_TEST_COMMAND; use crate::postgres; From c2055564074322a1f391b590e65a5cb59219e950 Mon Sep 17 00:00:00 2001 From: Pavel Marek Date: Mon, 2 Oct 2023 17:44:02 +0200 Subject: [PATCH 4/6] Include Asserts_Spec in the test suite --- test/Tests/src/Main.enso | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/Tests/src/Main.enso b/test/Tests/src/Main.enso index f14a8ac24f3e..1f69d9ec46a3 100644 --- a/test/Tests/src/Main.enso +++ b/test/Tests/src/Main.enso @@ -65,6 +65,7 @@ import project.Network.Http_Spec import project.Network.URI_Spec import project.Runtime.Ascribed_Parameters_Spec +import project.Runtime.Asserts_Spec import project.Runtime.Lazy_Spec import project.Runtime.Lazy_Generator_Spec import project.Runtime.Managed_Resource_Spec @@ -132,6 +133,7 @@ main = Test_Suite.run_main <| Ref_Spec.spec Regex_Spec.spec Ascribed_Parameters_Spec.spec + Asserts_Spec.spec Lazy_Spec.spec Runtime_Spec.spec Self_Type_Spec.spec From 00575c597855e23ad37a729ad68d12af835aeb40 Mon Sep 17 00:00:00 2001 From: Pavel Marek Date: Tue, 3 Oct 2023 12:32:27 +0200 Subject: [PATCH 5/6] Fix Assert_Spec tests --- test/Tests/src/Runtime/Asserts_Spec.enso | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/Tests/src/Runtime/Asserts_Spec.enso b/test/Tests/src/Runtime/Asserts_Spec.enso index d99d7c93d4d2..3261df693a9d 100644 --- a/test/Tests/src/Runtime/Asserts_Spec.enso +++ b/test/Tests/src/Runtime/Asserts_Spec.enso @@ -1,24 +1,24 @@ from Standard.Base import all -from Standard.Base.Errors.Common import Assert_Error +from Standard.Base.Errors.Common import Assertion_Error from Standard.Test import Test, Test_Suite import Standard.Test.Extensions foreign js js_check = """ - 4 == 2 + 2 + return (4 == 2 + 2) -on_ci = if env.get "ENSO_RUNNER_CONTAINER_NAME" . is_nothing . not then Nothing else "Not in CI" +on_ci = if Environment.get "ENSO_RUNNER_CONTAINER_NAME" . is_nothing . not then Nothing else "Not in CI" spec = Test.group "Asserts" pending=on_ci <| Test.specify "should be enabled on the CI" <| - p = Panic.catch Assert_Error (Runtime.assert False) err-> + p = Panic.catch Assertion_Error (Runtime.assert False) err-> err.payload - Meta.type_of p . should_be Assert_Error + Meta.type_of p . should_be_a Assertion_Error Test.specify "should be able to take foreign functions as expressions" <| ret = Runtime.assert js_check - ret . should_be Nothing + ret . should_be_a Nothing Test.specify "should be able to take lambdas as expressions" <| Runtime.assert <| From 9dfaef1a94e53fcc6f54c372a0bdef789c6286c1 Mon Sep 17 00:00:00 2001 From: Pavel Marek Date: Tue, 3 Oct 2023 13:11:52 +0200 Subject: [PATCH 6/6] fmt --- build/build/src/enso.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/build/src/enso.rs b/build/build/src/enso.rs index 99214b441c2a..40d2e27721c8 100644 --- a/build/build/src/enso.rs +++ b/build/build/src/enso.rs @@ -120,7 +120,7 @@ impl BuiltEnso { ENSO_META_TEST_COMMAND.set(&self.wrapper_script_path())?; ENSO_META_TEST_ARGS.set(&format!("{} --run", ir_caches.flag()))?; - ENSO_ENABLE_ASSERTIONS.set(&"true".to_string())?; + ENSO_ENABLE_ASSERTIONS.set("true")?; // Prepare Engine Test Environment if let Ok(gdoc_key) = std::env::var("GDOC_KEY") {