def main(): _python_version = setup() search_mode = createSearchMode() for filename in sorted(os.listdir(".")): if not os.path.isdir(filename) or filename.endswith(".build"): continue extra_flags = [ "expect_success", "remove_output", "module_mode", "two_step_execution", ] # The use of "__main__" in the test package gives a warning. if filename == "sub_package": extra_flags.append("ignore_warnings") active = search_mode.consider(dirname=None, filename=filename) if active: my_print("Consider output of recursively compiled program:", filename) filename_main = None for filename_main in os.listdir(filename): if not os.path.isdir(os.path.join(filename, filename_main)): continue if filename_main not in ("..", "."): break else: search_mode.onErrorDetected("""\ Error, no package in dir '%s' found, incomplete test case.""" % filename) extensions = [ "--include-package=%s" % os.path.basename(filename_main) ] if "--output-dir" not in os.environ.get("NUITKA_EXTRA_OPTIONS", ""): extensions.append("--output-dir=%s" % getTempDir()) with withExtendedExtraOptions(*extensions): compareWithCPython( dirname=filename, filename=filename_main, extra_flags=extra_flags, search_mode=search_mode, needs_2to3=False, ) if search_mode.abortIfExecuted(): break else: my_print("Skipping", filename) search_mode.finish()
def execute_tests(where, use_python, flags): # Many cases, pylint: disable=too-many-branches,too-many-statements my_print( "Executing test case called '%s' with CPython '%s' and extra flags '%s'." % (where, use_python, flags)) intended_version = use_python[6:] if sys.version.startswith(intended_version): os.environ["PYTHON"] = sys.executable else: if os.name == "nt": os.environ["PYTHON"] = getPythonExePathWindows( search=intended_version, arch=None) else: os.environ["PYTHON"] = getExecutablePath(use_python) if options.basic_tests: my_print("Running the basic tests with options '%s' with '%s':" % (flags, use_python)) with withExtendedExtraOptions( *getExtraFlags(where, "basics", flags)): executeSubTest("./tests/basics/run_all.py search") if options.syntax_tests: my_print("Running the syntax tests with options '%s' with '%s':" % (flags, use_python)) with withExtendedExtraOptions( *getExtraFlags(where, "syntax", flags)): executeSubTest("./tests/syntax/run_all.py search") if options.program_tests: my_print("Running the program tests with options '%s' with '%s':" % (flags, use_python)) with withExtendedExtraOptions( *getExtraFlags(where, "programs", flags)): executeSubTest("./tests/programs/run_all.py search") if options.package_tests: my_print("Running the package tests with options '%s' with '%s':" % (flags, use_python)) with withExtendedExtraOptions( *getExtraFlags(where, "packages", flags)): executeSubTest("./tests/packages/run_all.py search") if options.plugin_tests: my_print("Running the plugin tests with options '%s' with '%s':" % (flags, use_python)) with withExtendedExtraOptions( *getExtraFlags(where, "plugins", flags)): executeSubTest("./tests/plugins/run_all.py search") # At least one Debian Jessie, these versions won't have lxml installed, so # don't run them there. Also these won't be very version dependent in their # results. if use_python != "python2.6": if options.optimization_tests: my_print( "Running the optimizations tests with options '%s' with '%s':" % (flags, use_python)) with withExtendedExtraOptions( *getExtraFlags(where, "optimizations", flags)): executeSubTest("./tests/optimizations/run_all.py search") if options.standalone_tests and not options.coverage: my_print( "Running the standalone tests with options '%s' with '%s':" % (flags, use_python)) with withExtendedExtraOptions( *getExtraFlags(None, "standalone", flags)): executeSubTest("./tests/standalone/run_all.py search") if options.onefile_tests and not options.coverage: my_print( "Running the standalone tests with options '%s' with '%s':" % (flags, use_python)) with withExtendedExtraOptions( *getExtraFlags(None, "onefile", flags)): executeSubTest("./tests/onefile/run_all.py search") if options.reflection_test and not options.coverage: my_print( "Running the reflection test with options '%s' with '%s':" % (flags, use_python)) with withExtendedExtraOptions( *getExtraFlags(None, "reflected", flags)): executeSubTest("./tests/reflected/compile_itself.py search") if not use_python.startswith("python3"): if os.path.exists("./tests/CPython26/run_all.py"): if options.cpython26: my_print( "Running the CPython 2.6 tests with options '%s' with '%s':" % (flags, use_python)) with withExtendedExtraOptions( *getExtraFlags(where, "26tests", flags)): executeSubTest("./tests/CPython26/run_all.py search") else: my_print("The CPython2.6 tests are not present, not run.") # Running the Python 2.7 test suite with CPython 2.6 gives little # insight, because "importlib" will not be there and that's it. if use_python != "python2.6": if os.path.exists("./tests/CPython27/run_all.py"): if options.cpython27: my_print( "Running the CPython 2.7 tests with options '%s' with '%s':" % (flags, use_python)) with withExtendedExtraOptions( *getExtraFlags(where, "27tests", flags)): executeSubTest( "./tests/CPython27/run_all.py search") else: my_print("The CPython2.7 tests are not present, not run.") if "--debug" not in flags: # Not running the Python 3.2 test suite with CPython2.6, as that's about # the same as CPython2.7 and won't have any new insights. if use_python not in ("python2.6", "python2.7") or not options.coverage: if options.cpython32: if os.path.exists("./tests/CPython32/run_all.py"): with withExtendedExtraOptions( *getExtraFlags(where, "32tests", flags)): executeSubTest( "./tests/CPython32/run_all.py search") else: my_print( "The CPython3.2 tests are not present, not run.") # Running the Python 3.3 test suite only with CPython3.x. if not use_python.startswith("python2"): if options.cpython33: if os.path.exists("./tests/CPython33/run_all.py"): with withExtendedExtraOptions( *getExtraFlags(where, "33tests", flags)): executeSubTest( "./tests/CPython33/run_all.py search") else: my_print( "The CPython3.3 tests are not present, not run.") # Running the Python 3.4 test suite only with CPython3.x. if not use_python.startswith("python2"): if options.cpython34: if os.path.exists("./tests/CPython34/run_all.py"): with withExtendedExtraOptions( *getExtraFlags(where, "34tests", flags)): executeSubTest( "./tests/CPython34/run_all.py search") else: my_print( "The CPython3.4 tests are not present, not run.") # Running the Python 3.5 test suite only with CPython3.x. if not use_python.startswith("python2"): if options.cpython35: if os.path.exists("./tests/CPython35/run_all.py"): with withExtendedExtraOptions( *getExtraFlags(where, "35tests", flags)): executeSubTest( "./tests/CPython35/run_all.py search") else: my_print( "The CPython3.5 tests are not present, not run.") # Running the Python 3.6 test suite only with CPython3.x. if not use_python.startswith("python2"): if options.cpython36: if os.path.exists("./tests/CPython36/run_all.py"): with withExtendedExtraOptions( *getExtraFlags(where, "36tests", flags)): executeSubTest( "./tests/CPython36/run_all.py search") else: my_print( "The CPython3.6 tests are not present, not run.") # Running the Python 3.7 test suite only with CPython3.x. if not use_python.startswith("python2"): if options.cpython37: if os.path.exists("./tests/CPython37/run_all.py"): with withExtendedExtraOptions( *getExtraFlags(where, "37tests", flags)): executeSubTest( "./tests/CPython37/run_all.py search") else: my_print( "The CPython3.7 tests are not present, not run.") # Running the Python 3.8 test suite only with CPython3.x. if not use_python.startswith("python2"): if options.cpython38: if os.path.exists("./tests/CPython38/run_all.py"): with withExtendedExtraOptions( *getExtraFlags(where, "38tests", flags)): executeSubTest( "./tests/CPython38/run_all.py search") else: my_print( "The CPython3.8 tests are not present, not run.") # Running the Python 3.9 test suite only with CPython3.x. if not use_python.startswith("python2"): if options.cpython39: if os.path.exists("./tests/CPython39/run_all.py"): with withExtendedExtraOptions( *getExtraFlags(where, "39tests", flags)): executeSubTest( "./tests/CPython39/run_all.py search") else: my_print( "The CPython3.9 tests are not present, not run.")
active = search_mode.consider(dirname=None, filename=filename) if active: my_print("Consider output of recursively compiled program:", filename) for filename_main in os.listdir(filename): if not os.path.isdir(os.path.join(filename, filename_main)): continue if filename_main not in ("..", '.'): break else: sys.exit("""\ Error, no package in dir '%s' found, incomplete test case.""" % filename) extensions = ["--include-package=%s" % os.path.basename(filename_main)] if not "--output-dir" in os.environ.get("NUITKA_EXTRA_OPTIONS", ""): extensions.append("--output-dir=%s" % getTempDir()) with withExtendedExtraOptions(*extensions): compareWithCPython(dirname=filename, filename=filename_main, extra_flags=extra_flags, search_mode=search_mode, needs_2to3=False) else: my_print("Skipping", filename) search_mode.finish()
if not os.path.isdir(os.path.join(filename, filename_main)): continue if filename_main not in ("..", '.'): break else: sys.exit( """\ Error, no package in dir '%s' found, incomplete test case.""" % filename ) extensions = [ "--include-package=%s" % os.path.basename(filename_main) ] if not "--output-dir" in os.environ.get("NUITKA_EXTRA_OPTIONS", ""): extensions.append("--output-dir=%s" % getTempDir()) with withExtendedExtraOptions(*extensions): compareWithCPython( dirname = filename, filename = filename_main, extra_flags = extra_flags, search_mode = search_mode, needs_2to3 = False ) else: my_print("Skipping", filename) search_mode.finish()