Start working on the interpeter
[fur] / integration_tests.py
index b5ad321..7cc6d1a 100644 (file)
@@ -11,45 +11,38 @@ class InterpreterOutputTests(unittest.TestCase):
 
 def add_example_interpreter_output_test(filename):
     def test(self):
-        try:
-            p = subprocess.Popen(
-                'python main.py interpret {}'.format(
-                    os.path.join('examples', filename),
-                ),
-                stdout=subprocess.PIPE,
-                stderr=subprocess.PIPE,
-            )
-
-            actual_stdout, actual_stderr = p.communicate()
+        p = subprocess.Popen(
+            (
+                'python',
+                'main.py',
+                'interpret',
+                os.path.join('examples', filename),
+            ),
+            stdout=subprocess.PIPE,
+            stderr=subprocess.PIPE,
+        )
 
-            expected_stdout_path = os.path.join('examples', filename + '.stdout.txt')
-
-            if os.path.isfile(expected_stdout_path):
-                with open(expected_stdout_path, 'rb') as f:
-                    expected_stdout = f.read()
-            else:
-                expected_stdout = b''
+        actual_stdout, actual_stderr = p.communicate()
 
-            expected_stderr_path = os.path.join('examples', filename + '.stderr.txt')
+        expected_stdout_path = os.path.join('examples', filename + '.stdout.txt')
 
-            if os.path.isfile(expected_stderr_path):
-                with open(expected_stderr_path, 'rb') as f:
-                    expected_stderr = f.read()
-            else:
-                expected_stderr = b''
+        if os.path.isfile(expected_stdout_path):
+            with open(expected_stdout_path, 'rb') as f:
+                expected_stdout = f.read()
+        else:
+            expected_stdout = b''
 
-            self.assertEqual(expected_stderr, actual_stderr)
+        expected_stderr_path = os.path.join('examples', filename + '.stderr.txt')
 
-            # 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'))
+        if os.path.isfile(expected_stderr_path):
+            with open(expected_stderr_path, 'rb') as f:
+                expected_stderr = f.read()
+        else:
+            expected_stderr = b''
 
-        finally:
-            try:
-                os.remove('a.out')
-            except OSError:
-                pass
+        self.assertEqual(expected_stderr, actual_stderr)
 
-    setattr(InterpreterOutputTests, 'test_' + filename, test)
+    setattr(InterpreterOutputTests, 'test_' + filename[:-4], test)
 
 class CompilerOutputTests(unittest.TestCase):
     pass
@@ -105,7 +98,7 @@ def add_example_compiler_output_test(filename):
             except OSError:
                 pass
 
-    setattr(CompilerOutputTests, 'test_' + filename, test)
+    setattr(CompilerOutputTests, 'test_' + filename[:-4], test)
 
 class MemoryLeakTests(unittest.TestCase):
     pass
@@ -160,7 +153,7 @@ def add_example_memory_leak_test(filename):
             except OSError:
                 pass
 
-    setattr(MemoryLeakTests, 'test_' + filename, test)
+    setattr(MemoryLeakTests, 'test_' + filename[:-4], test)
 
 filenames = (
     entry.name