@@ -49,6 +49,13 @@ test('if at least one file is missing, this should be an error', t => {
49
49
t . is ( result . code , 2 ) ;
50
50
} ) ;
51
51
52
+ test ( "multiple files, one doesn't exist, one doesn't match" , t => {
53
+ const result = shell . grep ( / o o g a b o o g a / , 'test/resources/file1.txt' ,
54
+ 'test/resources/filedoesnotexist.txt' ) ;
55
+ t . truthy ( shell . error ( ) ) ;
56
+ t . is ( result . code , 2 ) ;
57
+ } ) ;
58
+
52
59
//
53
60
// Valids
54
61
//
@@ -127,6 +134,17 @@ test('one file, * in string-regex, make sure * is not globbed', t => {
127
134
t . is ( result . toString ( ) , 'this line ends in.js\nlllllllllllllllll.js\n' ) ;
128
135
} ) ;
129
136
137
+ test ( "one file, pattern doesn't match" , t => {
138
+ const result = shell . grep ( 'notfoundstring' , 'test/resources/grep/file' ) ;
139
+ t . truthy ( shell . error ( ) ) ;
140
+ t . is ( result . toString ( ) , '' ) ;
141
+ t . is ( result . stdout , '' ) ;
142
+ // TODO(#900): "grep: " isn't really the correct stderr output, but we need a
143
+ // non-empty string so `shell.error()` is truthy.
144
+ t . is ( result . stderr , 'grep: ' ) ;
145
+ t . is ( result . code , 1 ) ;
146
+ } ) ;
147
+
130
148
test ( '-l option' , t => {
131
149
const result = shell . grep ( '-l' , 'test1' , 'test/resources/file1' , 'test/resources/file2' ,
132
150
'test/resources/file1.txt' ) ;
0 commit comments