This is an archive of the discontinued LLVM Phabricator instance.

[libc++] Use .gen.py tests for the transitive inclusion tests
ClosedPublic

Authored by ldionne on Jun 2 2023, 10:07 AM.

Details

Summary

This finishes the transition of tests covered in generate_header_tests.py
to the new .gen.py format.

Diff Detail

Event Timeline

ldionne created this revision.Jun 2 2023, 10:07 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 2 2023, 10:07 AM
Herald added a subscriber: arichardson. · View Herald Transcript
ldionne requested review of this revision.Jun 2 2023, 10:07 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 2 2023, 10:07 AM
Herald added a reviewer: Restricted Project. · View Herald Transcript
philnik accepted this revision as: philnik.Jun 2 2023, 2:28 PM
philnik added subscribers: Mordante, philnik.

I think this makes sense, but I'd rather have @Mordante have a look, since he is more familiar with the interns of this test, and especially the transitive_includes_to_csv.py script.

Mordante requested changes to this revision.Jun 3 2023, 4:17 AM

In general the approach seems fine, but I want to do some testing with this patch.
Especially to see what happens when the regenerate_expected_results flag is toggled.

libcxx/test/libcxx/transitive_includes.gen.py
28–31

These instructions seem outdated an no longer working. The regeneration happen when I try to run this test. Unfortunately running the test fails.

<build>/bin/llvm-lit --param std=c++03 test/libcxx/transitive_includes.gen.py gives

<llvm>/llvm/utils/lit/lit/discovery.py:189: error: 'llvm-libc++-shared.cfg.in :: libcxx/transitive_includes.gen.py' would not be run indirectly: change name or LIT config(e.g. suffixes or standalone_tests variables)
1 errors, exiting

Running the generated test manually
<build>/bin/llvm-lit <build>/build/test/libcxx/transitive_includes.gen.py/algorithm.sh.cpp
gives

llvm-lit: <llvm>/llvm/utils/lit/lit/discovery.py:137: warning: unable to find test suite for '<build>/test/libcxx/transitive_includes.gen.py/algorithm.sh.cpp'
llvm-lit: <llvm>/llvm/utils/lit/lit/discovery.py:314: warning: input '<build>/test/libcxx/transitive_includes.gen.py/algorithm.sh.cpp' contained no tests
error: did not discover any tests for provided path(s)

How can we run this test and update the transitive includes?

37

This file is generated when regenerate_expected_results is set to True but not removed when set to False again. I would like to test whether this generated test will be executed, but I can't seem to run this test. (See comment above.)

89

It seems we don't use awk in our tests yet. It's already a dependency since it's on of the POSIX tools. However I wonder why not using grep instead?

This revision now requires changes to proceed.Jun 3 2023, 4:17 AM
ldionne marked an inline comment as done.
ldionne added inline comments.
libcxx/test/libcxx/transitive_includes.gen.py
28–31

This would be fixed by D151664.

89

That's a good question. I was using grep first.

grep returns non-zero when there are no matches, which fails this test for headers that have no transitive dependencies.

ldionne marked an inline comment as done.Jun 3 2023, 8:39 AM
Mordante accepted this revision.Jun 4 2023, 3:08 AM

LGTM modulo one nit.

libcxx/test/libcxx/transitive_includes.gen.py
28–29
28–31

Great! That patch was also very useful to test the new style tests for D151814.

37

I tested this with D151664 and only the proper branch of regenerate_expected_results was executed. So this works as expected and the stale files are not an issue.

89

Ah interesting.

This revision is now accepted and ready to land.Jun 4 2023, 3:08 AM
Mordante added inline comments.Jun 4 2023, 3:10 AM
libcxx/test/libcxx/transitive_includes.gen.py
28–31
ldionne marked 7 inline comments as done.Jun 5 2023, 7:23 AM

I'm going to ship this now despite D151664 not being landed because this is blocking other work.

I'm going to ship this now despite D151664 not being landed because this is blocking other work.

No objections. I just needed to be able to test the patch locally to see whether the stale tests were an issue.

libcxx/utils/CMakeLists.txt