Skip to content

Commit

Permalink
Refactor Table_Tests to the builder API (#8622)
Browse files Browse the repository at this point in the history
Refactor `test/Table_Test` to the builder API. The builder API is in a new library called `Test_New` that is alongside the old `Test` library. There will be follow-up PRs that will migrate the rest of the tests. Meanwhile, let's keep these two libraries, and merge them after the last PR.

# Important Notes
- For a brief introduction into the new API, see **Prototype 1** section in #8622 (comment)
- When executing all the tests, the behavior should be the same as with the old library. With the only exception that if `ENSO_TEST_ANSI_COLORS` env var is set, the output is more colorful than it used to be.
  • Loading branch information
Akirathan authored Jan 26, 2024
1 parent a04385a commit d0fdeca
Show file tree
Hide file tree
Showing 97 changed files with 8,930 additions and 5,315 deletions.
2 changes: 2 additions & 0 deletions build/build/src/enso.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ 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::paths::ENSO_TEST_ANSI_COLORS;
use crate::postgres;
use crate::postgres::EndpointConfiguration;
use crate::postgres::Postgresql;
Expand Down Expand Up @@ -121,6 +122,7 @@ impl BuiltEnso {
ENSO_META_TEST_ARGS.set(&format!("{} --run", ir_caches.flag()))?;

ENSO_ENABLE_ASSERTIONS.set("true")?;
ENSO_TEST_ANSI_COLORS.set("true")?;

// Prepare Engine Test Environment
if let Ok(gdoc_key) = std::env::var("GDOC_KEY") {
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 @@ -33,6 +33,9 @@ ide_ci::define_env_var! {
/// If Enso-specific assertions should be enabled.
ENSO_ENABLE_ASSERTIONS, String;

/// If true, enso tests output will be colored.
ENSO_TEST_ANSI_COLORS, String;

/// Can be set to `"espresso"` to enable Espresso interpreter support.
ENSO_JAVA, String;
}
Expand Down
10 changes: 10 additions & 0 deletions distribution/lib/Standard/Test_New/0.0.0-dev/package.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: Test_New
namespace: Standard
version: 0.0.0-dev
license: APLv2
authors:
- name: Enso Team
email: [email protected]
maintainers:
- name: Enso Team
email: [email protected]
11 changes: 11 additions & 0 deletions distribution/lib/Standard/Test_New/0.0.0-dev/src/Clue.enso
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
private

## PRIVATE
type Clue
## PRIVATE

Represents a clue as to why a test failed

Arguments:
- add_clue: either Nothing or a function which modifies a failure message
Value add_clue
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from Standard.Base import all
import Standard.Base.Runtime.Context

import project.Test.Test

## PRIVATE
Runs the action twice, once with the Output context enabled and once with it
disabled, to check that the behaviour is the same regardless of context.
run_with_and_without_output ~action =
Context.Output.with_enabled <|
Test.with_clue "(normal mode - Output context enabled) " <|
action
Context.Output.with_disabled <|
Test.with_clue "(dry run - Output context disabled) " <|
action
Loading

0 comments on commit d0fdeca

Please sign in to comment.