Skip to content

Commit ee11f58

Browse files
committed
Use single quotes on other tests too
For consistency and to make it easier to understand the special characters we are playing with without having to escape them in double-quote contexts
1 parent 40cac25 commit ee11f58

File tree

2 files changed

+20
-16
lines changed

2 files changed

+20
-16
lines changed

tests/pr_changed_files/test_any_match_patterns.sh

+15-11
Original file line numberDiff line numberDiff line change
@@ -17,41 +17,45 @@ export BUILDKITE_PULL_REQUEST_BASE_BRANCH="base"
1717
# Initialize the repository
1818
init_test_repo "$repo_path"
1919

20-
# Create test files
20+
# Create test files (using single quotes to avoid special chars being interpreted by the shell)
2121
mkdir -p docs src/swift src/ruby
22-
echo "doc" > "docs/read me.md"
23-
echo "doc" > "docs/special\!\@\#\$chars.md"
24-
echo "swift" > src/swift/main.swift
25-
echo "ruby" > src/ruby/main.rb
22+
echo "doc" > 'docs/read me.md'
23+
echo "doc" > 'docs/special!@*#$chars.md'
24+
echo "swift" > 'src/swift/main.swift'
25+
echo "ruby" > 'src/ruby/main.rb'
2626
git add .
2727
git commit -m "Add test files"
2828

2929
# [Test] Match specific extension
30-
result=$(pr_changed_files --any-match "*.swift")
30+
result=$(pr_changed_files --any-match '*.swift')
3131
assert_output "true" "$result" "Should match .swift files"
3232

3333
# [Test] Match multiple patterns
34-
result=$(pr_changed_files --any-match "docs/*.md" "*.rb")
34+
result=$(pr_changed_files --any-match 'docs/*.md' '*.rb')
3535
assert_output "true" "$result" "Should match multiple patterns"
3636

3737
# [Test] Match files with spaces and special characters
38-
result=$(pr_changed_files --any-match "docs/read me.md" "docs/special\!\@\#\$chars.md")
38+
result=$(pr_changed_files --any-match 'docs/read me.md' 'docs/special!@\*#$chars.md')
3939
assert_output "true" "$result" "Should match files with spaces and special characters"
4040

41+
# [Test] Match files with spaces and special characters, even when using globbing
42+
result=$(pr_changed_files --any-match 'docs/read me.md' 'docs/special*chars.md')
43+
assert_output "true" "$result" "Should match files with spaces and special characters, even when using globbing"
44+
4145
# [Test] No matches
42-
result=$(pr_changed_files --any-match "*.js")
46+
result=$(pr_changed_files --any-match '*.js')
4347
assert_output "false" "$result" "Should not match non-existent patterns"
4448

4549
# [Test] Directory pattern
46-
result=$(pr_changed_files --any-match "docs/*")
50+
result=$(pr_changed_files --any-match 'docs/*')
4751
assert_output "true" "$result" "Should match directory patterns"
4852

4953
# [Test] Exact pattern matching
5054
echo "swiftfile" > swiftfile.txt
5155
git add swiftfile.txt
5256
git commit -m "Add file with swift in name"
5357

54-
result=$(pr_changed_files --any-match "*.swift")
58+
result=$(pr_changed_files --any-match '*.swift')
5559
assert_output "true" "$result" "Should only match exact patterns"
5660

5761
echo "✅ Any-match pattern tests passed"

tests/pr_changed_files/test_edge_cases.sh

+5-5
Original file line numberDiff line numberDiff line change
@@ -41,20 +41,20 @@ output=$(pr_changed_files --any-match "*.txt" --all-match "*.md" 2>&1 || true)
4141
assert_output "Error: either specify --all-match or --any-match; cannot specify both" "$output" "Should fail with correct error when using mutually exclusive options"
4242

4343
# [Test] Files with spaces and special characters
44-
mkdir -p "folder with spaces/nested\!\@\#\$folder"
45-
echo "test" > "folder with spaces/file with spaces.txt"
46-
echo "test" > "folder with spaces/nested\!\@\#\$folder/file_with_\!\@\#.txt"
44+
mkdir -p 'folder with spaces/nested!\@*#$folder'
45+
echo "test" > 'folder with spaces/file with spaces.txt'
46+
echo "test" > 'folder with spaces/nested!\@*#$folder/file_with_!@*#$chars.txt'
4747
git add .
4848
git commit -m "Add files with special characters"
4949

5050
result=$(pr_changed_files)
5151
assert_output "true" "$result" "Should handle files with spaces and special characters"
5252

5353
# [Test] Pattern matching with spaces and special characters
54-
result=$(pr_changed_files --any-match "*spaces.txt")
54+
result=$(pr_changed_files --any-match '*spaces.txt')
5555
assert_output "true" "$result" "Should match files with special characters in path"
5656

57-
result=$(pr_changed_files --all-match "folder with spaces/*")
57+
result=$(pr_changed_files --all-match 'folder with spaces/*')
5858
assert_output "true" "$result" "Should handle directory patterns with spaces"
5959

6060
# [Test] No changes between branches

0 commit comments

Comments
 (0)