This is an archive of the discontinued LLVM Phabricator instance.

[libc++][CI] Fix check-generated-output.
ClosedPublic

Authored by Mordante on Apr 26 2021, 8:58 AM.

Details

Reviewers
Quuxplusone
curdeius
Group Reviewers
Restricted Project
Commits
rGbf72f6baccfe: [libc++][CI] Fix check-generated-output.
Summary

Before the script detected non-ASCII characters but let them pass. This
fixes the issue. I had a way to solve the issue, during review @Quuxplusone
suggested a better alternative. The patch has been changed to use this alternative.

Intended failed builds:

Diff Detail

Event Timeline

Mordante created this revision.Apr 26 2021, 8:58 AM
Mordante requested review of this revision.Apr 26 2021, 8:58 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 26 2021, 8:58 AM
Herald added a reviewer: Restricted Project. · View Herald Transcript
Mordante updated this revision to Diff 340571.Apr 26 2021, 9:50 AM

Add a revert of 18b03b008588e829751ab4b945982ee301a58839
This should break the build with non-ASCII characters.

Quuxplusone added inline comments.
libcxx/utils/ci/run-buildbot
10–11

@Mordante: Are you sure the script lets non-ASCII characters pass? My intent/understanding had been that set -e makes the build fail if any of these greps return nonzero; and I believe that that's what I was observing when I made the PR originally.

Mordante edited the summary of this revision. (Show Details)Apr 26 2021, 10:32 AM
Mordante updated this revision to Diff 340583.Apr 26 2021, 10:38 AM
Mordante marked an inline comment as done.

Re-applied 18b03b008588e829751ab4b945982ee301a58839 and pretend to have completed std::format.

libcxx/utils/ci/run-buildbot
10–11

Yes I noticed the non-ASCII hyphen in some comment which was copied from the Standard. So I was surprised the build passed.
An example is this build https://buildkite.com/llvm-project/libcxx-ci/builds/2807#2ec7bc42-3bac-4a7b-98ac-c3b8d03390c7

Mordante added inline comments.Apr 26 2021, 10:45 AM
libcxx/utils/ci/run-buildbot
10–11

If you have a better suggestion how to solve the issue, I'm open to suggestions.

Quuxplusone requested changes to this revision.Apr 26 2021, 11:21 AM
Quuxplusone added inline comments.
libcxx/utils/ci/run-buildbot
10–11

Oh, gross.
https://unix.stackexchange.com/questions/65532/why-does-set-e-not-work-inside-subshells-with-parenthesis-followed-by-an-or/65564
https://stackoverflow.com/questions/57681955/set-e-does-not-respect-logical-not
The ! is flipping the exit code from 1 to 0 or vice versa (as expected) but also disabling the effects of set -e (not expected). Compare the effects of running this script:

set -e
false
echo hello  # never reached

versus this one:

set -e
! true
echo hello  # oops, yes reached

So, I'm down this rabbit hole now.
I don't want to just chain everything together with &&, though; that seems unscaleable, in that if anyone ever forgets to end a line with &&, things will silently break again. I think the right solution is to find the appropriate replacement for !.

Could you try this out?

# Check if the diffs are empty, fail otherwise.
! grep -q '^--- a' ${BUILD_DIR}/generated_output.patch || false
# Reject patches that introduce non-ASCII characters or hard tabs.
! grep -rn '[^ -~]' libcxx/include/ || false
# Check that no dependency cycles have been introduced.
python3 libcxx/utils/graph_header_deps.py >/dev/null

and obviously with a commit message that explains why the seemingly pointless || false is needed (if I'm right that it works at all, that is).

This revision now requires changes to proceed.Apr 26 2021, 11:21 AM
Mordante updated this revision to Diff 340600.Apr 26 2021, 11:41 AM

Revert utils/ci/run-buildbot to its original state and try @Quuxplusone's suggestion.

Mordante planned changes to this revision.Apr 26 2021, 11:45 AM
Mordante added inline comments.
libcxx/utils/ci/run-buildbot
10–11

Thanks for the suggestion. I've started a build to test it. This looks more scalable and doesn't require to change the order so I like this a lot better.
If this works I'll add some comment why this is required.

Mordante updated this revision to Diff 340860.Apr 27 2021, 8:37 AM

Test with non-ASCII and not updated generate scripts.

Mordante updated this revision to Diff 340861.Apr 27 2021, 8:43 AM

Test with only non-ASCII to be sure.

Mordante updated this revision to Diff 340864.Apr 27 2021, 8:56 AM
  • Removes all test code.
  • Restores all pipelines.
  • Added documentation why the work-around is needed.
Mordante retitled this revision from [WIP][libc++][DI] Fix check-generated-output. to [libc++][CI] Fix check-generated-output..Apr 27 2021, 9:01 AM
Mordante edited the summary of this revision. (Show Details)
Quuxplusone added inline comments.
libcxx/utils/ci/run-buildbot
140–151

I think I actually liked your original reordering; it puts the two || falses close together visually. Meanwhile, the comment can easily be 1 line instead of 7.

~~~
# Check if the diffs are empty, fail otherwise.
# "|| false" works around https://stackoverflow.com/questions/57681955/set-e-does-not-respect-logical-not
! grep -q '^--- a' ${BUILD_DIR}/generated_output.patch || false
# Reject patches that introduce non-ASCII characters or hard tabs.
! grep -rn '[^ -~]' libcxx/include/ || false
# Check that no dependency cycles have been introduced.
python3 libcxx/utils/graph_header_deps.py >/dev/null

WDYT?

curdeius accepted this revision.Apr 27 2021, 9:20 AM
curdeius added a subscriber: curdeius.

LGTM. I have no strong feelings about the order of commands (per Arthur's comment). Both are OK for me.

This revision is now accepted and ready to land.Apr 27 2021, 9:20 AM
Mordante marked an inline comment as done.Apr 27 2021, 9:35 AM

Thanks for the reviews.

libcxx/utils/ci/run-buildbot
140–151

I reordered the code again.
I don't mind shortening the comment a bit, but I feel your version is too terse.
I changed it to two lines, including the stackoverflow link.

Mordante updated this revision to Diff 340883.Apr 27 2021, 9:36 AM
Mordante marked an inline comment as done.
Mordante edited the summary of this revision. (Show Details)

Adresses the review comments.

This revision was landed with ongoing or failed builds.Apr 28 2021, 10:14 AM
This revision was automatically updated to reflect the committed changes.