Skip to content

Commit

Permalink
Factorize tests selection code in task provider.
Browse files Browse the repository at this point in the history
  • Loading branch information
agrojean-ledger committed Nov 28, 2024
1 parent 68c5dfe commit 77d45f2
Showing 1 changed file with 9 additions and 28 deletions.
37 changes: 9 additions & 28 deletions src/taskProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,7 @@ export class TaskProvider implements vscode.TaskProvider {
return exec;
}

private functionalTestsExec(): string {
private getSelectedTests(): string {
let testsSelection = "";
if (this.selectedTests) {
testsSelection = "-k \"";
Expand All @@ -610,6 +610,11 @@ export class TaskProvider implements vscode.TaskProvider {
}
testsSelection += this.selectedTests[this.selectedTests.length - 1] + "\"";
}
return testsSelection;
}

private functionalTestsExec(): string {
let testsSelection = this.getSelectedTests();
// Runs functional tests inside the docker container (with Qt display disabled).
const exec = `docker exec -it ${this.containerName} bash -c 'pytest ${
this.functionalTestsDir
Expand All @@ -618,15 +623,7 @@ export class TaskProvider implements vscode.TaskProvider {
}

private functionalTestsDisplayExec(): string {
let testsSelection = "";
if (this.selectedTests) {
testsSelection = "-k \"";
// Create list with "or" separator for pytest selection (the last 'or' is not needed)
for (let i = 0; i < this.selectedTests.length - 1; i++) {
testsSelection += this.selectedTests[i] + " or ";
}
testsSelection += this.selectedTests[this.selectedTests.length - 1] + "\"";
}
let testsSelection = this.getSelectedTests();
// Runs functional tests inside the docker container (with Qt display enabled).
const exec = `docker exec -it ${this.containerName} bash -c 'pytest ${
this.functionalTestsDir
Expand All @@ -635,15 +632,7 @@ export class TaskProvider implements vscode.TaskProvider {
}

private functionalTestsGoldenRunExec(): string {
let testsSelection = "";
if (this.selectedTests) {
testsSelection = "-k \"";
// Create list with "or" separator for pytest selection (the last 'or' is not needed)
for (let i = 0; i < this.selectedTests.length - 1; i++) {
testsSelection += this.selectedTests[i] + " or ";
}
testsSelection += this.selectedTests[this.selectedTests.length - 1] + "\"";
}
let testsSelection = this.getSelectedTests();
// Runs functional tests inside the docker container (with Qt display disabled and '--golden_run' option).
const exec = `docker exec -it ${this.containerName} bash -c 'pytest ${
this.functionalTestsDir
Expand All @@ -652,15 +641,7 @@ export class TaskProvider implements vscode.TaskProvider {
}

private functionalTestsDisplayOnDeviceExec(): string {
let testsSelection = "";
if (this.selectedTests) {
testsSelection = "-k \"";
// Create list with "or" separator for pytest selection (the last 'or' is not needed)
for (let i = 0; i < this.selectedTests.length - 1; i++) {
testsSelection += this.selectedTests[i] + " or ";
}
testsSelection += this.selectedTests[this.selectedTests.length - 1] + "\"";
}
let testsSelection = this.getSelectedTests();
// Runs functional tests inside the docker container (with Qt display enabled) on real device.
const exec = `docker exec -it ${this.containerName} bash -c 'pytest ${
this.functionalTestsDir
Expand Down

0 comments on commit 77d45f2

Please sign in to comment.