Skip to content
This repository was archived by the owner on Jun 10, 2024. It is now read-only.

Commit 72c1d31

Browse files
committed
feat: implement lit for cli tests
1 parent cf1e94f commit 72c1d31

File tree

8 files changed

+41
-242
lines changed

8 files changed

+41
-242
lines changed

Makefile.toml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ args = ["clean"]
249249
[tasks.test]
250250
category = "Test"
251251
description = "Runs all tests"
252-
dependencies = ["test-rust", "test-cleanup"]
252+
dependencies = ["test-rust", "test-lit", "test-cleanup"]
253253

254254
[tasks.test-rust]
255255
category = "Test"
@@ -262,13 +262,22 @@ dependencies = [
262262
"require-cmake",
263263
]
264264

265+
[tasks.test-lit]
266+
category = "Test"
267+
description = "Runs file-based checks using lit"
268+
env = { RUSTFLAGS = "-Z unstable-options -C link-args=-Wl,-rpath,${LLVM_PREFIX}/lib" }
269+
script_runner = "@rust"
270+
script = { file = "${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/scripts/lit.rs", absolute_path = true }
271+
dependencies = [
272+
"lumen",
273+
]
274+
265275
[tasks.test-cleanup]
266276
private = true
267277
#condition = { env = { CARGO_MAKE_CI = "true" } }
268278
script = ['''
269279
#!@duckscript
270280
271-
rm -r ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/lumen/tests/_build
272281
rm -r ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/native_implemented/otp/tests/_build
273282
''']
274283

lumen/tests/cli.rs

Lines changed: 0 additions & 95 deletions
This file was deleted.

lumen/tests/cli/init.erl

Lines changed: 0 additions & 23 deletions
This file was deleted.

lumen/tests/global_dynamic.rs

Lines changed: 0 additions & 55 deletions
This file was deleted.

lumen/tests/global_dynamic/init.erl

Lines changed: 0 additions & 19 deletions
This file was deleted.

lumen/tests/hello_world.rs

Lines changed: 0 additions & 38 deletions
This file was deleted.

lumen/tests/hello_world/init.erl

Lines changed: 0 additions & 10 deletions
This file was deleted.

scripts/lit.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
//! ```cargo
2+
//! [dependencies]
3+
//! lit = { git = "https://github.com/lumen/lit", branch = "erlang" }
4+
//! ```
5+
6+
extern crate lit;
7+
8+
use std::env;
9+
use std::path::PathBuf;
10+
11+
const WORKSPACE_DIR: &'static str = env!("CARGO_MAKE_WORKING_DIRECTORY");
12+
13+
fn main() {
14+
let workspace_dir = PathBuf::from(WORKSPACE_DIR);
15+
let lit_dir = workspace_dir.join("test/lit");
16+
let lumen_exe = workspace_dir.join("bin/lumen");
17+
18+
lit::run::tests(lit::event_handler::Default::default(), |config| {
19+
config.add_search_path(lit_dir.to_str().unwrap());
20+
config.add_extension("erl");
21+
22+
config
23+
.constants
24+
.insert("tests".to_owned(), lit_dir.to_str().unwrap().to_string());
25+
config
26+
.constants
27+
.insert("lumen".to_owned(), lumen_exe.to_str().unwrap().to_string());
28+
})
29+
.expect("lit tests failed, see output for details")
30+
}

0 commit comments

Comments
 (0)