Closed GoogleCodeExporter closed 9 years ago
Looks good to me. Feel free to commit.
One style nit: should be space after the comma in "\\","/" (two places).
Original comment by csilv...@gmail.com
on 18 Jul 2011 at 11:55
Hmm, now that I think of it, depending on how you fix issue 54 this may not
need to be changed at all. Let's hold off on this until issue 54 is resolved.
Original comment by csilv...@gmail.com
on 19 Jul 2011 at 12:02
I think in this case there will still need to be some fixup in the python code.
The os.path.join that is used in _GetAllCppFilesUnderDir to generate
cpp_files_to_check ends up inserting backslashes on Windows.
Now that IWYU is canonicalising paths (Issue 54, Issue 55), the summary text
that is generated contains forward slashes.
This means that _GetExpectedSummaries ends up creating a dictionary with keys
containing backslashes, and _GetActualSummaries ends up creating a dictionary
with keys containing forward slashes. When _CompareExpectedAndActualSummaries
comes to compare the dictionaries, it fails to match up the summaries.
There's a couple of different approaches that would work:
(1) canonicalise cpp_files_to_check (the patch above, but cc_file no longer
needs to be changed)
(2) canonicalise paths before adding entries to the dictionaries in
_GetExpectedSummaries and _CompareExpectedAndActualSummaries (probably just
needs doing in _GetExpectedSummaries)
There's possibly an even simpler solution which I've overlooked?
Original comment by paul.hol...@gmail.com
on 19 Jul 2011 at 10:34
} There's possibly an even simpler solution which I've overlooked?
How about using '/'.join() instead of os.path.join(), with a comment that iwyu
only uses / internally?
But maybe that won't work great because the inputs to os.path.join could
already have '/' in them. Maybe you could do something like 'path =
path.replace(os.sep, '/')?
I think, again, we want to make the substitution as close to the 'input' to
iwyu as we can. So I'd prefer something that normalizes sooner, rather than in
cpp_files_to_check (which is pretty late).
Original comment by csilv...@gmail.com
on 19 Jul 2011 at 11:16
It turns out that this canonicalisation can be done as early as
run_iwyu_test.py/OneIwyuTest/RunOneTest which I do in the attached patch. I
tried moving this a little earlier still - canonicalising filename rather than
files_to_check - but it seems that the glob.glob inserts backslashes on Windows.
How does this look?
Incidentally, I had been assuming that the tests were being invoked via
iwyu_test_util.py/TestIwyuOnFile, which calls _GetAllCppFilesUnderDir. I can't
see where this might be called from. The comment for TestIwyuOnFile indicates
that the function might no longer be needed. Is that the case?
Original comment by paul.hol...@gmail.com
on 20 Jul 2011 at 9:31
Attachments:
run_iwyu_tests.py calls TestIwyuOnRelativeFile. It doesn't call
_GetAllCppFilesUnderDir(), as you noticed, and instead just does globs itself.
Patch looks good to me -- that's where I would make this canonicalization call
too. Feel free to commit!
Original comment by csilv...@gmail.com
on 20 Jul 2011 at 11:09
Great. That's applied in r283, and resolves this issue.
Original comment by paul.hol...@gmail.com
on 21 Jul 2011 at 7:12
Original issue reported on code.google.com by
paul.hol...@gmail.com
on 16 Jul 2011 at 5:50Attachments: