-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Internal test coverage for deduplicated header units #2563
Internal test coverage for deduplicated header units #2563
Conversation
tests/std/tests/P1502R1_standard_library_header_units/importable_cxx_library_headers.json
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lg2m
'version', | ||
] | ||
|
||
|
||
def loadJsonWithComments(filename): | ||
# This is far from a general-purpose solution (it doesn't attempt to handle block comments like /**/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it kinda is a general purpose solution, it's not like a json lexer would do something else ..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, as the comment explains, a json lexer would know where strings begin and end, so it wouldn't be confused by "cats // dogs"
(or more realistically something like "c:/temp/dir1/dir2//file.txt"
), whereas my regex here would immediately damage that.
|
||
sub loadJsonWithComments | ||
{ | ||
my $filename = $_[0]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
my $filename = shift(@_);
is a little more idiomatic, but this is fine too. Personally I prefer just using signatures, but I have no idea if the perl in runall is sufficiently new for that.
Noting for posterity no need to redo the backend integration just for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the record, we're running Perl 5.26 (May 2017 🙀) which looks like it would support signatures.
{ | ||
my $filename = $_[0]; | ||
my $jsonStr = readFile($filename); | ||
return JSON::PP->new->utf8->decode($jsonStr); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
apparently faster to just write decode_json $jsonStr;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. Although that would be shorter and faster, speed isn't important here (these JSON files are very small and the compilation process takes the vast majority of the time), and I felt that having this line look similar to the relaxed
line made their near-symmetry more obvious. I suppose I could have just made it a comment.
I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed. (I'll handle verifying that this works with the recent LLVM update.) |
This ports the test coverage for deduplicated (topologically sorted) header units, added by #2516 for the Python-powered GitHub test harness, to the Perl-powered internal test harness. This will allow @cdacamar to avoid compiler regressions while working on modules. It will also inform us when compiler and library changes trigger assertions in the internal "chk" builds of the compiler.
In the Python code, we don't need
sorted(set())
anymore. Originally, I combinedheader-units.json
with the Standard's list of importable C++ library headers. This had the effect of addingversion
, but also added a whole bunch of duplicates (likealgorithm
,bitset
, etc.), sosorted(set())
eliminated the duplicates and then put the list back into sorted order. Now, we're takingheader-units.json
and appending a small, completely disjoint list of headers. (It's okay that the resulting list isn't sorted; the order isn't important.)Next, to avoid having so many files to update when we add new Standard headers, I'm extracting that list of importable C++ library headers to a JSON With Comments file. In the Python code, we need to update the comment in
loadJsonWithComments()
(as it's not specific toheader-units.json
anymore), then we addgetImportableCxxLibraryHeaders(sourcePath)
. ThesourcePath
is the full path totest.cpp
, so we can extract its directory name to get to the new file in the same folder.The Perl code is a mostly direct translation of the Python code, including a rewrite of the classic independent header unit scenario. (Previously, the Perl code concatenated strings of compiler options. Now it builds arrays that are joined with spaces later, which is what the Python code does.) The comments are mostly identical (with a bit of variation marked as being for Perl), making it easier to read the source code side-by-side.
The internal port of this PR will contain a non-GitHub commit to re-add
STL_INCLUDE_DIR
to the environment variables that the internal test harness defines; this is the location of the STL's header files (andheader-units.json
which is in the same directory). I have verified that this passes internally and inspected the resulting command lines.A minor bit of variation between the Python and Perl is how
remainingDependencies
is updated. In Perl, it's easier to do two separate passes - a first pass to eliminate headers that were just built, followed by a second step to filter the dependencies of remaining headers.Finally, we're able to remove some compiler workarounds in the internal test harness. The Perl is always internal, so it can use
"logical-name"
in the/scanDependencies
output - this is considerably simpler. (The Python will need to wait until VS 2022 17.2 Preview 2 ships.) Also, thetest.cpp
can disable workarounds for the topo-sort scenario when it's running internally, again until the fixes ship. Thanks again to @cdacamar for fixing these bugs.STL_INCLUDE_DIR
.