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

Commit 42c692d

Browse files
committed
Refactor unit/golden test framework.
1 parent ca371a7 commit 42c692d

40 files changed

Lines changed: 254 additions & 176 deletions

‎.direnv.ps1‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.\venv\Scripts\activate.ps1

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

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,31 @@
1-
name: Test examples on debug-build
1+
name: CI/CD Test Pipeline
22

33
on:
44
push:
5-
branches: [ "master" ]
65
pull_request:
7-
branches: [ "master" ]
86

97
jobs:
10-
build:
11-
runs-on: ubuntu-latest
8+
test:
9+
strategy:
10+
matrix:
11+
os: [ ubuntu-latest, windows-latest ]
12+
13+
runs-on: ${{ matrix.os }}
1214

1315
steps:
1416
- name: Checkout repository
1517
uses: actions/checkout@v4
1618

17-
- name: Build
19+
- name: Set up Python
20+
uses: actions/setup-python@v5
21+
with:
22+
python-version: "3.14"
23+
24+
- name: Build CMake project
1825
run: |
19-
bash scripts/build.sh Debug
26+
python make.py setup
27+
python make.py build
2028
2129
- name: Run Golden Tests
2230
run: |
23-
bash tests/run_tests.sh
31+
python make.py test

‎.gitignore‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ cmake-build-debug/
33
venv/
44
**__pycache__/
55
dump/
6+
.lbd_history
7+
.direnv.ps1

‎.gitlab-ci.yml‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
stages:
2+
- test
3+
4+
linux:
5+
stage: test
6+
image: python:3.12
7+
8+
before_script:
9+
- apt-get update
10+
- apt-get install -y build-essential cmake ninja-build
11+
12+
script:
13+
- python make.py setup
14+
- python make.py build
15+
- python make.py test

‎README.md‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@
1313

1414
### Setup
1515

16-
```bash
17-
bash ./scripts/build.sh
16+
```shell
17+
python make.py setup
1818
```
1919

2020
### Run Golden Tests
2121

22-
```bash
23-
bash ./tests/run_tests.sh
22+
```shell
23+
python make.py test
2424
```
2525

2626
## Samples
@@ -42,7 +42,7 @@ boolToString: Bool = \bool: Bool. (if bool "true" "false")
4242
```
4343

4444
```console
45-
$ ./cmake-build-debug/lbd -f ./examples/conditional_branching.lbd
45+
$ ./cmake-build-debug/lbd run ./examples/conditional_branching.lbd
4646
true
4747
false
4848
```
@@ -69,7 +69,7 @@ volumeOfCylinder: Float -> Float -> Float = \r: Float.
6969
```
7070

7171
```console
72-
$ ./cmake-build-debug/lbd -f ./examples/shapes.lbd
72+
$ ./cmake-build-debug/lbd run ./examples/shapes.lbd
7373
Volume of cylinder is: 785.000000
7474
```
7575

@@ -85,7 +85,7 @@ fibonacci: Any = \num: Float.
8585
```
8686

8787
```console
88-
$ ./cmake-build-debug/lbd -f ./examples/math_demos.lbd
88+
$ ./cmake-build-debug/lbd run ./examples/math_demos.lbd
8989
55.000000
9090
```
9191

‎make.py‎

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
import subprocess
2+
import sys
3+
from pathlib import Path
4+
import argparse
5+
6+
7+
def log(level, message):
8+
print(f"[{level}] {message}")
9+
10+
11+
def error(message, shouldExit=False):
12+
log("ERROR", message)
13+
if shouldExit:
14+
sys.exit(1)
15+
16+
17+
def info(message):
18+
log("INFO", message)
19+
20+
21+
BUILD_DIR = "cmake-build-debug"
22+
VENV_DIR = "venv"
23+
24+
25+
def python():
26+
venv_dir = Path(VENV_DIR)
27+
if sys.platform == "win32":
28+
return str(venv_dir / "Scripts" / "python.exe")
29+
else:
30+
return str(venv_dir / "bin" / "python")
31+
32+
33+
def subcommand_setup():
34+
build_dir = Path(BUILD_DIR)
35+
venv_dir = Path(VENV_DIR)
36+
build_dir.mkdir(parents=True, exist_ok=True)
37+
38+
subprocess.run([sys.executable, "-m", "venv", str(venv_dir)], check=True)
39+
subprocess.run([python(), "-m", "pip", "install", "-r", "requirements.dev.txt"], check=True)
40+
41+
try:
42+
subprocess.run(["cmake", "-S", ".", "-B", str(build_dir)], check=True)
43+
except subprocess.CalledProcessError as e:
44+
error(f"CMake configure failed with exit code {e.returncode}")
45+
46+
47+
def subcommand_build():
48+
build_dir = Path(BUILD_DIR)
49+
subprocess.run(["cmake", "--build", str(build_dir)], check=True)
50+
51+
52+
def subcommand_test():
53+
subprocess.run([python(), "-m", "pytest", "-v"], check=True)
54+
55+
56+
if __name__ == "__main__":
57+
parser = argparse.ArgumentParser(prog="make.py", description="Lambda Discipline build tool")
58+
subparsers = parser.add_subparsers(dest="command", required=True)
59+
subparsers.add_parser("setup", help="Create venv, install dependencies, and configure CMake")
60+
subparsers.add_parser("build", help="Build the project")
61+
subparsers.add_parser("test", help="Run tests")
62+
63+
args = parser.parse_args()
64+
match args.command:
65+
case "setup":
66+
subcommand_setup()
67+
case "build":
68+
subcommand_build()
69+
case "test":
70+
subcommand_test()

‎requirements.dev.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pytest

‎scripts/build.sh‎

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

‎scripts/commons.sh‎

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

‎scripts/setup.ps1‎

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

0 commit comments

Comments
 (0)