Commit | Line | Data |
---|---|---|
a805b721 AT |
1 | #!/usr/local/bin/python3.6 |
2 | ||
3 | # (c) 2019 Aaron Taylor <ataylor at subgeniuskitty dot com> | |
4 | # All rights reserved. | |
5 | ||
6 | # Quick and dirty tests for the VVhitespace stdlib. | |
7 | ||
8 | import os, subprocess | |
9 | ||
10 | preprocessor = 'cpp' | |
11 | include_path = '-I../stdlib' | |
12 | cpp_temp_file = 'test.pvvs' | |
13 | compiler_path = '../vvc' | |
14 | interpreter_path = '../vvi' | |
15 | temp_file = './test.vvs' | |
16 | path_to_tests = './' | |
17 | src_extension = '.pvvs' | |
18 | ||
19 | tests = [ | |
20 | # Format: ['filename_without_extension', 'string for stdin', 'string for expected stdout'] | |
21 | ['0001_hello_world', '', 'Hello, world!\n'], | |
22 | ] | |
23 | ||
24 | for test in tests: | |
25 | subprocess.run([preprocessor, include_path, "-o", cpp_temp_file, path_to_tests + test[0] + src_extension]) | |
26 | subprocess.run([compiler_path, '-i', cpp_temp_file, '-o', temp_file]) | |
27 | result = subprocess.run([interpreter_path, '-i', temp_file], stdout=subprocess.PIPE, input=test[1].encode('utf-8')) | |
28 | if result.stdout.decode('utf-8') != test[2]: | |
29 | print('\n' + test[0]) | |
30 | else: | |
31 | print('.', end='', flush=True) | |
32 | os.remove(temp_file) | |
33 | ||
34 | print("") |