aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAnthony Pesch <inolen@gmail.com>2013-08-09 18:30:39 -0700
committerAnthony Pesch <inolen@gmail.com>2013-08-09 21:05:32 -0700
commit6036f604f5bda520212a3181eff2a46ed6d00450 (patch)
treecf9532f5c9ca85e8fda9d8924e3a6cbcace4c45c /tests
parent5c2647401735205df744bbf2e7c95f3d772fd1df (diff)
- fixed support for passing source to btest
- added force_c option to btest
Diffstat (limited to 'tests')
-rwxr-xr-xtests/runner.py16
1 files changed, 9 insertions, 7 deletions
diff --git a/tests/runner.py b/tests/runner.py
index ddee682e..95ee39da 100755
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -13706,15 +13706,17 @@ Press any key to continue.'''
self.btest(program,
reference=book_path(basename.replace('.bc', '.png')), args=args)
- def btest(self, filename, expected=None, reference=None, reference_slack=0,
+ def btest(self, filename, expected=None, reference=None, force_c=False, reference_slack=0,
args=[], outfile='test.html', message='.'): # TODO: use in all other tests
- filepath = path_from_root('tests', filename)
- temp_filepath = os.path.join(self.get_dir(), os.path.basename(filename))
+ # if we are provided the source and not a path, use that
+ filename_is_src = '\n' in filename
+ src = filename if filename_is_src else ''
+ filepath = path_from_root('tests', filename) if not filename_is_src else ('main.c' if force_c else 'main.cpp')
+ temp_filepath = os.path.join(self.get_dir(), os.path.basename(filepath))
+ if filename_is_src:
+ with open(temp_filepath, 'w') as f: f.write(src)
if not reference:
- if '\n' in filename: # if we are provided the source and not a path, use that
- src = filename
- filename = 'main.cpp'
- else:
+ if not src:
with open(filepath) as f: src = f.read()
with open(temp_filepath, 'w') as f: f.write(self.with_report_result(src))
else: