Skip to content

Commit 5531cd9

Browse files
committed
test(project): Add another multiple-task / tag handling case
1 parent a516158 commit 5531cd9

4 files changed

Lines changed: 113 additions & 0 deletions

File tree

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
let buildRanOnce;
2+
module.exports = async function ({
3+
workspace, taskUtil,
4+
options: {projectNamespace}
5+
}) {
6+
console.log("Custom task 0 executed");
7+
8+
// Read a file to trigger execution of this task:
9+
const testJS = await workspace.byPath(`/resources/${projectNamespace}/test.js`);
10+
11+
if (buildRanOnce != true) {
12+
console.log("Flag NOT set -> We are in #1 Build still");
13+
buildRanOnce = true;
14+
taskUtil.setTag(testJS, taskUtil.STANDARD_TAGS.IsDebugVariant);
15+
} else {
16+
console.log("Flag set -> We are in #2 Build");
17+
taskUtil.setTag(testJS, taskUtil.STANDARD_TAGS.OmitFromBuildResult);
18+
}
19+
};
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
let buildRanOnce;
2+
module.exports = async function ({
3+
workspace, taskUtil,
4+
options: {projectNamespace}
5+
}) {
6+
console.log("Custom task 1 executed");
7+
8+
// Read a file to trigger execution of this task:
9+
const testJS = await workspace.byPath(`/resources/${projectNamespace}/test.js`);
10+
11+
if (buildRanOnce != true) {
12+
console.log("Flag NOT set -> We are in #1 Build still");
13+
buildRanOnce = true;
14+
const tag = taskUtil.getTag(testJS, taskUtil.STANDARD_TAGS.IsDebugVariant);
15+
if (!tag) {
16+
throw new Error("Tag set during #1 Build is not readable, which is UNEXPECTED.");
17+
}
18+
} else {
19+
console.log("Flag set -> We are in #2 Build");
20+
const tag = taskUtil.getTag(testJS, taskUtil.STANDARD_TAGS.OmitFromBuildResult);
21+
if (!tag) {
22+
throw new Error("Tag set during #2 Build is not readable, which is UNEXPECTED.");
23+
}
24+
}
25+
};
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
specVersion: "5.0"
3+
type: application
4+
metadata:
5+
name: application.a
6+
builder:
7+
customTasks:
8+
- name: custom-task-0
9+
afterTask: minify
10+
- name: custom-task-1
11+
afterTask: custom-task-0
12+
---
13+
specVersion: "5.0"
14+
kind: extension
15+
type: task
16+
metadata:
17+
name: custom-task-0
18+
task:
19+
path: custom-tasks-2/custom-task-0.js
20+
---
21+
specVersion: "5.0"
22+
kind: extension
23+
type: task
24+
metadata:
25+
name: custom-task-1
26+
task:
27+
path: custom-tasks-2/custom-task-1.js

packages/project/test/lib/build/ProjectBuilder.integration.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,48 @@ test.serial("Build application.a (multiple custom tasks)", async (t) => {
319319
});
320320
});
321321

322+
test.serial.skip("Build application.a (multiple custom tasks 2)", async (t) => {
323+
const fixtureTester = new FixtureTester(t, "application.a");
324+
const destPath = fixtureTester.destPath;
325+
326+
// This test should cover a scenario with multiple custom tasks.
327+
// Specifically, it's invalidating the task cache by only modifying tags on resources,
328+
// but not the resources themselves.
329+
330+
// #1 build (no cache, no changes, with custom tasks)
331+
// During this build, "custom-task-0" sets the tag "isDebugVariant" to test.js.
332+
// "custom-task-1" checks if it's able to read this tag.
333+
await fixtureTester.buildProject({
334+
graphConfig: {rootConfigPath: "ui5-multiple-customTasks-2.yaml"},
335+
config: {destPath, cleanDest: true},
336+
assertions: {
337+
projects: {
338+
"application.a": {}
339+
}
340+
}
341+
});
342+
343+
344+
// #2 build (with cache, no changes, with custom tasks)
345+
// During this build, "custom-task-0" sets a different tag to test.js (namely "OmitFromBuildResult").
346+
// "custom-task-1" again checks if it's able to read this different tag.
347+
// It's expected that both custom tasks are not getting skipped during this build,
348+
// even though any resources weren't modified.
349+
// FIXME: Currently, the entire build is skipped and therefore the custom tasks are not executed.
350+
await fixtureTester.buildProject({
351+
graphConfig: {rootConfigPath: "ui5-multiple-customTasks-2.yaml"},
352+
config: {destPath, cleanDest: true},
353+
assertions: {
354+
projects: {
355+
"application.a": {} // TODO: add non-relevant skippedTasks here, once the tag handling works
356+
}
357+
}
358+
});
359+
360+
// Check that test.js is omitted from build output:
361+
await t.throwsAsync(fs.readFile(`${destPath}/test.js`, {encoding: "utf8"}));
362+
});
363+
322364
test.serial("Build library.d project multiple times", async (t) => {
323365
const fixtureTester = new FixtureTester(t, "library.d");
324366
const destPath = fixtureTester.destPath;

0 commit comments

Comments
 (0)