Skip to content

Conversation

@JukkaL
Copy link
Collaborator

@JukkaL JukkaL commented May 9, 2017

Use .2, .3 etc. as the suffixes for files in the second and later runs.

I'll add additional multi-pass test cases in separate PRs.

with open(mpath) as f:
files.append((join(base_path, fnam), f.read()))
elif p[i].id == 'stale':
elif re.match(r'stale[2-9]?$', p[i].id):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By convention we typically allow a redundant '1' (e.g. [out1] == [out]). (Or are you worried there would be multiple sections with the same pass number?)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I'll accept stale etc. as well.

if p[i].id == 'stale':
passnum = 1
else:
passnum = int(p[i].id[-1])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're limiting this to 9 passes? :-)

renamed_path = path[:-5]
if re.search(r'\.[2-9]$', path):
# Make sure new files introduced in the second and later runs are accounted for
renamed_path = path[:-2]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I see, this is why we can't have 10 or more passes...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll update to allow more than 9 passes.

if incremental == 0:
if incremental_step == 0:
# Not incremental
msg = 'Invalid type checker output ({}, line {})'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe change "Invalid" to "Unexpected" in each branch? This wording has always confused me.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do.

self.check_module_equivalence(
'rechecked',
testcase.expected_rechecked_modules,
'rechecked' + suffix,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding the suffix makes for a slightly awkward error message, "Set of rechecked1 modules does not match expected set". Especially since this refers to the difference between rechecked[1] and rechecked[2].

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll update the message to be less confusing.

m = re.search('# cmd: mypy -m ([a-zA-Z0-9_. ]+)$', program_text, flags=re.MULTILINE)
m2 = re.search('# cmd2: mypy -m ([a-zA-Z0-9_. ]+)$', program_text, flags=re.MULTILINE)
if m2 is not None and incremental == 2:
m2 = re.search('# cmd{}: mypy -m ([a-zA-Z0-9_. ]+)$'.format(incremental_step),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One would expect to be able to use "# cmd" with "# cmd2" and "# cmd3" and others together, but it seems you actually only support "# cmd" and one other. And you could spell the second one "# cmds" or "# cmdlol". Not sure if this is worth much deliberation but maybe it should match outN, staleN etc.?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that this works correctly since we include the incremental step number in the regexp, so this lets you use # cmd2 and # cmd3 together, since the function is being called once per incremental step. The name m2 is kind of confusing though. I'll refactor this code a bit to make it clearer. # cmdlol is not accepted.

-- Each test is run twice, once with a cold cache, once with a warm cache.
-- Before the tests are run the second time, any *.py.next files are copied to *.py.
-- Before the tests are run the second time, any *.py.2 files are copied to *.py
-- (and *.py.3 files for the third step, and so on).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A little awkwards wording, perhaps "Before the tests are run again, in step N any *.py.N files are ..." ? You might not need to "and *.py.3 etc." part then.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good.

Copy link
Member

@gvanrossum gvanrossum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can merge it yourself after fixing the list() thing (and waiting for tests).

expected: Optional[Set[str]], actual: Set[str]) -> None:
if expected is not None:
expected_normalized = list(sorted(expected))
actual_normalized = list(sorted(actual.difference({"__main__"})))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for list() around sorted().

@gvanrossum gvanrossum merged commit 03f9521 into master May 22, 2017
@gvanrossum gvanrossum deleted the test-multiple-passes branch May 22, 2017 22:22
gvanrossum added a commit that referenced this pull request May 23, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants