예제 #1
0
def main():
    options, requested_paths, excluded_paths = parse_args()
    if options.js_shell is not None and not isfile(options.js_shell):
        print('Could not find shell at given path.')
        return 1
    skip_list, test_list = load_tests(options, requested_paths, excluded_paths)

    if not test_list:
        print('no tests selected')
        return 1

    test_dir = dirname(abspath(__file__))

    if options.debug:
        if len(test_list) > 1:
            print('Multiple tests match command line arguments,'
                  ' debugger can only run one')
            for tc in test_list:
                print('    {}'.format(tc.path))
            return 2

        cmd = test_list[0].get_command(TestCase.js_cmd_prefix)
        if options.show_cmd:
            print(list2cmdline(cmd))
        if test_dir not in ('', '.'):
            os.chdir(test_dir)
        call(cmd)
        return 0

    curdir = os.getcwd()
    if test_dir not in ('', '.'):
        os.chdir(test_dir)

    # Force Pacific time zone to avoid failures in Date tests.
    os.environ['TZ'] = 'PST8PDT'
    # Force date strings to English.
    os.environ['LC_TIME'] = 'en_US.UTF-8'

    results = None
    try:
        results = ResultsSink(options, len(skip_list) + len(test_list))
        for t in skip_list:
            results.push(NullTestOutput(t))
        run_tests(options, test_list, results)
    finally:
        os.chdir(curdir)

    if results is None or not results.all_passed():
        return 1

    return 0
예제 #2
0
def main():
    options, requested_paths, excluded_paths = parse_args()
    if options.js_shell is not None and not isfile(options.js_shell):
        print('Could not find shell at given path.')
        return 1
    skip_list, test_list = load_tests(options, requested_paths, excluded_paths)

    if not test_list:
        print('no tests selected')
        return 1

    test_dir = dirname(abspath(__file__))

    if options.debug:
        if len(test_list) > 1:
            print('Multiple tests match command line arguments,'
                  ' debugger can only run one')
            for tc in test_list:
                print('    {}'.format(tc.path))
            return 2

        cmd = test_list[0].get_command(TestCase.js_cmd_prefix)
        if options.show_cmd:
            print(list2cmdline(cmd))
        if test_dir not in ('', '.'):
            os.chdir(test_dir)
        call(cmd)
        return 0

    curdir = os.getcwd()
    if test_dir not in ('', '.'):
        os.chdir(test_dir)

    # Force Pacific time zone to avoid failures in Date tests.
    os.environ['TZ'] = 'PST8PDT'
    # Force date strings to English.
    os.environ['LC_TIME'] = 'en_US.UTF-8'

    results = None
    try:
        results = ResultsSink(options, len(skip_list) + len(test_list))
        for t in skip_list:
            results.push(NullTestOutput(t))
        run_tests(options, test_list, results)
    finally:
        os.chdir(curdir)

    if results is None or not results.all_passed():
        return 1

    return 0
예제 #3
0
def main():
    options, requested_paths, excluded_paths = parse_args()
    skip_list, test_list = load_tests(options, requested_paths, excluded_paths)

    if not test_list:
        print("no tests selected")
        return 1

    test_dir = dirname(abspath(__file__))

    if options.debug:
        if len(test_list) > 1:
            print("Multiple tests match command line arguments, debugger can only run one")
            for tc in test_list:
                print("    %s" % tc.path)
            return 2

        cmd = test_list[0].get_command(TestCase.js_cmd_prefix)
        if options.show_cmd:
            print(list2cmdline(cmd))
        if test_dir not in ("", "."):
            os.chdir(test_dir)
        call(cmd)
        return 0

    curdir = os.getcwd()
    if test_dir not in ("", "."):
        os.chdir(test_dir)

    # Force Pacific time zone to avoid failures in Date tests.
    os.environ["TZ"] = "PST8PDT"

    results = None
    try:
        results = ResultsSink(options, len(skip_list) + len(test_list))
        for t in skip_list:
            results.push(NullTestOutput(t))
        run_tests(options, test_list, results)
    finally:
        os.chdir(curdir)

    if results is None or not results.all_passed():
        return 1

    return 0
예제 #4
0
def main():
    options, requested_paths, excluded_paths = parse_args()
    skip_list, test_list = load_tests(options, requested_paths, excluded_paths)

    if not test_list:
        print 'no tests selected'
        return 1

    test_dir = os.path.dirname(os.path.abspath(__file__))

    if options.debug:
        if len(test_list) > 1:
            print(
                'Multiple tests match command line arguments, debugger can only run one'
            )
            for tc in test_list:
                print('    %s' % tc.path)
            return 2

        cmd = test_list[0].get_command(TestCase.js_cmd_prefix)
        if options.show_cmd:
            print list2cmdline(cmd)
        if test_dir not in ('', '.'):
            os.chdir(test_dir)
        call(cmd)
        return 0

    curdir = os.getcwd()
    if test_dir not in ('', '.'):
        os.chdir(test_dir)

    results = None
    try:
        results = ResultsSink(options, len(skip_list) + len(test_list))
        for t in skip_list:
            results.push(NullTestOutput(t))
        run_tests(options, test_list, results)
    finally:
        os.chdir(curdir)

    if results is None or not results.all_passed():
        return 1

    return 0
예제 #5
0
def main():
    options, prefix, requested_paths, excluded_paths = parse_args()
    if options.js_shell is not None and not (isfile(options.js_shell) and
                                             os.access(options.js_shell, os.X_OK)):
        if (platform.system() != 'Windows' or
            isfile(options.js_shell) or not
            isfile(options.js_shell + ".exe") or not
            os.access(options.js_shell + ".exe", os.X_OK)):
           print('Could not find executable shell: ' + options.js_shell)
           return 1

    test_count, test_gen = load_tests(options, requested_paths, excluded_paths)
    test_environment = get_environment_overlay(options.js_shell)

    if test_count == 0:
        print('no tests selected')
        return 1

    test_dir = dirname(abspath(__file__))

    if options.debug:
        tests = list(test_gen)
        if len(tests) > 1:
            print('Multiple tests match command line arguments,'
                  ' debugger can only run one')
            for tc in tests:
                print('    {}'.format(tc.path))
            return 2

        cmd = tests[0].get_command(prefix)
        if options.show_cmd:
            print(list2cmdline(cmd))
        with changedir(test_dir), change_env(test_environment):
            call(cmd)
        return 0

    with changedir(test_dir), change_env(test_environment):
        results = ResultsSink(options, test_count)
        try:
            for out in run_all_tests(test_gen, prefix, results.pb, options):
                results.push(out)
            results.finish(True)
        except KeyboardInterrupt:
            results.finish(False)

        return 0 if results.all_passed() else 1

    return 0
예제 #6
0
def main():
    options, requested_paths, excluded_paths = parse_args()
    skip_list, test_list = load_tests(options, requested_paths, excluded_paths)

    if not test_list:
        print 'no tests selected'
        return 1

    test_dir = dirname(abspath(__file__))

    if options.debug:
        if len(test_list) > 1:
            print('Multiple tests match command line arguments, debugger can only run one')
            for tc in test_list:
                print('    %s'%tc.path)
            return 2

        cmd = test_list[0].get_command(TestCase.js_cmd_prefix)
        if options.show_cmd:
            print list2cmdline(cmd)
        if test_dir not in ('', '.'):
            os.chdir(test_dir)
        call(cmd)
        return 0

    curdir = os.getcwd()
    if test_dir not in ('', '.'):
        os.chdir(test_dir)

    results = None
    try:
        results = ResultsSink(options, len(skip_list) + len(test_list))
        for t in skip_list:
            results.push(NullTestOutput(t))
        run_tests(options, test_list, results)
    finally:
        os.chdir(curdir)

    if results is None or not results.all_passed():
        return 1

    return 0
예제 #7
0
def main():
    options, prefix, requested_paths, excluded_paths = parse_args()
    if options.js_shell is not None and not isfile(options.js_shell):
        print('Could not find shell at given path.')
        return 1
    test_count, test_gen = load_tests(options, requested_paths, excluded_paths)

    if test_count == 0:
        print('no tests selected')
        return 1

    test_dir = dirname(abspath(__file__))

    if options.debug:
        if len(list(test_gen)) > 1:
            print('Multiple tests match command line arguments,'
                  ' debugger can only run one')
            for tc in test_gen:
                print('    {}'.format(tc.path))
            return 2

        cmd = test_gen[0].get_command(TestCase.js_cmd_prefix)
        if options.show_cmd:
            print(list2cmdline(cmd))
        with changedir(test_dir):
            call(cmd)
        return 0

    with changedir(test_dir):
        # Force Pacific time zone to avoid failures in Date tests.
        os.environ['TZ'] = 'PST8PDT'
        # Force date strings to English.
        os.environ['LC_TIME'] = 'en_US.UTF-8'

        results = ResultsSink(options, test_count)
        try:
            for out in run_all_tests(test_gen, prefix, results, options):
                results.push(out)
            results.finish(True)
        except KeyboardInterrupt:
            results.finish(False)

        return 0 if results.all_passed() else 1

    return 0
예제 #8
0
def main():
    options, prefix, requested_paths, excluded_paths = parse_args()
    if options.js_shell is not None and not (isfile(options.js_shell) and
                                             os.access(options.js_shell, os.X_OK)):
        if (platform.system() != 'Windows' or
            isfile(options.js_shell) or not
            isfile(options.js_shell + ".exe") or not
            os.access(options.js_shell + ".exe", os.X_OK)):
           print('Could not find executable shell: ' + options.js_shell)
           return 1

    test_count, test_gen = load_tests(options, requested_paths, excluded_paths)
    test_environment = get_environment_overlay(options.js_shell)

    if test_count == 0:
        print('no tests selected')
        return 1

    test_dir = dirname(abspath(__file__))

    if options.debug:
        tests = list(test_gen)
        if len(tests) > 1:
            print('Multiple tests match command line arguments,'
                  ' debugger can only run one')
            for tc in tests:
                print('    {}'.format(tc.path))
            return 2

        cmd = tests[0].get_command(prefix)
        if options.show_cmd:
            print(list2cmdline(cmd))
        with changedir(test_dir), change_env(test_environment):
            call(cmd)
        return 0

    with changedir(test_dir), change_env(test_environment):
        results = ResultsSink(options, test_count)
        try:
            for out in run_all_tests(test_gen, prefix, results.pb, options):
                results.push(out)
            results.finish(True)
        except KeyboardInterrupt:
            results.finish(False)

        return 0 if results.all_passed() else 1

    return 0
예제 #9
0
파일: jstests.py 프로젝트: 6a68/gecko-dev
def main():
    options, prefix, requested_paths, excluded_paths = parse_args()
    if options.js_shell is not None and not isfile(options.js_shell):
        print('Could not find shell at given path.')
        return 1
    test_count, test_gen = load_tests(options, requested_paths, excluded_paths)

    if test_count == 0:
        print('no tests selected')
        return 1

    test_dir = dirname(abspath(__file__))

    if options.debug:
        tests = list(test_gen)
        if len(tests) > 1:
            print('Multiple tests match command line arguments,'
                  ' debugger can only run one')
            for tc in tests:
                print('    {}'.format(tc.path))
            return 2

        cmd = tests[0].get_command(prefix)
        if options.show_cmd:
            print(list2cmdline(cmd))
        with changedir(test_dir):
            call(cmd)
        return 0

    with changedir(test_dir):
        # Force Pacific time zone to avoid failures in Date tests.
        os.environ['TZ'] = 'PST8PDT'
        # Force date strings to English.
        os.environ['LC_TIME'] = 'en_US.UTF-8'

        results = ResultsSink(options, test_count)
        try:
            for out in run_all_tests(test_gen, prefix, results, options):
                results.push(out)
            results.finish(True)
        except KeyboardInterrupt:
            results.finish(False)

        return 0 if results.all_passed() else 1

    return 0
예제 #10
0
def main():
    options, prefix, requested_paths, excluded_paths = parse_args()
    if options.js_shell is not None and not isfile(options.js_shell):
        print("Could not find shell at given path.")
        return 1
    test_list = load_tests(options, requested_paths, excluded_paths)

    if not test_list:
        print("no tests selected")
        return 1

    test_dir = dirname(abspath(__file__))

    if options.debug:
        if len(test_list) > 1:
            print("Multiple tests match command line arguments," " debugger can only run one")
            for tc in test_list:
                print("    {}".format(tc.path))
            return 2

        cmd = test_list[0].get_command(TestCase.js_cmd_prefix)
        if options.show_cmd:
            print(list2cmdline(cmd))
        with changedir(test_dir):
            call(cmd)
        return 0

    with changedir(test_dir):
        # Force Pacific time zone to avoid failures in Date tests.
        os.environ["TZ"] = "PST8PDT"
        # Force date strings to English.
        os.environ["LC_TIME"] = "en_US.UTF-8"

        results = ResultsSink(options, len(test_list))
        try:
            for out in run_all_tests(test_list, prefix, results, options):
                results.push(out)
            results.finish(True)
        except KeyboardInterrupt:
            results.finish(False)

        return 0 if results.all_passed() else 1

    return 0
예제 #11
0
def main():
    options, prefix, requested_paths, excluded_paths = parse_args()
    if options.js_shell is not None and not (isfile(
            options.js_shell) and os.access(options.js_shell, os.X_OK)):
        if (platform.system() != 'Windows' or isfile(options.js_shell)
                or not isfile(options.js_shell + ".exe")
                or not os.access(options.js_shell + ".exe", os.X_OK)):
            print('Could not find executable shell: ' + options.js_shell)
            return 1

    test_count, test_gen = load_tests(options, requested_paths, excluded_paths)
    test_environment = get_environment_overlay(options.js_shell)

    if test_count == 0:
        print('no tests selected')
        return 1

    test_dir = dirname(abspath(__file__))

    if options.debug:
        if test_count > 1:
            print('Multiple tests match command line arguments,'
                  ' debugger can only run one')
            for tc in test_gen:
                print('    {}'.format(tc.path))
            return 2

        cmd = next(test_gen).get_command(prefix)
        if options.show_cmd:
            print(list2cmdline(cmd))
        with changedir(test_dir), change_env(test_environment):
            call(cmd)
        return 0

    # The test_gen generator is converted into a list in
    # run_all_tests. Go ahead and do it here so we can apply
    # chunking.
    #
    # If chunking is enabled, determine which tests are part of this chunk.
    # This code was adapted from testing/mochitest/runtestsremote.py.
    if options.total_chunks > 1:
        tests_per_chunk = math.ceil(test_count / float(options.total_chunks))
        start = int(round((options.this_chunk - 1) * tests_per_chunk))
        end = int(round(options.this_chunk * tests_per_chunk))
        test_gen = list(test_gen)[start:end]

    if options.remote:
        results = ResultsSink('jstests', options, test_count)
        try:
            from lib.remote import init_remote_dir, init_device
            device = init_device(options)
            jtd_tests = posixpath.join(options.remote_test_root, 'tests',
                                       'tests')
            init_remote_dir(device, jtd_tests)
            device.push(test_dir, jtd_tests, timeout=600)
            device.chmod(jtd_tests, recursive=True, root=True)
            prefix[0] = options.js_shell
            for test in test_gen:
                out = run_test_remote(test, device, prefix, options)
                results.push(out)
            results.finish(True)
        except KeyboardInterrupt:
            results.finish(False)

        return 0 if results.all_passed() else 1

    with changedir(test_dir), change_env(test_environment):
        results = ResultsSink('jstests', options, test_count)
        try:
            for out in run_all_tests(test_gen, prefix, results.pb, options):
                results.push(out)
            results.finish(True)
        except KeyboardInterrupt:
            results.finish(False)

        return 0 if results.all_passed() else 1

    return 0