Skip to content

Commit

Permalink
test: add stdout to parser expectations to capture warnings/errors
Browse files Browse the repository at this point in the history
  • Loading branch information
connorjclark committed Aug 6, 2023
1 parent 69d5f16 commit f78c85e
Show file tree
Hide file tree
Showing 17 changed files with 161 additions and 4 deletions.
10 changes: 10 additions & 0 deletions tests/scripts/armos_expected.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
Compiling 'armos.zs'
Pass 1: Parsing
Pass 2: Preprocessing
Pass 3: Registration
Pass 4: Analyzing Code
Pass 5: Generating object code
Pass 6: Assembling
Success!
Compile finished with exit code '0' (success)

PUSHR d0
PUSHR REFFFC
PUSHR d2
Expand Down
10 changes: 10 additions & 0 deletions tests/scripts/bumper_expected.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
Compiling 'bumper.zs'
Pass 1: Parsing
Pass 2: Preprocessing
Pass 3: Registration
Pass 4: Analyzing Code
Pass 5: Generating object code
Pass 6: Assembling
Success!
Compile finished with exit code '0' (success)

PUSHR d0
PUSHR REFFFC
PUSHR d2
Expand Down
10 changes: 10 additions & 0 deletions tests/scripts/circle_expected.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
Compiling 'circle.zs'
Pass 1: Parsing
Pass 2: Preprocessing
Pass 3: Registration
Pass 4: Analyzing Code
Pass 5: Generating object code
Pass 6: Assembling
Success!
Compile finished with exit code '0' (success)

PUSHR d0
PUSHR d1
PUSHR d2
Expand Down
10 changes: 10 additions & 0 deletions tests/scripts/circular_motion_expected.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
Compiling 'circular_motion.zs'
Pass 1: Parsing
Pass 2: Preprocessing
Pass 3: Registration
Pass 4: Analyzing Code
Pass 5: Generating object code
Pass 6: Assembling
Success!
Compile finished with exit code '0' (success)

PUSHR d0
PUSHR d1
PUSHR d2
Expand Down
10 changes: 10 additions & 0 deletions tests/scripts/cursor_expected.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
Compiling 'cursor.zs'
Pass 1: Parsing
Pass 2: Preprocessing
Pass 3: Registration
Pass 4: Analyzing Code
Pass 5: Generating object code
Pass 6: Assembling
Success!
Compile finished with exit code '0' (success)

PUSHR d0
PUSHR REFFFC
PUSHR d2
Expand Down
10 changes: 10 additions & 0 deletions tests/scripts/errors/errors_1.zs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#option NO_ERROR_HALT on

global script Global
{
void missing_run()
{
int number = 123;
printf("hello world: %d\n", number_oops);
}
}
9 changes: 9 additions & 0 deletions tests/scripts/errors/errors_1_expected.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Compiling 'errors_1.zs'
Pass 1: Parsing
Pass 2: Preprocessing
Pass 3: Registration
Pass 4: Analyzing Code
ZQ_BUFFER Line 3 @ Column 1 - Line 10 @ Column 2 - Error S011: Script Global needs a void run() function.
ZQ_BUFFER Line 8 @ Columns 37-48 - Error S009: Variable number_oops has not been declared.
Failure!
Compile finished with exit code '11' (compiled with errors)
5 changes: 5 additions & 0 deletions tests/scripts/errors/errors_2.zs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#option NO_ERROR_HALT on

global script Global {}}}}}{{}}
{
}
5 changes: 5 additions & 0 deletions tests/scripts/errors/errors_2_expected.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Compiling 'errors_2.zs'
Pass 1: Parsing
syntax error, unexpected RBRACE, expecting end of file [ZQ_BUFFER Line 3 Column 25 '}']
Failure!
Compile finished with exit code '-1' (compiled with warnings)
10 changes: 10 additions & 0 deletions tests/scripts/hello_world_expected.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
Compiling 'hello_world.zs'
Pass 1: Parsing
Pass 2: Preprocessing
Pass 3: Registration
Pass 4: Analyzing Code
Pass 5: Generating object code
Pass 6: Assembling
Success!
Compile finished with exit code '0' (success)

PUSHV 0
PUSHR d2
PUSHR d2
Expand Down
11 changes: 11 additions & 0 deletions tests/scripts/maths_expected.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
Compiling 'maths.zs'
Pass 1: Parsing
Pass 2: Preprocessing
Pass 3: Registration
Pass 4: Analyzing Code
Pass 5: Generating object code
ZQ_BUFFER Line 12 @ Columns 40-48 - Warning C020: Constant 10000000 is too long and has been truncated.
Pass 6: Assembling
Success!
Compile finished with exit code '0' (success)

PUSHR REFFFC
PUSHR d2
PUSHR d2
Expand Down
10 changes: 10 additions & 0 deletions tests/scripts/modify_input_expected.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
Compiling 'modify_input.zs'
Pass 1: Parsing
Pass 2: Preprocessing
Pass 3: Registration
Pass 4: Analyzing Code
Pass 5: Generating object code
Pass 6: Assembling
Success!
Compile finished with exit code '0' (success)

PUSHR REFFFC
SETR d4,SP
SETR d2,INPUTPRESSA
Expand Down
10 changes: 10 additions & 0 deletions tests/scripts/prime_expected.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
Compiling 'prime.zs'
Pass 1: Parsing
Pass 2: Preprocessing
Pass 3: Registration
Pass 4: Analyzing Code
Pass 5: Generating object code
Pass 6: Assembling
Success!
Compile finished with exit code '0' (success)

PUSHR d0
PUSHR REFFFC
PUSHR d2
Expand Down
10 changes: 10 additions & 0 deletions tests/scripts/screen_script_expected.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
Compiling 'screen_script.zs'
Pass 1: Parsing
Pass 2: Preprocessing
Pass 3: Registration
Pass 4: Analyzing Code
Pass 5: Generating object code
Pass 6: Assembling
Success!
Compile finished with exit code '0' (success)

PUSHR d0
PUSHR d1
PUSHV 0
Expand Down
10 changes: 10 additions & 0 deletions tests/scripts/scrolling_debug_expected.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
Compiling 'scrolling_debug.zs'
Pass 1: Parsing
Pass 2: Preprocessing
Pass 3: Registration
Pass 4: Analyzing Code
Pass 5: Generating object code
Pass 6: Assembling
Success!
Compile finished with exit code '0' (success)

PUSHR REFDMAPDATA
PUSHR d2
PUSHR d2
Expand Down
10 changes: 10 additions & 0 deletions tests/scripts/std_expected.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
Compiling 'std.zs'
Pass 1: Parsing
Pass 2: Preprocessing
Pass 3: Registration
Pass 4: Analyzing Code
Pass 5: Generating object code
Pass 6: Assembling
Success!
Compile finished with exit code '0' (success)

ALLOCATEGMEMV d2,4096
SETR gd1,d2
QUIT
15 changes: 11 additions & 4 deletions tests/test_zscript.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,27 @@ def compile_script(self, script_path):
str(root_dir / 'resources/include'),
str(root_dir / 'resources/headers'),
]
zasm_path = run_target.get_build_folder() / 'out.zasm'
zasm_path.unlink(missing_ok=True)
args = [
'-input', script_path,
'-zasm', 'out.zasm',
'-include', ';'.join(include_paths),
'-unlinked'
'-unlinked',
'-delay_cassert',
]
run_target.check_run('zscript', args)
zasm = Path(run_target.get_build_folder() / 'out.zasm').read_text()
p = run_target.run('zscript', args)
stdout = p.stdout.replace(str(script_path), script_path.name)
if p.returncode:
return stdout

zasm = zasm_path.read_text()

# Remove metadata.
zasm = '\n'.join([l.strip() for l in zasm.splitlines()
if not l.startswith('#')]).strip()

return zasm
return '\n'.join([stdout, zasm])

def test_zscript_compiler_expected_zasm(self):
for script_path in test_scripts_dir.glob('*.zs'):
Expand Down

0 comments on commit f78c85e

Please sign in to comment.