Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] Console: Handle consequitive builds correctly #479

Merged
merged 1 commit into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/writers/Console.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ class Console {
}

#handleBuildMetadataEvent({projectsToBuild}) {
this.#projectMetadata = new Map();
projectsToBuild.forEach((projectName) => {
this.#projectMetadata.set(projectName, {
buildStarted: false,
Expand Down
97 changes: 97 additions & 0 deletions test/lib/writers/Console.js
Original file line number Diff line number Diff line change
Expand Up @@ -870,3 +870,100 @@ test.serial("Disable: Stops progress bar", (t) => {
t.is(stderrWriteStub.callCount, 1, "Logged one message");
});

test.serial("Build metadata events (multiple projects)", (t) => {
const {stderrWriteStub} = t.context;
process.emit("ui5.build-metadata", {
projectsToBuild: ["project.a"]
});

process.emit("ui5.build-status", {
level: "verbose", // Should not get logged
projectName: "project.a",
projectType: "project-type",
status: "project-build-start",
});

process.emit("ui5.build-status", {
level: "info",
projectName: "project.a",
projectType: "project-type",
status: "project-build-end",
});

// Independent build of another project
process.emit("ui5.build-metadata", {
projectsToBuild: ["project.b"]
});

process.emit("ui5.build-status", {
level: "verbose", // Should not get logged
projectName: "project.b",
projectType: "project-type",
status: "project-build-start",
});

process.emit("ui5.build-status", {
level: "info",
projectName: "project.b",
projectType: "project-type",
status: "project-build-end",
});


t.is(stderrWriteStub.callCount, 2, "Logged one message");
t.is(stripAnsi(stderrWriteStub.getCall(0).args[0]),
`info Project 1 of 1: ${figures.tick} Finished building project-type project project.a\n`,
"Logged expected message");
t.is(stripAnsi(stderrWriteStub.getCall(1).args[0]),
`info Project 1 of 1: ${figures.tick} Finished building project-type project project.b\n`,
"Logged expected message");
});

test.serial("Build metadata events (same project)", (t) => {
const {stderrWriteStub} = t.context;
process.emit("ui5.build-metadata", {
projectsToBuild: ["project.a"]
});

process.emit("ui5.build-status", {
level: "verbose", // Should not get logged
projectName: "project.a",
projectType: "project-type",
status: "project-build-start",
});

process.emit("ui5.build-status", {
level: "info",
projectName: "project.a",
projectType: "project-type",
status: "project-build-end",
});

// Repeated build of the same project
process.emit("ui5.build-metadata", {
projectsToBuild: ["project.a"]
});

process.emit("ui5.build-status", {
level: "verbose", // Should not get logged
projectName: "project.a",
projectType: "project-type",
status: "project-build-start",
});

process.emit("ui5.build-status", {
level: "info",
projectName: "project.a",
projectType: "project-type",
status: "project-build-end",
});


t.is(stderrWriteStub.callCount, 2, "Logged one message");
t.is(stripAnsi(stderrWriteStub.getCall(0).args[0]),
`info Project 1 of 1: ${figures.tick} Finished building project-type project project.a\n`,
"Logged expected message");
t.is(stripAnsi(stderrWriteStub.getCall(1).args[0]),
`info Project 1 of 1: ${figures.tick} Finished building project-type project project.a\n`,
"Logged expected message");
});