This is an archive of the discontinued LLVM Phabricator instance.

[flang][driver] Refactor unit tests for frontend actions (nfc)
ClosedPublic

Authored by awarzynski on Dec 18 2020, 7:44 AM.

Details

Summary

These patch implements a few non-functional-changes:

  • switch to using test fixtures for better code sharing
  • rename some variables (e.g. to communicate their purpose a bit better)

This patch doesn't change _what_ is being tested.

Diff Detail

Event Timeline

awarzynski created this revision.Dec 18 2020, 7:44 AM
awarzynski requested review of this revision.Dec 18 2020, 7:44 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 18 2020, 7:44 AM

Rebase on top of main + refine

Making sure that the temporary test files have unique names. Also update
variables names (e.g. invocation -> invocation_) so that they conform to
Flang's coding style. Otherwise just updated comments.

Thank you!
That was much needed to extract into a fixture, given a few upcoming reviews.

flang/unittests/Frontend/FrontendActionTest.cpp
72–76

Does it mean that setting ClearOutputFiles to false will always not delete the files, as you are trying to mention that it's safe to call it anyways ?
If that's true what happens when a command line option creates physical file?
So should this be left to individual TEST_F function?

sameeranjoshi added inline comments.Dec 21 2020, 11:20 PM
flang/unittests/Frontend/FrontendActionTest.cpp
9

Just trying to understand - why is this error from clang-tidy?
Also I see https://buildkite.com/llvm-project/premerge-checks/builds/20385#c11feba0-7c79-4290-8631-3026a7ff89aa
failing for the same.

Thank you for reviewing @sameeranjoshi !

flang/unittests/Frontend/FrontendActionTest.cpp
9

I've not been able to reproduce this :( To me it looks like the pre-merge script is doing something unexpected. Clearly this line is perfectly fine.

I reported this with llvm-premerge-checks - hopefully they will have the bandwidth to look into this.

72–76

CASE 1
In normal circumstances, the compiler's job is to generate output files, so:

  • EraseFiles will be set to False (i.e. the output files should be kept after the compiler exits)
  • ClearOutputFiles will simply resets the internal state of CompilerInstance.

CASE 2
However, in some cases the compiler should delete the files, e.g.:

CASE 3
Finally, some actions don't generate output files, e.g. ParseSyntaxOnly, so calling ClearOutputFiles doesn't really do much.

In all cases calling ClearOutputFiles(/*EraseFiles=*/false); gives the desired behavior.

Let me clarify the comment to make it clearer!

Clarify the comment for ClearOutputFIles

awarzynski updated this revision to Diff 313278.EditedDec 22 2020, 3:13 AM

Please ignore the previous revision (i.e. Diff 3). Review Diff 4 instead.

sameeranjoshi accepted this revision.Dec 22 2020, 3:27 AM
This revision is now accepted and ready to land.Dec 22 2020, 3:27 AM
This revision was landed with ongoing or failed builds.Dec 22 2020, 5:09 AM
This revision was automatically updated to reflect the committed changes.