Skip to content

Commit 72d126e

Browse files
committed
Fix on CLI offline install and offline test runner
1 parent d5db6fb commit 72d126e

11 files changed

+91
-62
lines changed

.github/workflows/test_offline.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ jobs:
5656
uses: actions/download-artifact@v5
5757
with:
5858
pattern: build-info-*-${{ matrix.package_name }}
59-
merge-multiple: true
6059
path: ./artifacts
6160
github-token: ${{ secrets.GITHUB_TOKEN }}
6261
run-id: ${{ inputs.run_id }}

tests/CLIRunner.test.js

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -60,40 +60,47 @@ function testRun(jsonScript) {
6060
if (test.type === "prerequisites") {
6161
//route for prerequisites tests
6262

63-
describe(`Test${test.id} - ${test.name} ->`, function () {
63+
describe(`Test${test.id}- ${test.name} |`, function () {
6464
this.timeout(20000);
6565

66-
runCLIPrerequisitesTest(pathToEIMCLI);
66+
runCLIPrerequisitesTest({ id: `${test.id}1`, pathToEim: pathToEIMCLI });
6767
});
6868
} else if (test.type === "arguments") {
6969
//routine for arguments tests
7070

71-
describe(`Test${test.id} - ${test.name} ->`, function () {
71+
describe(`Test${test.id}- ${test.name} |`, function () {
7272
this.timeout(20000);
7373

74-
runCLIArgumentsTest(pathToEIMCLI, EIMCLIVersion);
74+
runCLIArgumentsTest({
75+
id: `${test.id}1`,
76+
pathToEim: pathToEIMCLI,
77+
eimVersion: EIMCLIVersion,
78+
});
7579
});
7680
} else if (test.type === "default") {
7781
//routine for default installation tests
7882

7983
const deleteAfterTest = test.deleteAfterTest ?? true;
8084
const testProxyMode = test.testProxyMode ?? false;
8185

82-
describe(`Test${test.id} - ${test.name} ->`, function () {
86+
describe(`Test${test.id}- ${test.name} |`, function () {
8387
this.timeout(6000000);
8488

8589
runCLIWizardInstallTest({
90+
id: `${test.id}1`,
8691
pathToEim: pathToEIMCLI,
8792
testProxyMode,
8893
});
8994

9095
runInstallVerification({
96+
id: `${test.id}2`,
9197
installFolder: INSTALLFOLDER,
9298
idfList: [IDFDefaultVersion],
9399
toolsFolder: TOOLSFOLDER,
94100
});
95101

96102
runCleanUp({
103+
id: `${test.id}3`,
97104
installFolder: INSTALLFOLDER,
98105
toolsFolder: TOOLSFOLDER,
99106
deleteAfterTest,
@@ -145,19 +152,22 @@ function testRun(jsonScript) {
145152
this.timeout(6000000);
146153

147154
runCLICustomInstallTest({
155+
id: `${test.id}1`,
148156
pathToEim: pathToEIMCLI,
149157
args: installArgs,
150158
testProxyMode,
151159
});
152160

153161
runInstallVerification({
162+
id: `${test.id}2`,
154163
installFolder,
155164
idfList: idfUpdatedList,
156165
targetList,
157166
toolsFolder: TOOLSFOLDER,
158167
});
159168

160169
runCleanUp({
170+
id: `${test.id}3`,
161171
installFolder,
162172
toolsFolder: TOOLSFOLDER,
163173
deleteAfterTest,
@@ -181,6 +191,7 @@ function testRun(jsonScript) {
181191
this.timeout(60000);
182192

183193
runVersionManagementTest({
194+
id: `${test.id}1`,
184195
pathToEim: pathToEIMCLI,
185196
idfList: idfUpdatedList,
186197
installFolder,
@@ -194,29 +205,22 @@ function testRun(jsonScript) {
194205
describe(`Test${test.id} - ${test.name} ->`, async function () {
195206
this.timeout(6000000);
196207

197-
const pathToOfflineArchive = await downloadOfflineArchive({
198-
idfVersion: IDFDefaultVersion,
199-
});
200-
201-
const offlineArg = [
202-
`${
203-
runInDebug ? "-vvv " : ""
204-
}--use-local-archive "${pathToOfflineArchive}"`,
205-
];
206-
207208
runCLICustomInstallTest({
209+
id: `${test.id}1`,
208210
pathToEim: pathToEIMCLI,
209-
args: offlineArg,
211+
offlineIDFVersion: IDFDefaultVersion,
210212
testProxyMode,
211213
});
212214

213215
runInstallVerification({
216+
id: `${test.id}2`,
214217
installFolder: INSTALLFOLDER,
215218
idfList: [IDFDefaultVersion],
216219
toolsFolder: TOOLSFOLDER,
217220
});
218221

219222
runCleanUp({
223+
id: `${test.id}3`,
220224
installFolder: INSTALLFOLDER,
221225
toolsFolder: TOOLSFOLDER,
222226
deleteAfterTest,

tests/helper.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { IDFDefaultVersion, pkgName } from "./config.js";
33
import { Readable } from "stream";
44
import { finished } from "stream/promises";
55
import os from "os";
6+
import fs from "fs";
67
import path from "path";
78

89
// Base url for offline archive files

tests/offlineRunner.test.js

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,30 +18,35 @@ import {
1818
pathToEIMCLI,
1919
INSTALLFOLDER,
2020
TOOLSFOLDER,
21-
downloadOfflineArchive,
2221
runInDebug,
2322
pathToBuildInfo,
2423
} from "./config.js";
24+
import { downloadOfflineArchive } from "./helper.js";
2525
import os from "os";
2626
import path from "path";
2727
import fs from "fs";
2828

2929
let buildInfo = {};
3030

3131
if (fs.existsSync(pathToBuildInfo)) {
32-
const files = fs
33-
.readdirSync(pathToBuildInfo)
34-
.filter((file) => file.endsWith(".json"));
35-
files.forEach((file) => {
36-
const filePath = path.join(pathToBuildInfo, file);
37-
try {
38-
const content = fs.readFileSync(filePath, "utf8");
39-
const jsonData = JSON.parse(content);
40-
buildInfo[file] = jsonData;
41-
} catch (err) {
42-
logger.error(`Failed to read or parse ${file}: ${err.message}`);
43-
}
44-
});
32+
function readJsonFilesRecursively(dir) {
33+
const entries = fs.readdirSync(dir, { withFileTypes: true });
34+
entries.forEach((entry) => {
35+
const fullPath = path.join(dir, entry.name);
36+
if (entry.isDirectory()) {
37+
readJsonFilesRecursively(fullPath);
38+
} else if (entry.isFile() && entry.name.endsWith(".json")) {
39+
try {
40+
const content = fs.readFileSync(fullPath, "utf8");
41+
const jsonData = JSON.parse(content);
42+
buildInfo[fullPath] = jsonData;
43+
} catch (err) {
44+
logger.error(`Failed to read or parse ${fullPath}: ${err.message}`);
45+
}
46+
}
47+
});
48+
}
49+
readJsonFilesRecursively(pathToBuildInfo);
4550
} else {
4651
logger.error(`Directory not found: ${pathToBuildInfo}`);
4752
}

tests/scripts/CLIArguments.test.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import { describe, it, before, after, beforeEach, afterEach } from "mocha";
33
import CLITestRunner from "../classes/CLITestRunner.class.js";
44
import logger from "../classes/logger.class.js";
55

6-
export function runCLIArgumentsTest(pathToEim, eimVersion) {
7-
describe("Basic Arguments ->", function () {
6+
export function runCLIArgumentsTest({ id, pathToEim, eimVersion }) {
7+
describe(`${id}- Basic Arguments |`, function () {
88
let testRunner = null;
99

1010
beforeEach(function () {
@@ -26,15 +26,15 @@ export function runCLIArgumentsTest(pathToEim, eimVersion) {
2626
testRunner = null;
2727
});
2828

29-
it("should show correct version number", async function () {
29+
it("1- should show correct version number", async function () {
3030
logger.info(`Starting test - show correct version`);
3131
await testRunner.start();
3232
testRunner.sendInput(`${pathToEim} -V`);
3333
const meetVersion = await testRunner.waitForOutput(eimVersion, 15000);
3434
expect(meetVersion, "EIM showing incorrect version number").to.be.true;
3535
});
3636

37-
it("should show help with --help argument", async function () {
37+
it("2- should show help with --help argument", async function () {
3838
logger.info(`Starting test - show help`);
3939
await testRunner.start();
4040
testRunner.sendInput(`${pathToEim} --help`);
@@ -45,7 +45,7 @@ export function runCLIArgumentsTest(pathToEim, eimVersion) {
4545
);
4646
});
4747

48-
it("should handle invalid arguments", async function () {
48+
it("3- should handle invalid arguments", async function () {
4949
logger.info(`Starting test - invalid argument`);
5050
await testRunner.start();
5151
testRunner.sendInput(`${pathToEim} --KK`);

tests/scripts/CLICustomInstall.test.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ import logger from "../classes/logger.class.js";
55
import TestProxy from "../classes/TestProxy.class.js";
66

77
export function runCLICustomInstallTest({
8+
id,
89
pathToEim,
910
args = [],
11+
offlineIDFVersion = null,
1012
testProxyMode = false,
1113
}) {
12-
describe("1- Run custom ->", function () {
14+
describe(`${id}- Run custom |`, function () {
1315
let testRunner = null;
1416
let proxy = null;
1517

@@ -19,6 +21,13 @@ export function runCLICustomInstallTest({
1921
);
2022
this.timeout(5000);
2123
testRunner = new CLITestRunner();
24+
if (offlineIDFVersion) {
25+
const pathToOfflineArchive = await downloadOfflineArchive({
26+
idfVersion: offlineIDFVersion,
27+
});
28+
29+
args.push(`--use-local-archive "${pathToOfflineArchive}"`);
30+
}
2231
if (testProxyMode) {
2332
try {
2433
proxy = new TestProxy({ mode: testProxyMode });
@@ -71,7 +80,7 @@ export function runCLICustomInstallTest({
7180
*
7281
*/
7382

74-
it("Should install IDF using specified parameters", async function () {
83+
it("1- Should install IDF using specified parameters", async function () {
7584
logger.info(`Starting test - IDF custom installation`);
7685
testRunner.sendInput(`${pathToEim} install ${args.join(" ")}`);
7786
await new Promise((resolve) => setTimeout(resolve, 5000));

tests/scripts/CLIPrerequisites.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import path from "path";
1616
*
1717
*/
1818

19-
export function runCLIPrerequisitesTest(pathToEim) {
19+
export function runCLIPrerequisitesTest({ id, pathToEim }) {
2020
// let pathToEim;
2121

2222
// if (process.env.EIM_FILE_PATH) {
@@ -25,7 +25,7 @@ export function runCLIPrerequisitesTest(pathToEim) {
2525
// pathToEim = path.join(os.homedir(), "eim-cli/eim");
2626
// }
2727

28-
describe("Check for prerequisites ->", function () {
28+
describe(`${id}- Check for prerequisites |`, function () {
2929
this.timeout(600000);
3030
let testRunner;
3131

@@ -69,7 +69,7 @@ export function runCLIPrerequisitesTest(pathToEim) {
6969
}
7070
});
7171

72-
it("Should detect missing requirements", async function () {
72+
it("1- Should detect missing requirements", async function () {
7373
logger.info(`Starting test - confirm requirements are missing`);
7474
this.timeout(25000);
7575
const missingRequisites = await testRunner.waitForOutput(
@@ -100,7 +100,7 @@ export function runCLIPrerequisitesTest(pathToEim) {
100100
}
101101
});
102102

103-
it("should offer to install prerequisites and exit upon negative answer", async function () {
103+
it("1- should offer to install prerequisites and exit upon negative answer", async function () {
104104
logger.info(`Starting test - confirm requirements are missing`);
105105
this.timeout(25000);
106106
const promptRequisites = await testRunner.waitForOutput(

tests/scripts/CLIVersionManagement.test.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@ import path from "path";
66
import fs from "fs";
77

88
export function runVersionManagementTest({
9+
id,
910
pathToEim,
1011
idfList,
1112
installFolder,
1213
}) {
13-
describe("3- EIM Version Management test ->", function () {
14+
describe(`${id}- EIM Version Management test |`, function () {
1415
this.timeout(120000);
1516
let testRunner = null;
1617
let testStepFailed = false;
@@ -51,7 +52,7 @@ export function runVersionManagementTest({
5152
logger.info("Version Management test Completed");
5253
});
5354

54-
it("1 - EIM list should show available IDF versions", async function () {
55+
it("1- EIM list should show available IDF versions", async function () {
5556
/**
5657
* This test executes eim list command and checks if the expected IDF versions
5758
* are present in the output, with the correct path
@@ -74,7 +75,7 @@ export function runVersionManagementTest({
7475
}
7576
});
7677

77-
it("2 - Select active IDF installation", async function () {
78+
it("2- Select active IDF installation", async function () {
7879
/**
7980
* This test executes eim select command and checks if the IDF version is set as
8081
* active correctly
@@ -143,7 +144,7 @@ export function runVersionManagementTest({
143144
).to.be.true;
144145
});
145146

146-
it("3 - EIM rename should rename existing installation", async function () {
147+
it("3- EIM rename should rename existing installation", async function () {
147148
/**
148149
* This test executes eim rename command and checks if the IDF version is renamed correctly
149150
*
@@ -199,7 +200,7 @@ export function runVersionManagementTest({
199200
.true;
200201
});
201202

202-
it("4 - EIM remove should delete existing installation", async function () {
203+
it("4- EIM remove should delete existing installation", async function () {
203204
/**
204205
* This test executes eim remove command and checks if the IDF version is removed correctly
205206
*
@@ -277,7 +278,7 @@ export function runVersionManagementTest({
277278
).to.be.true;
278279
});
279280

280-
it("5 - EIM purge should remove all IDF installations", async function () {
281+
it("5- EIM purge should remove all IDF installations", async function () {
281282
/**
282283
* This test executes eim purge command and checks if all IDF versions and tools are removed correctly
283284
*

tests/scripts/CLIWizardInstall.test.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,12 @@ import TestProxy from "../classes/TestProxy.class.js";
1212
import logger from "../classes/logger.class.js";
1313
import os from "os";
1414

15-
export function runCLIWizardInstallTest({ pathToEim, testProxyMode = false }) {
16-
describe("1- Run wizard ->", function () {
15+
export function runCLIWizardInstallTest({
16+
id,
17+
pathToEim,
18+
testProxyMode = false,
19+
}) {
20+
describe(`${id}- Run wizard |`, function () {
1721
let testRunner = null;
1822
let installationFailed = false;
1923
let proxy = null;
@@ -76,7 +80,7 @@ export function runCLIWizardInstallTest({ pathToEim, testProxyMode = false }) {
7680
*
7781
*/
7882

79-
it("Should install IDF using wizard and default values", async function () {
83+
it("1- Should install IDF using wizard and default values", async function () {
8084
logger.info(`Starting test - IDF installation wizard`);
8185
this.timeout(3660000);
8286
testRunner.sendInput(`${pathToEim} ${runInDebug ? "-vvv " : ""}wizard`);

0 commit comments

Comments
 (0)