Skip to content
This repository was archived by the owner on Oct 12, 2026. It is now read-only.

Commit 0a8a71a

Browse files
committed
test: add run_tests script for linux
1 parent 62b3fa5 commit 0a8a71a

4 files changed

Lines changed: 99 additions & 6 deletions

File tree

‎.github/workflows/cmake-ci.yml‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
- name: Install dependencies
1818
run: |
1919
sudo apt-get update
20-
sudo apt-get install -y cmake python3
20+
sudo apt-get install -y cmake
2121
2222
- name: Configure CMake
2323
run: |
@@ -27,6 +27,6 @@ jobs:
2727
run: |
2828
cmake --build cmake-build-debug --config Debug
2929
30-
- name: Run Python tests
30+
- name: Run tests
3131
run: |
32-
python3 tests/tests.py
32+
bash tests/run_tests.sh

‎README.md‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,22 @@ bash ./scripts/setup.sh
2626
. .\scripts\setup.ps1
2727
```
2828

29-
### Tests
29+
### Run Golden Tests
30+
31+
#### GNU/Linux
32+
33+
```bash
34+
bash ./tests/run_tests.sh
35+
```
36+
37+
#### Windows
3038

3139
```powershell
32-
python tests/tests.py
40+
python .\tests\tests.py
3341
```
3442

43+
> Depricated.
44+
3545
## Samples
3646

3747
Booleans and If-Then construct built entirely using Lambda Expressions.
@@ -130,4 +140,4 @@ lbd [options]
130140
- TODO: Fix tests output in README.
131141
- TODO: Step debug kind of functionality in REPL. Inside REPL, while loading a file, load one expression at a time and
132142
provide user with some feedback and actions to perform.
133-
- TODO: Make a pre-commit-hook which does not allow to push to master, if the tests are failing. Additionally, test whether the `docs/SIGNATURE.txt` is up-to-date or not.
143+
- TODO: Make a pre-commit-hook which does not allow to push to master, if the tests are failing. Additionally, test whether the `docs/SIGNATURE.txt` is up-to-date or not.

‎tests/ignore_tests.list‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
examples/std.lbd
2+
examples/test.lbd
3+
examples/aoc-24/day-01/part_02.lbd

‎tests/run_tests.sh‎

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
#!/usr/bin/env bash
2+
set -eu
3+
4+
LBD="cmake-build-debug/lbd"
5+
TESTS_DIR_PATH=$(dirname "${BASH_SOURCE[0]}")
6+
IGNORE_FILE_PATH="$TESTS_DIR_PATH/ignore_tests.list"
7+
8+
# Enable colored output, when inside TTY mode.
9+
if [ -t 1 ]; then
10+
RED="\033[0;31m"
11+
GREEN="\033[1;32m"
12+
YELLOW="\033[1;33m"
13+
BLUE="\033[0;34m"
14+
CYAN="\033[0;36m"
15+
GRAY="\033[0;90m"
16+
RESET="\033[0m"
17+
else
18+
RED=""
19+
GREEN=""
20+
YELLOW=""
21+
BLUE=""
22+
CYAN=""
23+
GRAY=""
24+
RESET=""
25+
fi
26+
27+
function log_info() { echo -e "[${BLUE}INFO${RESET}] $*"; }
28+
function log_pass() { echo -e "[${GREEN}PASS${RESET}] $*"; }
29+
function log_note() { echo -e "[${GRAY}NOTE${RESET}] $*"; }
30+
function log_fail() { echo -e "[${RED}FAIL${RESET}] $*" >&2; }
31+
function log_error() { echo -e "[${RED}ERROR${RESET}] $*" >&2; }
32+
33+
passed=0
34+
failed=0
35+
skipped=0
36+
total=0
37+
38+
while read -r source; do
39+
total=$((total+1))
40+
41+
# If file is present inside ignore list; then continue.
42+
if [ -f "$IGNORE_FILE_PATH" ] && grep -Fxq "$source" "$IGNORE_FILE_PATH"; then
43+
log_note "Skipping tests for \"$source\"."
44+
skipped=$((skipped+1))
45+
continue
46+
fi
47+
48+
rel_test_file_path="${source#examples/}"
49+
out_file_path="examples/out/${rel_test_file_path%.lbd}.out.txt"
50+
51+
if [ ! -f "$out_file_path" ]; then
52+
log_error "Missing output file \"$out_file_path\"."
53+
failed=$((failed+1))
54+
continue
55+
fi
56+
57+
start=$(date +%s%N)
58+
if diff -u <("$LBD" -f "$source") "$out_file_path"; then
59+
end=$(date +%s%N)
60+
elapsed=$(( (end - start) / 1000000 ))
61+
log_pass "Test \"$source\" passed. (${elapsed} ms)"
62+
passed=$((passed+1))
63+
else
64+
end=$(date +%s%N)
65+
elapsed=$(( (end - start) / 1000000 ))
66+
log_fail "Test \"$source\" failed. (${elapsed} ms)"
67+
failed=$((failed+1))
68+
fi
69+
done < <(find examples -name "*lbd")
70+
71+
log_info "===================="
72+
log_info "Total: $total"
73+
log_info "Passed: $passed"
74+
log_info "Failed: $failed"
75+
log_info "Skipped: $skipped"
76+
log_info "===================="
77+
78+
if [ "$failed" -ne 0 ]; then
79+
exit 1
80+
fi

0 commit comments

Comments
 (0)