forked from Mirror/wren
Run examples as tests. Would have prevented #266
This commit is contained in:
@ -90,8 +90,8 @@ class ReservedWords is SyntaxExample {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// `foreign`, `static`
|
// `foreign`, `static`
|
||||||
foreign static bar
|
// foreign static bar
|
||||||
foreign baz(string)
|
// foreign baz(string)
|
||||||
// (Remove lines above to make this file compile)
|
// (Remove lines above to make this file compile)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -65,7 +65,7 @@ def print_line(line=None):
|
|||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
|
|
||||||
|
|
||||||
def run_test(path):
|
def run_test(path, example=False):
|
||||||
global passed
|
global passed
|
||||||
global failed
|
global failed
|
||||||
global skipped
|
global skipped
|
||||||
@ -216,7 +216,9 @@ def run_test(path):
|
|||||||
for line in out_lines:
|
for line in out_lines:
|
||||||
if sys.version_info < (3, 0):
|
if sys.version_info < (3, 0):
|
||||||
line = line.encode('utf-8')
|
line = line.encode('utf-8')
|
||||||
if expect_index >= len(expect_output):
|
if example:
|
||||||
|
pass
|
||||||
|
elif expect_index >= len(expect_output):
|
||||||
fails.append('Got output "{0}" when none was expected.'.format(line))
|
fails.append('Got output "{0}" when none was expected.'.format(line))
|
||||||
elif expect_output[expect_index][0] != line:
|
elif expect_output[expect_index][0] != line:
|
||||||
fails.append('Expected output "{0}" on line {1} and got "{2}".'.
|
fails.append('Expected output "{0}" on line {1} and got "{2}".'.
|
||||||
@ -242,10 +244,15 @@ def run_test(path):
|
|||||||
print(' ' + color.PINK + fail + color.DEFAULT)
|
print(' ' + color.PINK + fail + color.DEFAULT)
|
||||||
print('')
|
print('')
|
||||||
|
|
||||||
|
def run_example(path):
|
||||||
|
return run_test(path, example=True)
|
||||||
|
|
||||||
for dir in ['core', 'io', 'language', 'limit', 'meta']:
|
for dir in ['core', 'io', 'language', 'limit', 'meta']:
|
||||||
walk(join(WREN_DIR, 'test', dir), run_test)
|
walk(join(WREN_DIR, 'test', dir), run_test)
|
||||||
|
|
||||||
|
walk(join(WREN_DIR, 'example'), run_example)
|
||||||
|
walk(join(WREN_DIR, 'example', 'import-module'), run_example)
|
||||||
|
|
||||||
print_line()
|
print_line()
|
||||||
if failed == 0:
|
if failed == 0:
|
||||||
print('All ' + color.GREEN + str(passed) + color.DEFAULT + ' tests passed.')
|
print('All ' + color.GREEN + str(passed) + color.DEFAULT + ' tests passed.')
|
||||||
|
|||||||
Reference in New Issue
Block a user