Skip to content

Commit ed246e5

Browse files
authored
Run Tox tests in the Github Action CI (#49)
This patch enables running the Tox tests in Github Actions CI. It also adds some dependencies required to run the tests locally with Tox. An important change is that we move from LLVM's FileCheck implementation to a near-equivalent Python version that can be installed with pip. This will make the test suite more independent and easier to run: requiring a full LLVM monorepo checkout and a configured LLVM build just to run the LNT unit tests seems like a very cumbersome requirement. Also, this updates the documentation to reflect my current understanding of how the test suite can be run. Note that the tests are not passing at the moment, we will need to update some dependencies and fix other issues. But this gets us closer to running them, and at least we can see the progress being made in the CI.
1 parent 17a374c commit ed246e5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+143
-136
lines changed

.github/workflows/flake8_docs.yaml renamed to .github/workflows/tox.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Python Flake8, Docs, mypy
1+
name: Run Tox tests
22

33
on:
44
- push
@@ -24,3 +24,5 @@ jobs:
2424
run: tox -e docs
2525
- name: Tox mypy
2626
run: tox -e mypy
27+
- name: Tox py3
28+
run: tox -e py3

docs/developer_guide.rst

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,20 @@ all times, therefore you should run the regression tests as part of your
2424
development work-flow, just like you do when developing on other LLVM
2525
sub-projects.
2626

27-
The LNT regression tests make use of lit and other tools like FileCheck. At
28-
the moment, probably the easiest way to get them installed is to compile LLVM
29-
and use the binaries that are generated there. Assuming you've build LLVM
30-
into $LLVMBUILD, and installed lnt in $LNTINSTALL you can run the regression
31-
tests using the following command::
27+
The LNT regression tests make use of lit and other tools like [filecheck](https://github.com/AntonLydike/filecheck).
28+
To run the tests, we recomment using ``tox`` in a virtual environment::
3229

33-
PATH=$LLVMBUILD/bin:$LNTINSTALL/bin:$PATH llvm-lit -sv ./tests
30+
python3 -m venv .venv
31+
source .venv/bin/activate
32+
pip install tox
33+
tox
3434

35-
If you don't like temporary files being created in your LNT source directory,
36-
you can run the tests in a different directory too::
35+
You can also run individual unit tests with ``lit`` directly::
3736

38-
mkdir ../run_lnt_tests
39-
cd ../run_lnt_tests
40-
PATH=$LLVMBUILD/bin:$LNTINSTALL/bin:$PATH llvm-lit -sv ../lnt/tests
37+
pip install lit
38+
lit -sv ./tests
39+
40+
However, that requires manually setting up the testing environment (``filecheck``, etc).
4141

4242
For simple changes, adding a regression test and making sure all regression
4343
tests pass, is often a good enough testing approach. For some changes, the
@@ -73,4 +73,4 @@ default. You can enable them by passing additional flags to lit:
7373

7474
Example::
7575

76-
PATH=$LLVMBUILD/bin:$LNTINSTALL/bin:$PATH llvm-lit -sv -Dpostgres=1 -Dmysql=1 -Dtidylib=1 ../lnt/tests
76+
lit -sv -Dpostgres=1 -Dmysql=1 -Dtidylib=1 ./tests

tests/Formats/json.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# RUN: lnt convert --to=json %S/Inputs/test.json | FileCheck %s
2-
# RUN: lnt convert --to=json < %S/Inputs/test.json | FileCheck %s
1+
# RUN: lnt convert --to=json %S/Inputs/test.json | filecheck %s
2+
# RUN: lnt convert --to=json < %S/Inputs/test.json | filecheck %s
33

44
# CHECK: {"a": 1}

tests/Formats/plist.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# RUN: lnt convert --to=json %S/Inputs/test.plist | FileCheck %s
2-
# RUN: lnt convert --to=json < %S/Inputs/test.plist | FileCheck %s
1+
# RUN: lnt convert --to=json %S/Inputs/test.plist | filecheck %s
2+
# RUN: lnt convert --to=json < %S/Inputs/test.plist | filecheck %s
33

44
# CHECK: {"a": 1}

tests/lnttool/PostgresDB.shtest

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ lnt import "${TESTDIR}/instance" "${SHARED_INPUTS}/sample-b-small.plist" --show-
2222
#
2323
lnt updatedb "${TESTDIR}/instance" --testsuite nts --delete-run 1 \
2424
--show-sql >& "${TESTDIR}/runrm.out"
25-
# RUN: FileCheck --check-prefix CHECK-RUNRM %s < "%t.install/runrm.out"
25+
# RUN: filecheck --check-prefix CHECK-RUNRM %s < "%t.install/runrm.out"
2626

2727
# CHECK-RUNRM: DELETE FROM "NT_Sample" WHERE "NT_Sample"."ID" = %(ID)s
2828
# CHECK-RUNRM-NEXT: ({'ID': 1}, {'ID': 2})
@@ -38,7 +38,7 @@ lnt import "${TESTDIR}/instance" "${SHARED_INPUTS}/sample-a-small.plist" --show-
3838
lnt updatedb "${TESTDIR}/instance" --testsuite nts \
3939
--delete-machine "LNT SAMPLE MACHINE" \
4040
--show-sql >& "${TESTDIR}/machinerm.out"
41-
# RUN: FileCheck --check-prefix CHECK-MACHINERM %s < "%t.install/machinerm.out"
41+
# RUN: filecheck --check-prefix CHECK-MACHINERM %s < "%t.install/machinerm.out"
4242

4343
# CHECK-MACHINERM: DELETE FROM "NT_Sample" WHERE "NT_Sample"."ID" = %(ID)s
4444
# CHECK-MACHINERM-NEXT: ({'ID': 3}, {'ID': 4}, {'ID': 5})

tests/lnttool/Profile.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
# RUN: lnt profile getVersion %S/Inputs/test.lntprof | FileCheck --check-prefix=CHECK-GETVERSION %s
1+
# RUN: lnt profile getVersion %S/Inputs/test.lntprof | filecheck --check-prefix=CHECK-GETVERSION %s
22
# CHECK-GETVERSION: 1
33

4-
# RUN: lnt profile getTopLevelCounters %S/Inputs/test.lntprof | FileCheck --check-prefix=CHECK-GETTLC %s
4+
# RUN: lnt profile getTopLevelCounters %S/Inputs/test.lntprof | filecheck --check-prefix=CHECK-GETTLC %s
55
# CHECK-GETTLC: {"cycles": 12345.0, "branch-misses": 200.0}
66

7-
# RUN: lnt profile getFunctions --sortkeys %S/Inputs/test.lntprof | FileCheck --check-prefix=CHECK-GETFUNCTIONS %s
7+
# RUN: lnt profile getFunctions --sortkeys %S/Inputs/test.lntprof | filecheck --check-prefix=CHECK-GETFUNCTIONS %s
88
# CHECK-GETFUNCTIONS: {"fn1": {"counters": {"branch-misses": 10.0, "cycles": 45.0}, "length": 2}}
99

10-
# RUN: lnt profile getCodeForFunction %S/Inputs/test.lntprof fn1 | FileCheck --check-prefix=CHECK-GETFN1 %s
10+
# RUN: lnt profile getCodeForFunction %S/Inputs/test.lntprof fn1 | filecheck --check-prefix=CHECK-GETFN1 %s
1111
# CHECK-GETFN1: [{}, 1048576, "add r0, r0, r0"], [{"cycles": 100.0}, 1048580, "sub r1, r0, r0"]]
1212

1313
# RUN: mkdir -p %t

tests/lnttool/UpdateDB.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#
1010
# RUN: lnt updatedb %t.install --testsuite nts \
1111
# RUN: --delete-run 1 --show-sql >& %t.out
12-
# RUN: FileCheck --check-prefix CHECK-RUNRM %s < %t.out
12+
# RUN: filecheck --check-prefix CHECK-RUNRM %s < %t.out
1313

1414
# CHECK-RUNRM: DELETE FROM "NT_Sample" WHERE "NT_Sample"."ID" = ?
1515
# CHECK-RUNRM-NEXT: ((1,), (2,))
@@ -25,7 +25,7 @@
2525
# RUN: --show-sample-count
2626
# RUN: lnt updatedb %t.install --testsuite nts \
2727
# RUN: --delete-machine "LNT SAMPLE MACHINE" --show-sql >& %t.out
28-
# RUN: FileCheck --check-prefix CHECK-MACHINERM %s < %t.out
28+
# RUN: filecheck --check-prefix CHECK-MACHINERM %s < %t.out
2929

3030
# CHECK-MACHINERM: DELETE FROM "NT_Sample" WHERE "NT_Sample"."ID" = ?
3131
# CHECK-MACHINERM-NEXT: ((1,), (2,))

tests/lnttool/admin.shtest

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ cd "$DIR"
1212
rm -rf lntadmin.yaml
1313
lnt admin create-config > create_config.stdout
1414
mv lntadmin.yaml create_config.txt
15-
# RUN: FileCheck %s --check-prefix=CREATE_CONFIG < %t.tmp/create_config.txt
15+
# RUN: filecheck %s --check-prefix=CREATE_CONFIG < %t.tmp/create_config.txt
1616
# CREATE_CONFIG: lnt_url: "http://localhost:8000"
1717
# CREATE_CONFIG-NEXT: database: default
1818
# CREATE_CONFIG-NEXT: testsuite: nts
@@ -28,11 +28,11 @@ auth_token: test_token
2828
__EOF__
2929

3030
lnt admin post-run "${SHARED_INPUTS}/sample-a-small.plist" > post_run.stdout
31-
# RUN: FileCheck %s --check-prefix=POST_RN < %t.tmp/post_run.stdout
31+
# RUN: filecheck %s --check-prefix=POST_RN < %t.tmp/post_run.stdout
3232
# POST_RN: http://localhost:9092/api/db_default/v4/nts/runs/3
3333

3434
lnt admin machine-info 1 > machine_info.stdout
35-
# RUN: FileCheck %s --check-prefix=MACHINE_INFO < %t.tmp/machine_info.stdout
35+
# RUN: filecheck %s --check-prefix=MACHINE_INFO < %t.tmp/machine_info.stdout
3636
# MACHINE_INFO: name: localhost__clang_DEV__x86_64
3737
# MACHINE_INFO: id: 1
3838
# MACHINE_INFO: hardware: x86_64
@@ -42,7 +42,7 @@ lnt admin machine-info 1 > machine_info.stdout
4242

4343
rm -rf run_3.json
4444
lnt admin get-run 3 > get_run.stdout
45-
# RUN: FileCheck %s --check-prefix=GET_RN < %t.tmp/run_3.json
45+
# RUN: filecheck %s --check-prefix=GET_RN < %t.tmp/run_3.json
4646
# GET_RN: {
4747
# GET_RN: "generated_by":
4848
# GET_RN: "machine": {
@@ -60,18 +60,18 @@ lnt admin get-run 3 > get_run.stdout
6060
# GET_RN: }
6161

6262
lnt admin list-machines > list_machines.stdout
63-
# RUN: FileCheck %s --check-prefix=LIST_MACHINES < %t.tmp/list_machines.stdout
63+
# RUN: filecheck %s --check-prefix=LIST_MACHINES < %t.tmp/list_machines.stdout
6464
# LIST_MACHINES: localhost__clang_DEV__x86_64:1
6565
# LIST_MACHINES-NEXT: LNT SAMPLE MACHINE:2
6666

6767
lnt admin list-runs 1 > list_runs.stdout
68-
# RUN: FileCheck %s --check-prefix=LIST_RUNS < %t.tmp/list_runs.stdout
68+
# RUN: filecheck %s --check-prefix=LIST_RUNS < %t.tmp/list_runs.stdout
6969
# LIST_RUNS: llvm_project_revision=154331 1
7070
# LIST_RUNS: llvm_project_revision=152289 2
7171

7272
rm -rf machine_1.json
7373
lnt admin get-machine 1 > get_machine.stdout
74-
# RUN: FileCheck %s --check-prefix=GET_MACHINE_JSON < %t.tmp/machine_1.json
74+
# RUN: filecheck %s --check-prefix=GET_MACHINE_JSON < %t.tmp/machine_1.json
7575
# GET_MACHINE_JSON: {
7676
# GET_MACHINE_JSON: "generated_by":
7777
# GET_MACHINE_JSON: "machine": {
@@ -88,20 +88,20 @@ lnt admin get-machine 1 > get_machine.stdout
8888
# GET_MACHINE_JSON: }
8989

9090
lnt admin rm-machine 1 > rm_machine.stdout
91-
# RUN: FileCheck %s --check-prefix=RM_MACHINE < %t.tmp/rm_machine.stdout
91+
# RUN: filecheck %s --check-prefix=RM_MACHINE < %t.tmp/rm_machine.stdout
9292
# RM_MACHINE: Deleting runs 1 2 (2/2)
9393
# RM_MACHINE: Deleted machine localhost__clang_DEV__x86_64:1
9494

9595
lnt admin list-machines > list_machines2.stdout
96-
# RUN: FileCheck %s --check-prefix=LIST_MACHINES2 < %t.tmp/list_machines2.stdout
96+
# RUN: filecheck %s --check-prefix=LIST_MACHINES2 < %t.tmp/list_machines2.stdout
9797
# LIST_MACHINES2-NOT: localhost__clang_DEV__x86_64:1
9898
# LIST_MACHINES2: LNT SAMPLE MACHINE:2
9999

100100
lnt admin rename-machine 2 hal9000
101101
# No output
102102

103103
lnt admin list-machines > list_machines3.stdout
104-
# RUN: FileCheck %s --check-prefix=LIST_MACHINES3 < %t.tmp/list_machines3.stdout
104+
# RUN: filecheck %s --check-prefix=LIST_MACHINES3 < %t.tmp/list_machines3.stdout
105105
# LIST_MACHINES3: hal9000:2
106106

107107
# Just post again so we have a machine to merge

tests/lnttool/checkformat.shtest

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Check an old plist format
2-
# RUN: lnt checkformat %{shared_inputs}/sample-a-small.plist 2>&1 | FileCheck %s --check-prefix=CHECK0
2+
# RUN: lnt checkformat %{shared_inputs}/sample-a-small.plist 2>&1 | filecheck %s --check-prefix=CHECK0
33
#
44
# CHECK0: Import succeeded.
55
# CHECK0: Imported Data
@@ -14,7 +14,7 @@
1414
#
1515
#
1616
# Check an old json format
17-
# RUN: lnt checkformat %{shared_inputs}/sample-report.json 2>&1 | FileCheck %s --check-prefix=CHECK1
17+
# RUN: lnt checkformat %{shared_inputs}/sample-report.json 2>&1 | filecheck %s --check-prefix=CHECK1
1818
#
1919
# CHECK1: Import succeeded.
2020
# CHECK1: Imported Data
@@ -29,7 +29,7 @@
2929
#
3030
#
3131
# Check new-style json format
32-
# RUN: lnt checkformat %{src_root}/docs/report-example.json 2>&1 | FileCheck %s --check-prefix=CHECK2
32+
# RUN: lnt checkformat %{src_root}/docs/report-example.json 2>&1 | filecheck %s --check-prefix=CHECK2
3333
#
3434
# CHECK2: Import succeeded.
3535
# CHECK2: Imported Data
@@ -43,14 +43,14 @@
4343
# CHECK2: PASS : 10
4444
#
4545
#
46-
# RUN: lnt checkformat %S/Inputs/minimal.json 2>&1 | FileCheck %s --check-prefix=MINIMAL
46+
# RUN: lnt checkformat %S/Inputs/minimal.json 2>&1 | filecheck %s --check-prefix=MINIMAL
4747
# MINIMAL: Import succeeded.
4848
# MINIMAL: Added Machines: 1
4949
# MINIMAL: Added Runs : 1
5050
#
5151
#
5252
# Check invalid format
53-
# RUN: lnt checkformat %S/Inputs/invalid_submission0.json 2>&1 | FileCheck %s --check-prefix=CHECKFAIL0
53+
# RUN: lnt checkformat %S/Inputs/invalid_submission0.json 2>&1 | filecheck %s --check-prefix=CHECKFAIL0
5454
#
5555
# CHECKFAIL0: Import Failed:
5656
# CHECKFAIL0: could not parse input format

tests/lnttool/email_tools.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
# RUN: lnt send-run-comparison --dry-run --to [email protected] \
1111
# RUN: --from [email protected] \
12-
# RUN: --host localhost %t.instance 1 2 | FileCheck %s --check-prefix CHECK0
12+
# RUN: --host localhost %t.instance 1 2 | filecheck %s --check-prefix CHECK0
1313
#
1414
# CHECK0: From: [email protected]
1515
# CHECK0: To: [email protected]
@@ -37,7 +37,7 @@
3737

3838
# RUN: lnt send-daily-report --dry-run --from [email protected] \
3939
# RUN: --host localhost --testsuite nts --filter-machine-regex=machine.? \
40-
# RUN: %t.instance [email protected] | FileCheck %s --check-prefix CHECK1
40+
# RUN: %t.instance [email protected] | filecheck %s --check-prefix CHECK1
4141
#
4242
# CHECK1: From: [email protected]
4343
# CHECK1: To: [email protected]

0 commit comments

Comments
 (0)