Commits

Brett Cannon committed 817d54b

Re-arrange executable discovery code.

  • Participants
  • Parent commits 4dfc931

Comments (0)

Files changed (3)

File build_cpython.py

 import subprocess
 import sys
 
+
+def executable():
+    directory = 'cpython'
+    cmd = os.path.join(directory, 'python')
+    # UNIX
+    if not os.path.isfile(cmd):
+        # OS X
+        cmd += '.exe'
+        if not os.path.isfile(cmd):
+            # 32-bit Windows
+            cmd = os.path.join(directory, 'PCBuild', 'python_d.exe')
+            if not os.path.isfile(cmd):
+                # 64-bit Windows
+                cmd = os.path.join(directory, 'PCBuild', 'AMD64', 'python_d.exe')
+                if not os.path.isfile(cmd):
+                    return None
+    return os.path.abspath(cmd)
+
+
 def main():
     if sys.platform == 'win32':
         print("See the devguide's Getting Set Up guide for building under "
         subprocess.call(make_cmd)
     finally:
         os.chdir(cwd)
+    return executable
 
 if __name__ == '__main__':
-    main()
+    if not main():
+        print('No executable found')
+        sys.exit(1)

File make_a_box.py

 import webbrowser
 import xmlrpc.client
 import build_cpython
-import run_all_tests
 
 
 def rename(new_name):
                         url, self.directory))
 
 
+# XXX test
 @rename('coverage.py')
 class CoveragePy(HgProvider):
 
     def build(self):
         """Run coverage over CPython."""
         # Build Python
-        build_cpython.main()
+        executable = build_cpython.main()
         # Run coverage
-        executable = run_all_tests.executable()
         if not executable:
             print('No CPython executable found')
             sys.exit(1)

File run_all_tests.py

 #!/usr/bin/env python
 """Run CPython's test suite in the most rigorous way possible."""
 import multiprocessing
-import os
 import subprocess
 import sys
+import build_cpython
 
 
-def executable():
-    directory = 'cpython'
-    cmd = os.path.join(directory, 'python')
-    # UNIX
-    if not os.path.isfile(cmd):
-        # OS X
-        cmd += '.exe'
-        if not os.path.isfile(cmd):
-            # 32-bit Windows
-            cmd = os.path.join(directory, 'PCBuild', 'python_d.exe')
-            if not os.path.isfile(cmd):
-                # 64-bit Windows
-                cmd = os.path.join(directory, 'PCBuild', 'AMD64', 'python_d.exe')
-                if not os.path.isfile(cmd):
-                    return None
-    return os.path.abspath(cmd)
-
-if __name__ == '__main__':
+def main():
     cmd = executable()
     if cmd is None:
         print('CPython is not built')
     subprocess.call([cmd, '-W', 'default', '-bb', '-E', '-m', 'test', '-r',
                      '-w', '-u', 'all', '-j',
                      str(multiprocessing.cpu_count())])
+
+
+if __name__ == '__main__':
+    main()