Skip to content

Commit 4c87690

Browse files
authored
Merge pull request #751 from boriel-basic/refact/move_preproc_test_to_their_own_folder
refact: move zxbpp test to zxbpp/ subfolder
2 parents effcd43 + 5b64902 commit 4c87690

File tree

191 files changed

+60
-326
lines changed

Some content is hidden

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

191 files changed

+60
-326
lines changed

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ repos:
33
rev: v4.6.0
44
hooks:
55
- id: check-yaml
6-
exclude: \.bin$
6+
exclude: \.(bin|out)$
77
- id: end-of-file-fixer
8-
exclude: \.bin$
8+
exclude: \.(bin|out)$
99
- id: trailing-whitespace
10-
exclude: \.bin$
10+
exclude: \.(bin|out)$
1111

1212
- repo: https://github.com/astral-sh/ruff-pre-commit
1313
# Ruff version.

src/zxbpp/zxbpp.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -974,6 +974,7 @@ def entry_point(args=None):
974974
if options.arch not in arch.AVAILABLE_ARCHITECTURES:
975975
parser.error(f"Invalid architecture '{options.arch}'")
976976
return 2
977+
977978
config.OPTIONS.architecture = options.arch
978979

979980
if options.stderr:
@@ -991,6 +992,7 @@ def entry_point(args=None):
991992
output_file.write(OUTPUT)
992993
else:
993994
config.OPTIONS.stdout.write(OUTPUT)
995+
994996
return result
995997

996998

tests/functional/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ test_:
1212
pytest . -k 'test_errmsg or test_cmdline'
1313

1414
prepro:
15-
./test.py *.bi
15+
./test.py zxbpp/*.bi
1616

1717
asm:
1818
./test.py asm/*.asm

tests/functional/prepro21.bi

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

tests/functional/prepro72.bi

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

tests/functional/test.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -271,13 +271,16 @@ def updateTest(tfname: str, pattern_: str | None, strip_blanks: bool = True) ->
271271

272272
@src.api.utils.timeout(_timeout)
273273
def testPREPRO(
274-
fname: str, pattern_: str | None = None, inline: bool | None = None, cmdline_args: list[str] | None = None
274+
preproc_file_path: str,
275+
pattern_: str | None = None,
276+
inline: bool | None = None,
277+
cmdline_args: list[str] | None = None,
275278
) -> bool | None:
276279
"""Test preprocessing file. Test is done by preprocessing the file and then
277280
comparing the output against an expected one. The output file can optionally be filtered
278281
using a filter_ regexp (see above).
279282
280-
:param fname: Filename (usually a .bi file) to test.
283+
:param preproc_file_path: Filename (usually a .bi file) to test.
281284
:param pattern_: regexp for filtering output before comparing. It will be ignored for binary (tzx, tap, etc) files
282285
:param inline: whether the test should be run inline or using the system shell
283286
:return: True on success false if not
@@ -290,21 +293,19 @@ def testPREPRO(
290293
if cmdline_args is None:
291294
cmdline_args = []
292295

293-
tfname = os.path.join(TEMP_DIR, "test" + getName(fname) + os.extsep + "out")
294-
okfile = os.path.join(os.path.dirname(fname), getName(fname) + os.extsep + "out")
296+
file_dir = os.path.dirname(preproc_file_path)
295297

296-
if UPDATE:
297-
tfname = okfile
298-
if os.path.exists(okfile):
299-
os.unlink(okfile)
298+
# For the zxbpp, we *must* test from the same folder, so we remove the folder from the path.
299+
fname = f"{getName(preproc_file_path)}{os.extsep}{getExtension(preproc_file_path) or ''}"
300+
301+
tfname = os.path.join(TEMP_DIR, f"test{fname}{os.extsep}out")
302+
okfile = os.path.join(f"{getName(preproc_file_path)}{os.extsep}out")
300303

301304
prep = ["-e", "/dev/null"] if CLOSE_STDERR else ["-e", STDERR]
302305
if UPDATE:
303306
tfname = okfile
304-
if os.path.exists(okfile):
305-
os.unlink(okfile)
306307

307-
options = [os.path.basename(fname), "-o", tfname] + prep
308+
options = [fname, "-o", tfname] + prep
308309
options.extend(cmdline_args)
309310

310311
if inline:
@@ -317,7 +318,10 @@ def testPREPRO(
317318
current_path: str = os.getcwd()
318319

319320
try:
320-
os.chdir(os.path.dirname(fname) or os.curdir)
321+
os.chdir(file_dir or os.curdir)
322+
if UPDATE:
323+
if os.path.exists(okfile):
324+
os.unlink(okfile)
321325

322326
with TempTestFile(func, tfname, keep_file=UPDATE):
323327
if not UPDATE:

tests/functional/test_errmsg.txt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ dowhile1.bas:1: warning: Empty loop
1818
subcall1.bas:6: error: 'test' is a SUB not a FUNCTION
1919
>>> process_file('zx48k/subcall2.bas')
2020
subcall2.bas:6: error: 'test' is a SUB, not a FUNCTION
21-
>>> process_file('prepro05.bi')
21+
>>> process_file('zxbpp/prepro05.bi')
2222
prepro05.bi:2: warning: [W510] "test" redefined (previous definition at prepro05.bi:2)
23-
>>> process_file('prepro07.bi')
23+
>>> process_file('zxbpp/prepro07.bi')
2424
prepro07.bi:2: error: Duplicated name parameter "x"
25-
>>> process_file('prepro28.bi')
25+
>>> process_file('zxbpp/prepro28.bi')
2626
prepro28.bi:3: error: invalid directive #defien
27-
>>> process_file('builtin.bi')
27+
>>> process_file('zxbpp/builtin.bi')
2828
builtin.bi:5: warning: [W520] missing whitespace after macro name
2929
builtin.bi:16: warning: [W500] builtin macro "__FILE__" redefined
3030
builtin.bi:17: warning: [W500] builtin macro "__LINE__" redefined
@@ -176,9 +176,9 @@ due_par.bas:2: error: Syntax error. Unexpected end of line
176176
due_par.bas:4: error: Syntax error. Unexpected end of file
177177
>>> process_file('zx48k/error_array.bas')
178178
error_array.bas:3: error: Invalid assignment. Variable z$() is an array
179-
>>> process_file('prepro76.bi')
179+
>>> process_file('zxbpp/prepro76.bi')
180180
prepro76.bi:2: error: this is an intended error
181-
>>> process_file('line_asm.bi')
181+
>>> process_file('zxbpp/line_asm.bi')
182182
line_asm.bi:26: warning: this should be line 26
183183
>>> process_file('zx48k/line_err.bas')
184184
line_err.bas:5: error: Variable 'q' already declared at line_err.bas:1
@@ -224,7 +224,7 @@ do_err.bas:3: error: DO loop not closed
224224
# Test warning silencing
225225
>>> process_file('zx48k/mcleod3.bas', ['-S', '-q', '-O --expect-warnings=2'])
226226
mcleod3.bas:3: error: 'GenerateSpaces' is neither an array nor a function.
227-
>>> process_file('prepro77.bi', ['-S', '-q', '-O --expect-warnings=1'])
227+
>>> process_file('zxbpp/prepro77.bi', ['-S', '-q', '-O --expect-warnings=1'])
228228
>>> process_file('zx48k/doloop2.bas', ['-S', '-q', '-O -W110'])
229229
doloop2.bas:4: warning: [W100] Using default implicit type 'ubyte' for 'a'
230230
doloop2.bas:4: warning: [W150] Variable 'a' is never used

tests/functional/test_prepro.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import pytest
88
import test
99

10-
TEST_PATH = os.path.dirname(os.path.realpath(__file__))
10+
TEST_PATH = os.path.join(os.path.dirname(os.path.realpath(__file__)), "zxbpp")
1111

1212

1313
@pytest.mark.parametrize("fname", [os.path.join(TEST_PATH, f) for f in os.listdir(TEST_PATH) if f.endswith(".bi")])
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)