X-Git-Url: https://code.kerkeslager.com/?p=fur;a=blobdiff_plain;f=integration_tests.py;h=25550f61f5f4b2c63c078d32fe8056677ef0866b;hp=8a5b8f356359ff41cbf17f69a8029ec35467ccd9;hb=7abf5e459b2ef02c8e59c05f0a83d8213ade0427;hpb=8b306504c3a04a4334d3e8de6abed6c3ce182585 diff --git a/integration_tests.py b/integration_tests.py index 8a5b8f3..25550f6 100644 --- a/integration_tests.py +++ b/integration_tests.py @@ -29,12 +29,26 @@ def add_example_output_test(filename): raise Exception('Example output "{}" did not compile'.format(filename + '.c')) try: - actual_output = subprocess.check_output(['./a.out']) + p = subprocess.Popen('./a.out', stdout=subprocess.PIPE, stderr=subprocess.PIPE) + actual_stdout, actual_stderr = p.communicate() - with open(os.path.join('examples', filename + '.output.txt'), 'rb') as f: - expected_output = f.read() + expected_stdout_path = os.path.join('examples', filename + '.stdout.txt') - self.assertEqual(expected_output, actual_output) + if os.path.isfile(expected_stdout_path): + with open(expected_stdout_path, 'rb') as f: + expected_stdout = f.read() + else: + expected_stdout = b'' + + expected_stderr_path = os.path.join('examples', filename + '.stderr.txt') + + if os.path.isfile(expected_stderr_path): + with open(expected_stderr_path, 'rb') as f: + expected_stderr = f.read() + else: + expected_stderr = b'' + + self.assertEqual(expected_stderr, actual_stderr) # We don't clean up the C file in the finally clause because it can be useful to have in case of errors os.remove(os.path.join('examples', filename + '.c')) @@ -47,7 +61,7 @@ def add_example_output_test(filename): setattr(OutputTests, 'test_' + filename, test) -class MemoryLeakTest(unittest.TestCase): +class MemoryLeakTests(unittest.TestCase): pass def add_example_memory_leak_test(filename): @@ -81,7 +95,7 @@ def add_example_memory_leak_test(filename): '--show-reachable=yes', '--num-callers=20', '--track-fds=yes', - '--error-exitcode=666', + '--error-exitcode=42', '-q', './a.out', ], @@ -100,7 +114,7 @@ def add_example_memory_leak_test(filename): except OSError: pass - setattr(MemoryLeakTest, 'test_' + filename, test) + setattr(MemoryLeakTests, 'test_' + filename, test) filenames = ( entry.name