-
Notifications
You must be signed in to change notification settings - Fork 10.6k
[Test][AutoDiff] Replace sed command with echo/cat for internal shell compatibility #85842
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
base: main
Are you sure you want to change the base?
[Test][AutoDiff] Replace sed command with echo/cat for internal shell compatibility #85842
Conversation
…_type.swift file Convert `sed` command with `echo` and `cat` commands to achieve the same logic for compatibility with LLVM Lit internal shell.
Convert the existing `sed` commands in `AutoDiff` test files that use `REQUIRES: shell` into equivalent logic using `echo` and `cat` for compatibility with LLVM Lit’s internal shell.
| // https://github.com/apple/swift/issues/54526 | ||
| // Workaround because import declarations are not preserved in .sib files. | ||
| // RUN: sed -e 's/import Swift$/import Swift; import _Differentiation/' %t/tmp.sil > %t/tmp_fixed.sil | ||
| // RUN: echo "import _Differentiation" > %t/tmp_preamble |
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.
I do not recall all all restrictions of internal shell, does one of the following work instead?
cat <(echo "import _Differentiation") tmp.sil > tmp_fixed.sil
(echo "import _Differentiation"; cat tmp.sil) > tmp_fixed.silor even
echo "import _Differentiation" | cat - tmp.sil > tmp_fixed.silThere 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.
I think that the <(...) syntax is only supported by BASH and not by internal shell, so that test would fail in Windows CI or shells other than Bash. I think keeping it as two atomic, standard commands is the most robust approach (thanks to @hnrklssn for suggesting this approach in the first place):
// RUN: echo "import _Differentiation" > %t/tmp_fixed.sil
// RUN: cat %t/tmp.sil >> %t/tmp_fixed.sil
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.
Is this so for pipe as well? I believe this is something that should be supported (see https://github.com/llvm/llvm-project/blob/2a10e91d8f2edf20bb0e6680e668b327334dc6e8/llvm/utils/lit/tests/Inputs/shtest-shell/diff-pipes.txt)
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.
Chiming in here, lit's shell doesn't give you much to work with. You can't use process substitution and you can't use echo if it's piped to another command. At least with the two line approach it keeps things simple.
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.
Pipes are supported in general, the one limitation is that the built-in version of echo does not support pipes. Another option would be to create a file test/AutoDiff/SIL/import_Differentiation.txt containing import _Differentiation, and use cat %S/import_Differentiation.txt %t/tmp.sil > %t/tmp_fixed.sil. No strong preference from my end though.
|
LGTM! |
|
? @swift-ci please smoke test |
|
The bot clocked out for the day. 🪫🪫🪫 |
|
@swift-ci please smoke test |
magic touch ;) |
|
Oh no, Windows platform test failed 😭 ! I cannot see the cause in details, it says:
How do I identify the problem that makes the test fail? |
These two tests failed: If you click on the failed CI bot, and then go to "View as plain text" you can see the build and test log (where the above excerpt is from). I'm on the phone so I can't really see what the actual issue was, but if you cmd+f for those paths you should find the test output for them. Let me know if you need more help, I can take a look tomorrow. Normally when only Windows fails it's related to either newlines or path separators being different. |
Thanks so much for the explanation! I’ll check the logs and try to fix it. If I run into issues, I’ll reach out again. |
|
It looks like |
Yeah, this is what normally done in tests. Or just ignore everything between |
Thanks for the explanation! I also checked the other failing test file, I believe this could be fixed in a similar way by allowing But as @asl mentioned, it could also be fixed by ignoring everything between But I couldn't figure out which is the best way to approach this. Allowing only the known platform differences seems safer to me, since a fully generic |
…ndows dllimport and dllexport This change updates the affected `IRGEN` and `IRGEN-LABEL` checks to explicitly allow optional `dllimport` and `dllexport` attributes using regex patterns, while keeping the rest of the checks strict.
I’ve updated the failing tests by adding optional If you’d prefer |
|
@swift-ci please smoke test |
Refactored
AutoDifftest files that containsREQUIRES: shellby replacing the line:with
echoandcatcommands:to make it compatible with LLVM Lit internal shell.
Partially address #84407