Skip to content

Commit

Permalink
Enable Enso asserts on CI (#7929)
Browse files Browse the repository at this point in the history

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
Akirathan and mergify[bot] authored Oct 4, 2023
1 parent 997e0fc commit c525698
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 0 deletions.
3 changes: 3 additions & 0 deletions build/build/src/enso.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::prelude::*;

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;
Expand Down Expand Up @@ -119,6 +120,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")?;

// Prepare Engine Test Environment
if let Ok(gdoc_key) = std::env::var("GDOC_KEY") {
let google_api_test_data_dir =
Expand Down
3 changes: 3 additions & 0 deletions build/build/src/paths.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ ide_ci::define_env_var! {
/// Arguments to the engine runner.
/// See: <https://github.com/diab0l/enso/blob/feature/test_with_clue/test/Meta_Test_Suite_Tests/README.md>
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";
Expand Down
2 changes: 2 additions & 0 deletions test/Tests/src/Main.enso
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
27 changes: 27 additions & 0 deletions test/Tests/src/Runtime/Asserts_Spec.enso
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from Standard.Base import all

from Standard.Base.Errors.Common import Assertion_Error

from Standard.Test import Test, Test_Suite
import Standard.Test.Extensions

foreign js js_check = """
return (4 == 2 + 2)

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 Assertion_Error (Runtime.assert False) err->
err.payload
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_a Nothing

Test.specify "should be able to take lambdas as expressions" <|
Runtime.assert <|
4 == 2 + 2

main = Test_Suite.run_main spec

0 comments on commit c525698

Please sign in to comment.