Skip to content

Commit 9dc88b5

Browse files
authored
chore: minor cleanup to compile script (#40)
Signed-off-by: Henry Schreiner <[email protected]>
1 parent 7a670ee commit 9dc88b5

File tree

3 files changed

+20
-14
lines changed

3 files changed

+20
-14
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,3 +158,6 @@ cython_debug/
158158
# and can be added to the global gitignore or merged into this file. For a more nuclear
159159
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
160160
#.idea/
161+
162+
/test/*/a/*
163+
/test/*/b/*

idd.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#!/usr/bin/env python3
2+
13
import argparse
24
import sys
35

test/compile_tests.py

100644100755
Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
1-
#!/usr/bin/env python
2-
# coding: utf-8
1+
#!/usr/bin/env python3
32

4-
import glob
5-
import os
6-
from os import system
7-
root_tests_dir = '.'
3+
import subprocess
4+
from pathlib import Path
85

9-
for test_dir in os.listdir(root_tests_dir):
10-
if os.path.isdir(os.path.join(root_tests_dir, test_dir)):
6+
root_tests_dir = Path(__file__).parent.resolve()
7+
prog = "g++"
8+
9+
for test_dir in root_tests_dir.iterdir():
10+
if test_dir.is_dir():
1111
print(test_dir)
12-
if not os.path.exists("{test_dir}/a".format(test_dir = test_dir)):
13-
os.makedirs("{test_dir}/a".format(test_dir = test_dir))
12+
a_dir = test_dir / "a"
13+
b_dir = test_dir / "b"
1414

15-
if not os.path.exists("{test_dir}/b".format(test_dir = test_dir)):
16-
os.makedirs("{test_dir}/b".format(test_dir = test_dir))
15+
a_dir.mkdir(exist_ok=True)
16+
b_dir.mkdir(exist_ok=True)
1717

18-
system("g++ -DV1 -o {test_d}/a/program.out -xc++ -g {test_files}".format(test_d = test_dir, test_files = ' '.join(glob.glob(test_dir + '/*.c??'))))
19-
system("g++ -DV2 -o {test_d}/b/program.out -xc++ -g {test_files}".format(test_d = test_dir, test_files = ' '.join(glob.glob(test_dir + '/*.c??'))))
18+
test_files = list(test_dir.glob('*.c??'))
19+
subprocess.run([prog, "-DV1", "-o", a_dir/"program.out", "-g", *test_files], check=True)
20+
subprocess.run([prog, "-DV2", "-o", b_dir/"program.out", "-g", *test_files], check=True)

0 commit comments

Comments
 (0)