Skip to content

Commit ca5a114

Browse files
committed
Merge branch 'test-script' into 'master'
tests: add a script that supports filtering tests See merge request picodata/brod/tarantool-module!44
2 parents 8bf0dcf + 6081f39 commit ca5a114

File tree

4 files changed

+26
-4
lines changed

4 files changed

+26
-4
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ all:
22
cargo build --all
33

44
test:
5-
tests/run_tests.lua
5+
tests/test.sh
66

77
benchmark:
88
tests/run_benchmarks.lua

tests/run_tests.lua

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,11 @@ end
4444
-- Add test runner library location to lua search path
4545
package.cpath = 'target/debug/?.so;' .. package.cpath
4646

47+
-- Prepare config
48+
json = require('json')
49+
cfg = json.encode { filter = arg[1] or "" }
50+
4751
-- Run tests
4852
local test_main = require('libtarantool_module_test_runner')
49-
local exit_code = test_main()
53+
local exit_code = test_main(cfg)
5054
os.exit(exit_code)

tests/src/lib.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,12 @@ macro_rules! tests {
4444
}
4545
}
4646

47-
#[derive(Clone, Copy, Default, Deserialize)]
47+
#[derive(Clone, Default, Deserialize)]
4848
struct TestConfig {
49+
#[serde(default)]
4950
bench: bool,
51+
52+
filter: Option<String>,
5053
}
5154

5255
fn create_test_spaces() -> Result<(), Error> {
@@ -141,7 +144,7 @@ fn run_tests(cfg: TestConfig) -> Result<bool, io::Error> {
141144
run_tests_console(
142145
&TestOpts {
143146
list: false,
144-
filter: None,
147+
filter: cfg.filter,
145148
filter_exact: false,
146149
force_run_in_process: false,
147150
exclude_should_panic: false,

tests/test.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/bash
2+
3+
set -e
4+
5+
FILTER="$1"
6+
7+
WORKSPACE_ROOT=$(
8+
cargo metadata --format-version=1 |
9+
tarantool -e \
10+
'print(require("json").decode(io.read("*l")).workspace_root)'
11+
)
12+
13+
cargo build -p tarantool-module-test-runner
14+
15+
"${WORKSPACE_ROOT}/tests/run_tests.lua" "${FILTER}"

0 commit comments

Comments
 (0)