@@ -101,6 +101,87 @@ public void downloadOutputsWithRegex() throws Exception {
101
101
assertOutputsDoNotExist ("//:foobar" );
102
102
}
103
103
104
+ @ Test
105
+ public void downloadOutputsWithRegex_treeOutput_regexMatchesTreeFile () throws Exception {
106
+ // Disable on Windows since it fails for unknown reasons.
107
+ // TODO(chiwang): Enable it on windows.
108
+ if (OS .getCurrent () == OS .WINDOWS ) {
109
+ return ;
110
+ }
111
+
112
+ writeOutputDirRule ();
113
+ write (
114
+ "BUILD" ,
115
+ "load(':output_dir.bzl', 'output_dir')" ,
116
+ "output_dir(" ,
117
+ " name = 'foo'," ,
118
+ " manifest = ':manifest'," ,
119
+ ")" );
120
+ write ("manifest" , "file-1" , "file-2" , "file-3" );
121
+ addOptions ("--experimental_remote_download_regex=.*foo/file-2$" );
122
+
123
+ buildTarget ("//:foo" );
124
+ waitDownloads ();
125
+
126
+ assertValidOutputFile ("foo/file-2" , "file-2\n " );
127
+ assertOutputDoesNotExist ("foo/file-1" );
128
+ assertOutputDoesNotExist ("foo/file-3" );
129
+ }
130
+
131
+ @ Test
132
+ public void downloadOutputsWithRegex_treeOutput_regexMatchesTreeRoot () throws Exception {
133
+ writeOutputDirRule ();
134
+ write (
135
+ "BUILD" ,
136
+ "load(':output_dir.bzl', 'output_dir')" ,
137
+ "output_dir(" ,
138
+ " name = 'foo'," ,
139
+ " manifest = ':manifest'," ,
140
+ ")" );
141
+ write ("manifest" , "file-1" , "file-2" , "file-3" );
142
+ addOptions ("--experimental_remote_download_regex=.*foo$" );
143
+
144
+ buildTarget ("//:foo" );
145
+ waitDownloads ();
146
+
147
+ assertThat (getOutputPath ("foo" ).exists ()).isTrue ();
148
+ assertOutputDoesNotExist ("foo/file-1" );
149
+ assertOutputDoesNotExist ("foo/file-2" );
150
+ assertOutputDoesNotExist ("foo/file-3" );
151
+ }
152
+
153
+ @ Test
154
+ public void downloadOutputsWithRegex_regexMatchParentPath_filesNotDownloaded () throws Exception {
155
+ write (
156
+ "BUILD" ,
157
+ "genrule(" ,
158
+ " name = 'file-1'," ,
159
+ " srcs = []," ,
160
+ " outs = ['foo/file-1']," ,
161
+ " cmd = 'echo file-1 > $@'," ,
162
+ ")" ,
163
+ "genrule(" ,
164
+ " name = 'file-2'," ,
165
+ " srcs = []," ,
166
+ " outs = ['foo/file-2']," ,
167
+ " cmd = 'echo file-2 > $@'," ,
168
+ ")" ,
169
+ "genrule(" ,
170
+ " name = 'file-3'," ,
171
+ " srcs = []," ,
172
+ " outs = ['foo/file-3']," ,
173
+ " cmd = 'echo file-3 > $@'," ,
174
+ ")" );
175
+ addOptions ("--experimental_remote_download_regex=.*foo$" );
176
+
177
+ buildTarget ("//:file-1" , "//:file-2" , "//:file-3" );
178
+ waitDownloads ();
179
+
180
+ assertOutputDoesNotExist ("foo/file-1" );
181
+ assertOutputDoesNotExist ("foo/file-2" );
182
+ assertOutputDoesNotExist ("foo/file-3" );
183
+ }
184
+
104
185
@ Test
105
186
public void intermediateOutputsAreInputForLocalActions_prefetchIntermediateOutputs ()
106
187
throws Exception {
0 commit comments