@@ -108,13 +108,29 @@ func TestDiff(t *testing.T) {
108108func TestDiffWithSubshell (t * testing.T ) {
109109 want := []string {
110110 "user-service/infrastructure/cloudfront.yaml" ,
111+ "user-service/my config/settings.yaml" ,
111112 "user-service/serverless.yaml" ,
112113 }
113114 got , err := diff ("cat e2e/multiple-paths" )
114115 assert .NoError (t , err )
115116 assert .Equal (t , want , got )
116117}
117118
119+ func TestDiffRealisticGitOutput (t * testing.T ) {
120+ // Fixture mirrors git diff --name-only output: plain paths, C-style
121+ // quoted paths (tab, octal emoji), and paths with spaces.
122+ want := []string {
123+ "normal/path.go" ,
124+ "path/with\t escape.go" ,
125+ "directory/File Name With Spaces.md" ,
126+ "projects/17_🪁_emoji.py" ,
127+ "another dir/some file.txt" ,
128+ }
129+ got , err := diff ("cat e2e/diff-output-realistic" )
130+ assert .NoError (t , err )
131+ assert .Equal (t , want , got )
132+ }
133+
118134func TestDiffWithQuotedPaths (t * testing.T ) {
119135 want := []string {
120136 "projects/test/pages/17_🪁_testfile.py" ,
@@ -161,6 +177,48 @@ func TestDiffWithSpacesInFilenamesSingleFile(t *testing.T) {
161177 assert .Equal (t , want , got )
162178}
163179
180+ func TestDiffEmptyOutput (t * testing.T ) {
181+ got , err := diff (`printf ''` )
182+ assert .NoError (t , err )
183+ assert .Equal (t , []string {}, got )
184+ }
185+
186+ func TestDiffWhitespaceOnlyOutput (t * testing.T ) {
187+ got , err := diff (`printf '\n\n\n'` )
188+ assert .NoError (t , err )
189+ assert .Equal (t , []string {}, got )
190+ }
191+
192+ func TestDiffSingleFileNoTrailingNewline (t * testing.T ) {
193+ // Legacy compat: custom diff commands may not emit a trailing newline
194+ want := []string {"services/foo/serverless.yml" }
195+ got , err := diff (`printf 'services/foo/serverless.yml'` )
196+ assert .NoError (t , err )
197+ assert .Equal (t , want , got )
198+ }
199+
200+ func TestDiffWindowsLineEndings (t * testing.T ) {
201+ want := []string {
202+ "services/foo/file.go" ,
203+ "services/bar/file.go" ,
204+ }
205+ got , err := diff (`printf 'services/foo/file.go\r\nservices/bar/file.go\r\n'` )
206+ assert .NoError (t , err )
207+ assert .Equal (t , want , got )
208+ }
209+
210+ func TestDiffQuotedPathsWithSpaces (t * testing.T ) {
211+ // Git C-style quotes paths with special chars; spaces alone don't trigger quoting,
212+ // but paths with both spaces and special chars will be quoted.
213+ want := []string {
214+ "projects/my docs/17_🪁_file.py" ,
215+ "normal/file.txt" ,
216+ }
217+ got , err := diff (`printf '"projects/my docs/17_\360\237\252\201_file.py"\nnormal/file.txt\n'` )
218+ assert .NoError (t , err )
219+ assert .Equal (t , want , got )
220+ }
221+
164222func TestStepsToTriggerWithEmojiPaths (t * testing.T ) {
165223 watch := []WatchConfig {
166224 {
0 commit comments