@@ -17,11 +17,11 @@ export BUILDKITE_PULL_REQUEST_BASE_BRANCH="base"
17
17
# Initialize the repository
18
18
init_test_repo " $repo_path "
19
19
20
- # Create test files
20
+ # Create test files (using single quotes to avoid special chars being interpreted by the shell)
21
21
mkdir -p docs src/swift
22
- echo " doc " > " docs/read me.md"
23
- echo " doc2" > " docs/guide with spaces.md"
24
- echo " doc3" > " docs/special\!\@\# \ $ chars.md"
22
+ echo " doc1 " > ' docs/read me.md'
23
+ echo " doc2" > ' docs/guide with spaces.md'
24
+ echo " doc3" > ' docs/special\!@*# $chars.md'
25
25
git add .
26
26
git commit -m " Add doc files"
27
27
@@ -30,20 +30,30 @@ result=$(pr_changed_files --all-match "docs/*")
30
30
assert_output " true" " $result " " Should return true when all changes match patterns"
31
31
32
32
# [Test] All changes in docs with explicit patterns including spaces and special chars
33
- result=$( pr_changed_files --all-match ' docs/read me.md' ' docs/guide with spaces.md' ' docs/special\\!\\@\\#\$chars.md' )
33
+ # Note: we need to escape the '\` and `*` special chars in the pattern to match them literally instead of as special characters
34
+ result=$( pr_changed_files --all-match ' docs/read me.md' ' docs/guide with spaces.md' ' docs/special\\!@\*#$chars.md' )
34
35
assert_output " true" " $result " " Should return true when all changes match patterns with spaces and special chars"
35
36
37
+ # [Test] All changes in docs with globbing patterns including spaces and special chars
38
+ result=$( pr_changed_files --all-match ' docs/read me.md' ' docs/guide with spaces.md' ' docs/special\\!*.md' )
39
+ assert_output " true" " $result " " Should return true when all changes match patterns with spaces and special chars, even when using globbing"
40
+
36
41
# [Test] Changes outside pattern
37
- echo " swift" > " src/swift/main with spaces.swift"
38
- echo " swift" > " src/swift/special\ !\@\# \ $ chars.swift"
42
+ echo " swift" > ' src/swift/main with spaces.swift'
43
+ echo " swift" > ' src/swift/special!\@#* $chars.swift'
39
44
git add .
40
45
git commit -m " Add swift file"
41
46
42
47
result=$( pr_changed_files --all-match " docs/*" )
43
48
assert_output " false" " $result " " Should return false when changes exist outside patterns"
44
49
45
50
# [Test] Multiple patterns, all matching
46
- result=$( pr_changed_files --all-match ' docs/*' ' src/swift/main with spaces.swift' ' src/swift/special\\!\\@\\#\$chars.swift' )
51
+ # Note: we need to escape the '\` and `*` special chars in the pattern to match them literally instead of as special characters
52
+ result=$( pr_changed_files --all-match ' docs/*' ' src/swift/main with spaces.swift' ' src/swift/special\!\\@#\*$chars.swift' )
47
53
assert_output " true" " $result " " Should return true when all changes match multiple patterns"
48
54
55
+ # [Test] Multiple patterns, all matching, including some using globbing
56
+ result=$( pr_changed_files --all-match ' docs/*' ' src/swift/main with spaces.swift' ' src/swift/special*chars.swift' )
57
+ assert_output " true" " $result " " Should return true when all changes match multiple patterns, including some using globbing"
58
+
49
59
echo " ✅ All-match pattern tests passed"
0 commit comments