Skip to content

Add support for test cases with more than 2 incremental runs - #3347

Merged
gvanrossum merged 8 commits into
masterfrom
test-multiple-passes
May 22, 2017
Merged

gvanrossum merged 8 commits into
masterfrom
test-multiple-passes

Conversation

@JukkaL

@JukkaL JukkaL commented May 9, 2017

Copy link
Copy Markdown
Collaborator

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.

Comment thread mypy/test/data.py Outdated
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
Copy Markdown
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
Copy Markdown
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.

Comment thread mypy/test/data.py Outdated
if p[i].id == 'stale':
passnum = 1
else:
passnum = int(p[i].id[-1])

Copy link
Copy Markdown
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? :-)

Comment thread mypy/test/data.py
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
Copy Markdown
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
Copy Markdown
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.

Comment thread mypy/test/testcheck.py Outdated
if incremental == 0:
if incremental_step == 0:
# Not incremental
msg = 'Invalid type checker output ({}, line {})'

Copy link
Copy Markdown
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
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Will do.

Comment thread mypy/test/testcheck.py
self.check_module_equivalence(
'rechecked',
testcase.expected_rechecked_modules,
'rechecked' + suffix,

Copy link
Copy Markdown
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
Copy Markdown
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.

Comment thread mypy/test/testcheck.py Outdated
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
Copy Markdown
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
Copy Markdown
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.

Comment thread test-data/unit/check-incremental.test Outdated
-- 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
Copy Markdown
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
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Sounds good.

@gvanrossum gvanrossum left a comment

Copy link
Copy Markdown
Member

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).

Comment thread mypy/test/testcheck.py Outdated
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
Copy Markdown
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