Esempio n. 1
0
    def checkExecutableCommand(command):
        """ Check if a command is executable. """

        # Many cases, pylint: disable=too-many-branches,too-many-return-statements

        # Do respect given options to disable specific Python versions
        if command == "python2.6" and options.no26:
            return False
        if command == "python2.7" and options.no27:
            return False
        if command == "python3.3" and options.no33:
            return False
        if command == "python3.4" and options.no34:
            return False
        if command == "python3.5" and options.no35:
            return False
        if command == "python3.6" and options.no36:
            return False
        if command == "python3.7" and options.no37:
            return False

        # Shortcuts for python versions, also needed for Windows as it won't have
        # the version number in the Python binaries at all.
        if command == "python2.6" and sys.version_info[0:2] == (2, 6):
            return True
        if command == "python2.7" and sys.version_info[0:2] == (2, 7):
            return True
        if command == "python3.3" and sys.version_info[0:2] == (3, 3):
            return True
        if command == "python3.4" and sys.version_info[0:2] == (3, 4):
            return True
        if command == "python3.5" and sys.version_info[0:2] == (3, 5):
            return True
        if command == "python3.6" and sys.version_info[0:2] == (3, 6):
            return True
        if command == "python3.7" and sys.version_info[0:2] == (3, 7):
            return True

        path = os.environ["PATH"]

        suffixes = (".exe",) if os.name == "nt" else ("",)

        for part in path.split(os.pathsep):
            if not part:
                continue

            for suffix in suffixes:
                if os.path.exists(os.path.join(part, command + suffix)):
                    return True

        if os.name == "nt":
            if command.startswith("python"):
                remainder = command[6:]

                if len(remainder) == 3 and remainder[1] == ".":
                    command = getPythonExePathWindows(search=remainder, arch=None)

                    return True

        return False
Esempio n. 2
0
    def checkExecutableCommand(command):
        """ Check if a command is executable. """

        # Many cases, pylint: disable=too-many-branches,too-many-return-statements

        # Do respect given options to disable specific Python versions
        if command == "python2.6" and options.no26:
            return False
        if command == "python2.7" and options.no27:
            return False
        if command == "python3.3" and options.no33:
            return False
        if command == "python3.4" and options.no34:
            return False
        if command == "python3.5" and options.no35:
            return False
        if command == "python3.6" and options.no36:
            return False
        if command == "python3.7" and options.no37:
            return False

        # Shortcuts for python versions, also needed for Windows as it won't have
        # the version number in the Python binaries at all.
        if command == "python2.6" and sys.version_info[0:2] == (2, 6):
            return True
        if command == "python2.7" and sys.version_info[0:2] == (2, 7):
            return True
        if command == "python3.3" and sys.version_info[0:2] == (3, 3):
            return True
        if command == "python3.4" and sys.version_info[0:2] == (3, 4):
            return True
        if command == "python3.5" and sys.version_info[0:2] == (3, 5):
            return True
        if command == "python3.6" and sys.version_info[0:2] == (3, 6):
            return True
        if command == "python3.7" and sys.version_info[0:2] == (3, 7):
            return True

        path = os.environ["PATH"]

        suffixes = (".exe",) if os.name == "nt" else ("",)

        for part in path.split(os.pathsep):
            if not part:
                continue

            for suffix in suffixes:
                if os.path.exists(os.path.join(part, command + suffix)):
                    return True

        if os.name == "nt":
            if command.startswith("python"):
                remainder = command[6:]

                if len(remainder) == 3 and remainder[1] == ".":
                    command = getPythonExePathWindows(search=remainder, arch=None)

                    return True

        return False
Esempio n. 3
0
    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))
            setExtraFlags(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))
            setExtraFlags(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))
            setExtraFlags(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))
            setExtraFlags(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))
            setExtraFlags(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))
                setExtraFlags(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))
            setExtraFlags(None, "standalone", flags)
            executeSubTest("./tests/standalone/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))
            setExtraFlags(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))

                    setExtraFlags(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))
                        setExtraFlags(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 os.path.exists("./tests/CPython32/run_all.py"):
                    if options.cpython32:
                        setExtraFlags(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 os.path.exists("./tests/CPython33/run_all.py"):
                    if options.cpython33:
                        setExtraFlags(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 os.path.exists("./tests/CPython34/run_all.py"):
                    if options.cpython34:
                        setExtraFlags(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 os.path.exists("./tests/CPython35/run_all.py"):
                    if options.cpython35:
                        setExtraFlags(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 os.path.exists("./tests/CPython36/run_all.py"):
                    if options.cpython36:
                        setExtraFlags(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 os.path.exists("./tests/CPython37/run_all.py"):
                    if options.cpython36:
                        setExtraFlags(where, "37tests", flags)
                        executeSubTest("./tests/CPython37/run_all.py search")
                else:
                    my_print("The CPython3.7 tests are not present, not run.")

            if not use_python.startswith("python2"):
                if os.path.exists("./tests/CPython38/run_all.py"):
                    if options.cpython36:
                        setExtraFlags(where, "38tests", flags)
                        executeSubTest("./tests/CPython38/run_all.py search")
                else:
                    my_print("The CPython3.8 tests are not present, not run.")

        if "NUITKA_EXTRA_OPTIONS" in os.environ:
            del os.environ["NUITKA_EXTRA_OPTIONS"]
Esempio n. 4
0
    def execute_tests(where, use_python, flags):
        # Many cases, pylint: disable=too-many-branches,too-many-statements

        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:
            print(
                "Running the basic tests with options '%s' with %s:"
                % (flags, use_python)
            )
            setExtraFlags(where, "basics", flags)
            executeSubTest("./tests/basics/run_all.py search")

        if options.syntax_tests:
            print(
                "Running the syntax tests with options '%s' with %s:"
                % (flags, use_python)
            )
            setExtraFlags(where, "syntax", flags)
            executeSubTest("./tests/syntax/run_all.py search")

        if options.program_tests:
            print(
                "Running the program tests with options '%s' with %s:"
                % (flags, use_python)
            )
            setExtraFlags(where, "programs", flags)
            executeSubTest("./tests/programs/run_all.py search")

        if options.package_tests:
            print(
                "Running the package tests with options '%s' with %s:"
                % (flags, use_python)
            )
            setExtraFlags(where, "packages", flags)
            executeSubTest("./tests/packages/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:
                print(
                    "Running the optimizations tests with options '%s' with %s:"
                    % (flags, use_python)
                )
                setExtraFlags(where, "optimizations", flags)
                executeSubTest("./tests/optimizations/run_all.py search")

        if options.standalone_tests and not options.coverage:
            print(
                "Running the standalone tests with options '%s' with %s:"
                % (flags, use_python)
            )
            setExtraFlags(None, "standalone", flags)
            executeSubTest("./tests/standalone/run_all.py search")

        if options.reflection_test and not options.coverage:
            print(
                "Running the reflection test with options '%s' with %s:"
                % (flags, use_python)
            )
            setExtraFlags(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:
                    print(
                        "Running the CPython 2.6 tests with options '%s' with %s:"
                        % (flags, use_python)
                    )

                    setExtraFlags(where, "26tests", flags)
                    executeSubTest("./tests/CPython26/run_all.py search")
            else:
                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:
                        print(
                            "Running the CPython 2.7 tests with options '%s' with %s:"
                            % (flags, use_python)
                        )
                        setExtraFlags(where, "27tests", flags)
                        executeSubTest("./tests/CPython27/run_all.py search")
                else:
                    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 os.path.exists("./tests/CPython32/run_all.py"):
                    if options.cpython32:
                        setExtraFlags(where, "32tests", flags)
                        executeSubTest("./tests/CPython32/run_all.py search")
                else:
                    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 os.path.exists("./tests/CPython33/run_all.py"):
                    if options.cpython33:
                        setExtraFlags(where, "33tests", flags)
                        executeSubTest("./tests/CPython33/run_all.py search")
                else:
                    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 os.path.exists("./tests/CPython34/run_all.py"):
                    if options.cpython34:
                        setExtraFlags(where, "34tests", flags)
                        executeSubTest("./tests/CPython34/run_all.py search")
                else:
                    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 os.path.exists("./tests/CPython35/run_all.py"):
                    if options.cpython35:
                        setExtraFlags(where, "35tests", flags)
                        executeSubTest("./tests/CPython35/run_all.py search")
                else:
                    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 os.path.exists("./tests/CPython36/run_all.py"):
                    if options.cpython36:
                        setExtraFlags(where, "36tests", flags)
                        executeSubTest("./tests/CPython36/run_all.py search")
                else:
                    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 os.path.exists("./tests/CPython36/run_all.py"):
                    if options.cpython36:
                        setExtraFlags(where, "37tests", flags)
                        executeSubTest("./tests/CPython37/run_all.py search")
                else:
                    print("The CPython3.7 tests are not present, not run.")

        if "NUITKA_EXTRA_OPTIONS" in os.environ:
            del os.environ["NUITKA_EXTRA_OPTIONS"]