Skip to content

Commit a8b0804

Browse files
authored
[INTERNAL] Specification: Add tests for resource excludes with absolute paths (#609)
Add tests showing the issue reported in SAP/ui5-tooling#826
1 parent 0fd548a commit a8b0804

File tree

4 files changed

+434
-0
lines changed

4 files changed

+434
-0
lines changed

test/lib/specifications/types/Application.js

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,147 @@ test("Access project resources via workspace w/ builder excludes", async (t) =>
176176
"Did not find excluded resource for default style");
177177
});
178178

179+
test("Access project resources w/ absolute builder excludes", async (t) => {
180+
const {projectInput} = t.context;
181+
const baselineProject = await Specification.create(projectInput);
182+
183+
projectInput.configuration.builder = {
184+
resources: {
185+
excludes: ["/resources/id1/manifest.json"]
186+
}
187+
};
188+
const excludesProject = await Specification.create(projectInput);
189+
190+
// We now have two projects: One with excludes and one without
191+
// Always compare the results of both to make sure a file is really excluded because of the
192+
// configuration and not because of a typo or because of it's absence in the fixture
193+
194+
t.is((await baselineProject.getReader({}).byGlob("**/manifest.json")).length, 1,
195+
"Found resource in baseline project for default style");
196+
t.is((await excludesProject.getReader({}).byGlob("**/manifest.json")).length, 0,
197+
"Did not find excluded resource for default style");
198+
199+
t.is((await baselineProject.getReader({style: "buildtime"}).byGlob("**/manifest.json")).length, 1,
200+
"Found resource in baseline project for buildtime style");
201+
t.is((await excludesProject.getReader({style: "buildtime"}).byGlob("**/manifest.json")).length, 0,
202+
"Did not find excluded resource for buildtime style");
203+
204+
t.is((await baselineProject.getReader({style: "dist"}).byGlob("**/manifest.json")).length, 1,
205+
"Found resource in baseline project for dist style");
206+
t.is((await excludesProject.getReader({style: "dist"}).byGlob("**/manifest.json")).length, 0,
207+
"Did not find excluded resource for dist style");
208+
209+
t.is((await baselineProject.getReader({style: "flat"}).byGlob("**/manifest.json")).length, 1,
210+
"Found resource in baseline project for flat style");
211+
t.is((await excludesProject.getReader({style: "flat"}).byGlob("**/manifest.json")).length, 0,
212+
"Did not find excluded resource for flat style");
213+
214+
// Excludes are not applied for "runtime" style
215+
t.is((await baselineProject.getReader({style: "runtime"}).byGlob("**/manifest.json")).length, 1,
216+
"Found resource in baseline project for runtime style");
217+
t.is((await excludesProject.getReader({style: "runtime"}).byGlob("**/manifest.json")).length, 1,
218+
"Found excluded resource for runtime style");
219+
220+
t.is((await baselineProject.getWorkspace().byGlob("**/manifest.json")).length, 1,
221+
"Found resource in baseline project for default style");
222+
t.is((await excludesProject.getWorkspace().byGlob("**/manifest.json")).length, 0,
223+
"Did not find excluded resource for default style");
224+
});
225+
226+
test("Access project resources w/ relative builder excludes", async (t) => {
227+
const {projectInput} = t.context;
228+
const baselineProject = await Specification.create(projectInput);
229+
230+
projectInput.configuration.builder = {
231+
resources: {
232+
excludes: ["manifest.json"]
233+
}
234+
};
235+
const excludesProject = await Specification.create(projectInput);
236+
237+
// We now have two projects: One with excludes and one without
238+
// Always compare the results of both to make sure a file is really excluded because of the
239+
// configuration and not because of a typo or because of it's absence in the fixture
240+
241+
t.is((await baselineProject.getReader({}).byGlob("**/manifest.json")).length, 1,
242+
"Found resource in baseline project for default style");
243+
t.is((await excludesProject.getReader({}).byGlob("**/manifest.json")).length, 0,
244+
"Did not find excluded resource for default style");
245+
246+
t.is((await baselineProject.getReader({style: "buildtime"}).byGlob("**/manifest.json")).length, 1,
247+
"Found resource in baseline project for buildtime style");
248+
t.is((await excludesProject.getReader({style: "buildtime"}).byGlob("**/manifest.json")).length, 0,
249+
"Did not find excluded resource for buildtime style");
250+
251+
t.is((await baselineProject.getReader({style: "dist"}).byGlob("**/manifest.json")).length, 1,
252+
"Found resource in baseline project for dist style");
253+
t.is((await excludesProject.getReader({style: "dist"}).byGlob("**/manifest.json")).length, 0,
254+
"Did not find excluded resource for dist style");
255+
256+
t.is((await baselineProject.getReader({style: "flat"}).byGlob("**/manifest.json")).length, 1,
257+
"Found resource in baseline project for flat style");
258+
t.is((await excludesProject.getReader({style: "flat"}).byGlob("**/manifest.json")).length, 0,
259+
"Did not find excluded resource for flat style");
260+
261+
// Excludes are not applied for "runtime" style
262+
t.is((await baselineProject.getReader({style: "runtime"}).byGlob("**/manifest.json")).length, 1,
263+
"Found resource in baseline project for runtime style");
264+
t.is((await excludesProject.getReader({style: "runtime"}).byGlob("**/manifest.json")).length, 1,
265+
"Found excluded resource for runtime style");
266+
267+
t.is((await baselineProject.getWorkspace().byGlob("**/manifest.json")).length, 1,
268+
"Found resource in baseline project for default style");
269+
t.is((await excludesProject.getWorkspace().byGlob("**/manifest.json")).length, 0,
270+
"Did not find excluded resource for default style");
271+
});
272+
273+
test("Access project resources w/ legacy builder excludes", async (t) => {
274+
const {projectInput} = t.context;
275+
const baselineProject = await Specification.create(projectInput);
276+
277+
projectInput.configuration.builder = {
278+
resources: {
279+
excludes: ["/manifest.json"]
280+
}
281+
};
282+
const excludesProject = await Specification.create(projectInput);
283+
284+
// We now have two projects: One with excludes and one without
285+
// Always compare the results of both to make sure a file is really excluded because of the
286+
// configuration and not because of a typo or because of it's absence in the fixture
287+
288+
t.is((await baselineProject.getReader({}).byGlob("**/manifest.json")).length, 1,
289+
"Found resource in baseline project for default style");
290+
t.is((await excludesProject.getReader({}).byGlob("**/manifest.json")).length, 0,
291+
"Did not find excluded resource for default style");
292+
293+
t.is((await baselineProject.getReader({style: "buildtime"}).byGlob("**/manifest.json")).length, 1,
294+
"Found resource in baseline project for buildtime style");
295+
t.is((await excludesProject.getReader({style: "buildtime"}).byGlob("**/manifest.json")).length, 0,
296+
"Did not find excluded resource for buildtime style");
297+
298+
t.is((await baselineProject.getReader({style: "dist"}).byGlob("**/manifest.json")).length, 1,
299+
"Found resource in baseline project for dist style");
300+
t.is((await excludesProject.getReader({style: "dist"}).byGlob("**/manifest.json")).length, 0,
301+
"Did not find excluded resource for dist style");
302+
303+
t.is((await baselineProject.getReader({style: "flat"}).byGlob("**/manifest.json")).length, 1,
304+
"Found resource in baseline project for flat style");
305+
t.is((await excludesProject.getReader({style: "flat"}).byGlob("**/manifest.json")).length, 0,
306+
"Did not find excluded resource for flat style");
307+
308+
// Excludes are not applied for "runtime" style
309+
t.is((await baselineProject.getReader({style: "runtime"}).byGlob("**/manifest.json")).length, 1,
310+
"Found resource in baseline project for runtime style");
311+
t.is((await excludesProject.getReader({style: "runtime"}).byGlob("**/manifest.json")).length, 1,
312+
"Found excluded resource for runtime style");
313+
314+
t.is((await baselineProject.getWorkspace().byGlob("**/manifest.json")).length, 1,
315+
"Found resource in baseline project for default style");
316+
t.is((await excludesProject.getWorkspace().byGlob("**/manifest.json")).length, 0,
317+
"Did not find excluded resource for default style");
318+
});
319+
179320
test("Modify project resources via workspace and access via flat and runtime readers", async (t) => {
180321
const {projectInput} = t.context;
181322
const project = await Specification.create(projectInput);

test/lib/specifications/types/Library.js

Lines changed: 191 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ test("Access project resources via reader w/ builder excludes", async (t) => {
169169
t.is((await excludesProject.getReader({style: "flat"}).byGlob("**/.library")).length, 0,
170170
"Did not find excluded resource for flat style");
171171

172+
// Excludes are not applied for "runtime" style
172173
t.is((await baselineProject.getReader({style: "runtime"}).byGlob("**/.library")).length, 1,
173174
"Found resource in baseline project for runtime style");
174175
t.is((await excludesProject.getReader({style: "runtime"}).byGlob("**/.library")).length, 1,
@@ -196,6 +197,196 @@ test("Access project resources via workspace w/ builder excludes", async (t) =>
196197
"Did not find excluded resource for default style");
197198
});
198199

200+
test("Access project resources via reader and workspace w/ absolute builder excludes", async (t) => {
201+
const {projectInput} = t.context;
202+
const baselineProject = await (new Library().init(projectInput));
203+
204+
projectInput.configuration.builder = {
205+
resources: {
206+
excludes: ["/resources/library/d/.library"]
207+
}
208+
};
209+
const excludesProject = await (new Library().init(projectInput));
210+
211+
// We now have two projects: One with excludes and one without
212+
// Always compare the results of both to make sure a file is really excluded because of the
213+
// configuration and not because of a typo or because of it's absence in the fixture
214+
215+
t.is((await baselineProject.getReader({}).byGlob("**/.library")).length, 1,
216+
"Found resource in baseline project for default style");
217+
t.is((await excludesProject.getReader({}).byGlob("**/.library")).length, 0,
218+
"Did not find excluded resource for default style");
219+
220+
t.is((await baselineProject.getReader({style: "buildtime"}).byGlob("**/.library")).length, 1,
221+
"Found resource in baseline project for buildtime style");
222+
t.is((await excludesProject.getReader({style: "buildtime"}).byGlob("**/.library")).length, 0,
223+
"Did not find excluded resource for buildtime style");
224+
225+
t.is((await baselineProject.getReader({style: "dist"}).byGlob("**/.library")).length, 1,
226+
"Found resource in baseline project for dist style");
227+
t.is((await excludesProject.getReader({style: "dist"}).byGlob("**/.library")).length, 0,
228+
"Did not find excluded resource for dist style");
229+
230+
t.is((await baselineProject.getReader({style: "flat"}).byGlob("**/.library")).length, 1,
231+
"Found resource in baseline project for flat style");
232+
t.is((await excludesProject.getReader({style: "flat"}).byGlob("**/.library")).length, 0,
233+
"Did not find excluded resource for flat style");
234+
235+
// Excludes are not applied for "runtime" style
236+
t.is((await baselineProject.getReader({style: "runtime"}).byGlob("**/.library")).length, 1,
237+
"Found resource in baseline project for runtime style");
238+
t.is((await excludesProject.getReader({style: "runtime"}).byGlob("**/.library")).length, 1,
239+
"Found excluded resource for runtime style");
240+
241+
t.is((await baselineProject.getWorkspace().byGlob("**/.library")).length, 1,
242+
"Found resource in baseline project for default style");
243+
t.is((await excludesProject.getWorkspace().byGlob("**/.library")).length, 0,
244+
"Did not find excluded resource for default style");
245+
});
246+
247+
test("Access project resources via reader and workspace w/ incorrect builder excludes", async (t) => {
248+
const {projectInput} = t.context;
249+
const baselineProject = await (new Library().init(projectInput));
250+
251+
projectInput.configuration.builder = {
252+
resources: {
253+
excludes: ["/.library"] // Absolute path does not match base path
254+
}
255+
};
256+
const excludesProject = await (new Library().init(projectInput));
257+
258+
// We now have two projects: One with excludes and one without
259+
// Always compare the results of both to make sure a file is really excluded because of the
260+
// configuration and not because of a typo or because of it's absence in the fixture
261+
262+
t.is((await baselineProject.getReader({}).byGlob("**/.library")).length, 1,
263+
"Found resource in baseline project for default style");
264+
t.is((await excludesProject.getReader({}).byGlob("**/.library")).length, 1,
265+
"Found resource in project with incorrect exclude for default style");
266+
267+
t.is((await baselineProject.getReader({style: "buildtime"}).byGlob("**/.library")).length, 1,
268+
"Found resource in baseline project for buildtime style");
269+
t.is((await excludesProject.getReader({style: "buildtime"}).byGlob("**/.library")).length, 1,
270+
"Found resource in project with incorrect exclude for buildtime style");
271+
272+
t.is((await baselineProject.getReader({style: "dist"}).byGlob("**/.library")).length, 1,
273+
"Found resource in baseline project for dist style");
274+
t.is((await excludesProject.getReader({style: "dist"}).byGlob("**/.library")).length, 1,
275+
"Found resource in project with incorrect exclude for dist style");
276+
277+
t.is((await baselineProject.getReader({style: "flat"}).byGlob("**/.library")).length, 1,
278+
"Can not read any test-resources for flat style");
279+
t.is((await excludesProject.getReader({style: "flat"}).byGlob("**/.library")).length, 1,
280+
"Can not read any test-resources for flat style");
281+
282+
// Excludes are not applied for "runtime" style
283+
t.is((await baselineProject.getReader({style: "runtime"}).byGlob("**/.library")).length, 1,
284+
"Found resource in baseline project for runtime style");
285+
t.is((await excludesProject.getReader({style: "runtime"}).byGlob("**/.library")).length, 1,
286+
"Found resource for runtime style");
287+
288+
t.is((await baselineProject.getWorkspace().byGlob("**/.library")).length, 1,
289+
"Found resource in baseline project for default style");
290+
t.is((await excludesProject.getWorkspace().byGlob("**/.library")).length, 1,
291+
"Found resource in project with incorrect exclude for default style");
292+
});
293+
294+
test("Access project test-resources via reader and workspace w/ absolute builder excludes", async (t) => {
295+
const {projectInput} = t.context;
296+
const baselineProject = await (new Library().init(projectInput));
297+
298+
projectInput.configuration.builder = {
299+
resources: {
300+
excludes: ["/test-resources/library/d/Test.html"]
301+
}
302+
};
303+
const excludesProject = await (new Library().init(projectInput));
304+
305+
// We now have two projects: One with excludes and one without
306+
// Always compare the results of both to make sure a file is really excluded because of the
307+
// configuration and not because of a typo or because of it's absence in the fixture
308+
309+
t.is((await baselineProject.getReader({}).byGlob("**/Test.html")).length, 1,
310+
"Found resource in baseline project for default style");
311+
t.is((await excludesProject.getReader({}).byGlob("**/Test.html")).length, 0,
312+
"Did not find excluded resource for default style");
313+
314+
t.is((await baselineProject.getReader({style: "buildtime"}).byGlob("**/Test.html")).length, 1,
315+
"Found resource in baseline project for buildtime style");
316+
t.is((await excludesProject.getReader({style: "buildtime"}).byGlob("**/Test.html")).length, 0,
317+
"Did not find excluded resource for buildtime style");
318+
319+
t.is((await baselineProject.getReader({style: "dist"}).byGlob("**/Test.html")).length, 1,
320+
"Found resource in baseline project for dist style");
321+
t.is((await excludesProject.getReader({style: "dist"}).byGlob("**/Test.html")).length, 0,
322+
"Did not find excluded resource for dist style");
323+
324+
// Test resources are not available in flat reader
325+
t.is((await baselineProject.getReader({style: "flat"}).byGlob("**/Test.html")).length, 0,
326+
"Can not read any test-resources for flat style");
327+
t.is((await excludesProject.getReader({style: "flat"}).byGlob("**/Test.html")).length, 0,
328+
"Can not read any test-resources for flat style");
329+
330+
// Excludes are not applied for "runtime" style
331+
t.is((await baselineProject.getReader({style: "runtime"}).byGlob("**/Test.html")).length, 1,
332+
"Found resource in baseline project for runtime style");
333+
t.is((await excludesProject.getReader({style: "runtime"}).byGlob("**/Test.html")).length, 1,
334+
"Found excluded resource for runtime style");
335+
336+
t.is((await baselineProject.getWorkspace().byGlob("**/Test.html")).length, 1,
337+
"Found resource in baseline project for default style");
338+
t.is((await excludesProject.getWorkspace().byGlob("**/Test.html")).length, 0,
339+
"Did not find excluded resource for default style");
340+
});
341+
342+
test("Access project test-resources via reader and workspace w/ relative builder excludes", async (t) => {
343+
const {projectInput} = t.context;
344+
const baselineProject = await (new Library().init(projectInput));
345+
346+
projectInput.configuration.builder = {
347+
resources: {
348+
excludes: ["Test.html"] // Has no effect since library excludes must be absolute or use wildcards
349+
}
350+
};
351+
const excludesProject = await (new Library().init(projectInput));
352+
353+
// We now have two projects: One with excludes and one without
354+
// Always compare the results of both to make sure a file is really excluded because of the
355+
// configuration and not because of a typo or because of it's absence in the fixture
356+
357+
t.is((await baselineProject.getReader({}).byGlob("**/Test.html")).length, 1,
358+
"Found resource in baseline project for default style");
359+
t.is((await excludesProject.getReader({}).byGlob("**/Test.html")).length, 1,
360+
"Did not find excluded resource for default style");
361+
362+
t.is((await baselineProject.getReader({style: "buildtime"}).byGlob("**/Test.html")).length, 1,
363+
"Found resource in baseline project for buildtime style");
364+
t.is((await excludesProject.getReader({style: "buildtime"}).byGlob("**/Test.html")).length, 1,
365+
"Did not find excluded resource for buildtime style");
366+
367+
t.is((await baselineProject.getReader({style: "dist"}).byGlob("**/Test.html")).length, 1,
368+
"Found resource in baseline project for dist style");
369+
t.is((await excludesProject.getReader({style: "dist"}).byGlob("**/Test.html")).length, 1,
370+
"Did not find excluded resource for dist style");
371+
372+
// Test resources are not available in flat reader
373+
t.is((await baselineProject.getReader({style: "flat"}).byGlob("**/Test.html")).length, 0,
374+
"Can not read any test-resources for flat style");
375+
t.is((await excludesProject.getReader({style: "flat"}).byGlob("**/Test.html")).length, 0,
376+
"Can not read any test-resources for flat style");
377+
378+
// Excludes are not applied for "runtime" style
379+
t.is((await baselineProject.getReader({style: "runtime"}).byGlob("**/Test.html")).length, 1,
380+
"Found resource in baseline project for runtime style");
381+
t.is((await excludesProject.getReader({style: "runtime"}).byGlob("**/Test.html")).length, 1,
382+
"Found excluded resource for runtime style");
383+
384+
t.is((await baselineProject.getWorkspace().byGlob("**/Test.html")).length, 1,
385+
"Found resource in baseline project for default style");
386+
t.is((await excludesProject.getWorkspace().byGlob("**/Test.html")).length, 1,
387+
"Did not find excluded resource for default style");
388+
});
389+
199390
test("Modify project resources via workspace and access via flat and runtime reader", async (t) => {
200391
const {projectInput} = t.context;
201392
const project = await (new Library().init(projectInput));

0 commit comments

Comments
 (0)