-
Notifications
You must be signed in to change notification settings - Fork 70
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
tests: Wrapped all %s that refer to paths with " #2628
tests: Wrapped all %s that refer to paths with " #2628
Conversation
Attempts to fix issue xdslproject#2598
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2628 +/- ##
=======================================
Coverage 89.60% 89.60%
=======================================
Files 358 358
Lines 45714 45714
Branches 6900 6900
=======================================
Hits 40962 40962
Misses 3697 3697
Partials 1055 1055 ☔ View full report in Codecov by Sentry. |
config.suffixes = ['.test', '.mlir', '.py'] | ||
|
||
xdsl_opt = "xdsl/tools/xdsl-opt" | ||
xdsl_run = "xdsl/tools/xdsl_run.py" | ||
irdl_to_pyrdl = "xdsl/tools/irdl_to_pyrdl.py" | ||
|
||
config.substitutions.append(('XDSL_ROUNDTRIP', "xdsl-opt %s --print-op-generic --split-input-file | xdsl-opt --split-input-file | filecheck %s")) | ||
config.substitutions.append(("XDSL_GENERIC_ROUNDTRIP", "xdsl-opt %s --print-op-generic --split-input-file | filecheck %s --check-prefix=CHECK-GENERIC")) | ||
config.substitutions.append(('XDSL_ROUNDTRIP', "xdsl-opt \"%s\" --print-op-generic --split-input-file | xdsl-opt --split-input-file | filecheck \"%s\"")) |
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.
config.substitutions.append(('XDSL_ROUNDTRIP', "xdsl-opt \"%s\" --print-op-generic --split-input-file | xdsl-opt --split-input-file | filecheck \"%s\"")) | |
config.substitutions.append(('XDSL_ROUNDTRIP', 'xdsl-opt "%s" --print-op-generic --split-input-file | xdsl-opt --split-input-file | filecheck "%s"')) |
config.substitutions.append(('XDSL_ROUNDTRIP', "xdsl-opt %s --print-op-generic --split-input-file | xdsl-opt --split-input-file | filecheck %s")) | ||
config.substitutions.append(("XDSL_GENERIC_ROUNDTRIP", "xdsl-opt %s --print-op-generic --split-input-file | filecheck %s --check-prefix=CHECK-GENERIC")) | ||
config.substitutions.append(('XDSL_ROUNDTRIP', "xdsl-opt \"%s\" --print-op-generic --split-input-file | xdsl-opt --split-input-file | filecheck \"%s\"")) | ||
config.substitutions.append(("XDSL_GENERIC_ROUNDTRIP", "xdsl-opt \"%s\" --print-op-generic --split-input-file | filecheck \"%s\" --check-prefix=CHECK-GENERIC")) |
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.
config.substitutions.append(("XDSL_GENERIC_ROUNDTRIP", "xdsl-opt \"%s\" --print-op-generic --split-input-file | filecheck \"%s\" --check-prefix=CHECK-GENERIC")) | |
config.substitutions.append(("XDSL_GENERIC_ROUNDTRIP", 'xdsl-opt "%s" --print-op-generic --split-input-file | filecheck "%s" --check-prefix=CHECK-GENERIC')) |
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.
Looks good! Small suggestion to avoid escaping, LGTM otherwise
Looking at the Adding this line: Would that make more sense? |
This looks like a better solution, I agree. |
What was the motivation behind that change? |
Personally for me this gets a bit too close to magic. Magic in the sense that a shell command that should not work is working or it is working in one situation but not in another situation (e.g. for non-lit tests). This confusion can be quickly resolved, but I think it would be better if it couldn't happen in the first place. |
See issue: #2598: If the absolute path of the project directory contains a space |
I am not sure I understand what you mean here. What I'm worried about is that people will copy-paste their lit tests from something like MLIR, and forget to escape the |
This is a bit philosophical and this is also not a hill I'm willing to die on so feel free to solve this problem the way you suggested /gen. I think code should never lie. That's the reason why singletons are an anti-pattern, because they make code lie. The same is true for configurations that change the way code is interpreted, they also make the code lie. It might be a small thing in this case, especially for someone who knows about the configuration. But small things add up and eventually become an entry barrier or a configuration/dependency hell, something this project is trying to take away from MLIR if I understood correctly. A little less philosophical and more practical: This correct code will be incorrect after the substitution:
as it gets replaced with:
Again, a bit more philosophical: Quoting variables is universally a good practice in shell scripts to prevent word splitting and globbing: https://www.shellcheck.net/wiki/SC2086 Back to a little more practical reasons: You would need to add this substitution for every substitution there is if you want to cover all future cases: https://llvm.org/docs/CommandGuide/lit.html#substitutions All that said, I totally acknowledge that there is always a trade-off between practicality and "cleanliness" (if there even is such a thing). I see that in this case the practical solution might be the better one. |
I wrote an implementation that changes the configuration file directly, so we do the substitution with escaping of spaces ourselves. This is fixing lit issue of spaces, and while I think this should be done in lit itself, I do not currently have the time to fix it there, especially if this will happen to be a controversial change. |
Hi @watermelonwolverine, I think the best course of action would be to fix Here are some resources about this: I'll close this for now, since I don't think we want to make this change in the tests for the time being. |
See issue #2598
Replaced all %s with "%s" inside .mlir, .toy and some .py.
Wrapped some paths with " in lit.cfg