From caff008ff20a4ab14c1988025c762d34223170d4 Mon Sep 17 00:00:00 2001 From: Martin DeMello Date: Tue, 12 Jun 2018 15:48:00 -0700 Subject: [PATCH] test files under stdlib/2and3 with both python versions (#2222) * test files under stdlib/2and3 with both python versions --- tests/pytype_blacklist.txt | 1 + tests/pytype_test.py | 46 ++++++++++++++++++++++++-------------- 2 files changed, 30 insertions(+), 17 deletions(-) diff --git a/tests/pytype_blacklist.txt b/tests/pytype_blacklist.txt index 0881e0aa2..0939fe425 100644 --- a/tests/pytype_blacklist.txt +++ b/tests/pytype_blacklist.txt @@ -19,3 +19,4 @@ stdlib/3.4/asyncio/tasks.pyi # aliases to class constants stdlib/3/signal.pyi # parse only stdlib/3/re.pyi # parse only +stdlib/2and3/plistlib.pyi # parse only diff --git a/tests/pytype_test.py b/tests/pytype_test.py index 351c53ce5..ec7267162 100755 --- a/tests/pytype_test.py +++ b/tests/pytype_test.py @@ -174,6 +174,21 @@ def pytype_test(args): pytd_run = [] bad = [] + def _make_test(filename, major_version): + run_cmd = [ + pytype_exe, + '--module-name=%s' % _get_module_name(filename), + '--parse-pyi', + ] + if major_version == 3: + run_cmd += [ + '-V 3.6', + '--python_exe=%s' % args.python36_exe, + ] + return BinaryRun(run_cmd + [filename], + dry_run=args.dry_run, + env={"TYPESHED_HOME": dirs.typeshed}) + for root, _, filenames in os.walk(stdlib_path): for f in sorted(filenames): f = os.path.join(root, f) @@ -187,31 +202,28 @@ def pytype_test(args): running_tests = collections.deque() max_code, runs, errors = 0, 0, 0 files = pytype_run + pytd_run - total_files = len(files) + total_tests = len(files) + # Files in stdlib/2and3 get tested twice + total_tests += sum(1 for f in pytype_run if 'stdlib/2and3' in f) print("Testing files with pytype...") while 1: while files and len(running_tests) < args.num_parallel: f = files.pop() if f in pytype_run: - run_cmd = [ - pytype_exe, - '--module-name=%s' % _get_module_name(f), - '--parse-pyi' - ] - if 'stdlib/3' in f: - run_cmd += [ - '-V 3.6', - '--python_exe=%s' % args.python36_exe - ] - test_run = BinaryRun( - run_cmd + [f], - dry_run=args.dry_run, - env={"TYPESHED_HOME": dirs.typeshed}) + if 'stdlib/2and3' in f: + running_tests.append(_make_test(f, 2)) + running_tests.append(_make_test(f, 3)) + elif 'stdlib/2' in f: + running_tests.append(_make_test(f, 2)) + elif 'stdlib/3' in f: + running_tests.append(_make_test(f, 3)) + else: + print("Unrecognised stdlib path: %s" % f) elif f in pytd_run: test_run = BinaryRun([pytd_exe, f], dry_run=args.dry_run) + running_tests.append(test_run) else: raise ValueError('Unknown action for file: %s' % f) - running_tests.append(test_run) if not running_tests: break @@ -231,7 +243,7 @@ def pytype_test(args): stderr.rstrip().rsplit('\n', 1)[-1])) if runs % 25 == 0: - print(" %3d/%d with %3d errors" % (runs, total_files, errors)) + print(" %3d/%d with %3d errors" % (runs, total_tests, errors)) print('Ran pytype with %d pyis, got %d errors.' % (runs, errors)) for f, err in bad: