Repository navigation
Fix paths with spaces in lit check updater #9375
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
Closed
Rodri5449
wants to merge
1
commit into
WebAssembly:main
from
Rodri5449:fix/lit-checks-paths-with-spaces
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| import os | ||
| import subprocess | ||
| import sys | ||
| import tempfile | ||
| from pathlib import Path | ||
|
|
||
| from scripts.test import shared | ||
|
|
||
| from . import utils | ||
|
|
||
|
|
||
| class UpdateLitChecksPathsTest(utils.BinaryenTestCase): | ||
| def test_paths_with_spaces(self): | ||
| with tempfile.TemporaryDirectory(prefix='update lit checks ') as temp: | ||
| root = Path(temp) | ||
| # Exercise %s, %S, and %t, with both quoted and unquoted RUN lines. | ||
| for run in ( | ||
| 'wasm-opt %s -S -o -', | ||
| 'wasm-opt "%s" -S -o -', | ||
| 'wasm-opt "%S/input file.wat" -S -o %t.wat && wasm-opt %t.wat -S -o -', | ||
| 'foreach %s %t wasm-opt -S -o -', | ||
| 'foreach "%s" "%t" wasm-opt -S -o -', | ||
| ): | ||
| with self.subTest(run=run): | ||
| test = root / 'input file.wat' | ||
| test.write_text(';; RUN: ' + run + ' | filecheck %s\n' | ||
| '(module\n' | ||
| ' (func $answer (result i32) (i32.const 42))\n' | ||
| ')\n') | ||
| env = dict(os.environ, TMPDIR=temp, TEMP=temp, TMP=temp) | ||
| command = [sys.executable, | ||
| os.path.join(shared.options.binaryen_root, 'scripts', 'update_lit_checks.py'), | ||
| '--binaryen-bin', shared.options.binaryen_bin, | ||
| '--force', '--dry-run', str(test)] | ||
| result = subprocess.run(command, env=env, capture_output=True, text=True) | ||
| self.assertEqual(result.returncode, 0, result.stderr) | ||
| self.assertIn(';; CHECK:', result.stdout) | ||
| self.assertIn('(i32.const 42)', result.stdout) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Using sequential
.replace()calls can lead to unexpected behavior if one of the replacement values (such astestortmppaths) contains another placeholder substring (e.g., if the test path contains%tor%S). In such cases, the subsequent.replace()calls will perform recursive replacements on the already-replaced path, corrupting the final command.Using a single-pass regular expression replacement ensures that each placeholder is replaced exactly once and prevents recursive replacement bugs.