Skip to content

Commit 9046711

Browse files
committed
WIP: Experiment with using lit as a test runner
1 parent 94b70c5 commit 9046711

File tree

7 files changed

+72
-12
lines changed

7 files changed

+72
-12
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
# Ignore only the root node_modules, but not any further down the path
1616
/node_modules/
1717

18+
/tests/out/
19+
1820
# Python coverage tool output
1921
.coverage
2022
.coverage.*

requirements-dev.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,6 @@
77
flake8==3.9.0
88
flake8-unused-arguments==0.0.6
99
coverage==5.5
10-
sphinx==2.4.4
10+
sphinx==2.4.4
11+
filecheck==0.0.17
12+
lit==0.11.0.post1

tests/em-lit

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import os
2+
from lit.main import main
3+
4+
# A simple wrapper around `lit` test running. Loosely based on
5+
# llvm's llvm-lit script
6+
7+
script_dir = os.path.dirname(os.path.abspath(__file__))
8+
9+
builtin_parameters = {
10+
'config_map': {
11+
os.path.normcase(os.path.join(script_dir, 'lit/lit.cfg.py')):
12+
os.path.normcase(os.path.join(script_dir, 'lit/lit.site.cfg.py'))
13+
}
14+
}
15+
16+
print(builtin_parameters)
17+
18+
if __name__ == '__main__':
19+
main(builtin_parameters)

tests/lit/lit.cfg.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import lit.formats
2+
import re
3+
4+
config.name = "Emscripten lit tests"
5+
config.test_format = lit.formats.ShTest()
6+
7+
config.suffixes = ['.cpp', '.c']
8+
9+
config.test_source_root = config.src_root + '/tests/lit'
10+
config.test_exec_root = config.src_root + '/tests/out'
11+
12+
# Replace all Binaryen tools with their absolute paths
13+
#bin_dir = os.path.join(config.binaryen_build_root, 'bin')
14+
#for tool_file in os.listdir(bin_dir):
15+
#tool_path = config.binaryen_build_root + '/bin/' + tool_file
16+
#tool = tool_file[:-4] if tool_file.endswith('.exe') else tool_file
17+
for tool in ('emcc', 'em++', 'emar'):
18+
config.substitutions.append((re.escape(tool), config.src_root + '/' + tool))
19+
20+
# Also make the `not` and `foreach` commands available
21+
for tool in ('not', 'foreach'):
22+
tool_file = config.src_root + '/tests/lit/' + tool + '.py'
23+
python = sys.executable.replace('\\', '/')
24+
config.substitutions.append((tool, python + ' ' + tool_file))
25+
26+
print(config.substitutions)

tests/lit/lit.site.cfg.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import os
2+
3+
script_dir = os.path.dirname(os.path.abspath(__file__))
4+
config.src_root = os.path.dirname(os.path.dirname(script_dir))
5+
6+
lit_config.load_config(
7+
config, os.path.join(config.src_root, 'tests', 'lit', 'lit.cfg.py'))
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
// RUN: emcc %s -o %t.js
2+
// RUN: node %t.js | filecheck %s
3+
4+
// CHECK: 0
5+
// CHECK-NEXT: 1
6+
// CHECK-NEXT: 2
7+
// CHECK-NEXT: 3
8+
// CHECK-NEXT: 4
9+
// CHECK-NEXT: 5
10+
// CHECK-NEXT: 6
11+
// CHECK-NEXT: 7
12+
// CHECK-NEXT: 8
13+
// CHECK-NEXT: 9
14+
// CHECK-NEXT: 10
15+
116
#define _GNU_SOURCE
217

318
#include <search.h>

tests/other/test_tsearch.out

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

0 commit comments

Comments
 (0)