mirror of
https://github.com/davidhalter/parso.git
synced 2025-12-10 06:31:57 +08:00
Make the diff parser use a lot of different files by default
This commit is contained in:
@@ -131,12 +131,9 @@ class FileTests:
|
|||||||
|
|
||||||
def _run(self, grammar, file_modifications, debugger, print_diffs=False):
|
def _run(self, grammar, file_modifications, debugger, print_diffs=False):
|
||||||
try:
|
try:
|
||||||
print("Checking %s" % self._path)
|
|
||||||
for i, fm in enumerate(file_modifications, 1):
|
for i, fm in enumerate(file_modifications, 1):
|
||||||
fm.run(grammar, self._code_lines, print_diff=print_diffs)
|
fm.run(grammar, self._code_lines, print_diff=print_diffs)
|
||||||
print('.', end='')
|
print('.', end='')
|
||||||
if i % 1000 == 0:
|
|
||||||
print('\n%s tries' % i)
|
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
print()
|
print()
|
||||||
except Exception:
|
except Exception:
|
||||||
@@ -192,13 +189,17 @@ def main(arguments):
|
|||||||
elif arguments['random']:
|
elif arguments['random']:
|
||||||
# A random file is used to do diff parser checks if no file is given.
|
# A random file is used to do diff parser checks if no file is given.
|
||||||
# This helps us to find errors in a lot of different files.
|
# This helps us to find errors in a lot of different files.
|
||||||
file_path_generator = find_python_files_in_tree(arguments['<path>'] or '.')
|
file_paths = list(find_python_files_in_tree(arguments['<path>'] or '.'))
|
||||||
path = next(file_path_generator)
|
max_tries = int(arguments['--maxtries'])
|
||||||
file_tests_obj = FileTests(
|
tries = 0
|
||||||
path, int(arguments['--maxtries']), int(arguments['--changes'])
|
|
||||||
)
|
|
||||||
try:
|
try:
|
||||||
file_tests_obj.run(grammar, debugger)
|
while tries < max_tries:
|
||||||
|
path = random.choice(file_paths)
|
||||||
|
print("Checking %s: %s tries" % (path, tries))
|
||||||
|
now_tries = min(1000, max_tries - tries)
|
||||||
|
file_tests_obj = FileTests(path, now_tries, int(arguments['--changes']))
|
||||||
|
file_tests_obj.run(grammar, debugger)
|
||||||
|
tries += now_tries
|
||||||
except Exception:
|
except Exception:
|
||||||
with open(redo_file, 'wb') as f:
|
with open(redo_file, 'wb') as f:
|
||||||
pickle.dump(file_tests_obj, f)
|
pickle.dump(file_tests_obj, f)
|
||||||
|
|||||||
Reference in New Issue
Block a user