Skip to content

Commit 4829c62

Browse files
enhancements
1 parent 1cda030 commit 4829c62

File tree

1 file changed

+32
-27
lines changed

1 file changed

+32
-27
lines changed

commands/utils/batch/batch_runner.js

Lines changed: 32 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -43,37 +43,37 @@ function run_test(payload, env = "prod", rejectUnauthorized,lt_config) {
4343
}
4444
if (run_on_hyper) {
4545
try {
46-
await executeHyperExecuteCLI(
46+
await executeHyperExecuteCLI(
4747
lt_config["lambdatest_auth"]["username"],
4848
lt_config["lambdatest_auth"]["access_key"],
4949
"he_conv.yaml",
5050
env,
5151
lt_config["run_settings"]["sync"]
5252
);
53-
let jobID = getLastJobIDFromLog();
54-
let build_id;
55-
try {
56-
if (jobID) {
57-
build_id = await pollJobStatus(
58-
jobID,
59-
lt_config["lambdatest_auth"]["username"],
60-
lt_config["lambdatest_auth"]["access_key"],
61-
env
62-
);
53+
let jobID = getLastJobIDFromLog(lt_config);
54+
let build_id;
55+
try {
56+
if (jobID) {
57+
build_id = await pollJobStatus(
58+
jobID,
59+
lt_config["lambdatest_auth"]["username"],
60+
lt_config["lambdatest_auth"]["access_key"],
61+
env
62+
);
63+
}
64+
} catch (error) {
65+
console.log("could not fetch build id ", error);
6366
}
64-
} catch (error) {
65-
console.log("could not fetch build id ", error);
66-
}
67-
//Write session_id to a file
68-
data = { build_id: build_id, session_id: jobID };
69-
fs.writeFileSync(
70-
"lambdatest_run.json",
71-
JSON.stringify(data, null, 3)
72-
);
73-
console.log(
74-
`Uploaded tests successfully Check Dashboard : ${constants.Dashboard_URL[env]}${build_id}`
75-
);
76-
resolve({ session_id: jobID, hyperexecute: true });
67+
//Write session_id to a file
68+
data = { build_id: build_id, session_id: jobID };
69+
fs.writeFileSync(
70+
"lambdatest_run.json",
71+
JSON.stringify(data, null, 3)
72+
);
73+
console.log(
74+
`Uploaded tests successfully Check Dashboard : ${constants.Dashboard_URL[env]}${build_id}`
75+
);
76+
resolve({ session_id: jobID, hyperexecute: true });
7777
} catch (error) {
7878
run_on_hyper = false;
7979
try {
@@ -210,7 +210,7 @@ async function executeHyperExecuteCLI(username, accessKey, yamlFile, env,sync) {
210210
// console.log("HyperExecute CLI executed successfully");
211211
}
212212

213-
function getLastJobIDFromLog() {
213+
function getLastJobIDFromLog(lt_config) {
214214
let lastJobID = null;
215215
try {
216216
const logFilePath = path.join("hyperexecute-cli.log");
@@ -221,7 +221,10 @@ function getLastJobIDFromLog() {
221221
while ((match = jobIDPattern.exec(logContent)) !== null) {
222222
lastJobID = match[1];
223223
}
224-
fs.unlinkSync(logFilePath); // Delete the file after reading
224+
225+
if(!lt_config.run_settings.verbose){
226+
fs.unlinkSync(logFilePath); // Delete the file after reading
227+
}
225228
} catch (error) {
226229
console.log("Error in reading log file ", error);
227230
throw error;
@@ -273,8 +276,10 @@ function downloadHyperExecuteCLI(env) {
273276
} else {
274277
return reject(new Error('Unsupported OS type'));
275278
}
276-
277279
const filePath = path.join(__dirname, binaryfileName);
280+
if (fs.existsSync(filePath)) {
281+
return resolve(filePath);
282+
}
278283
const file = fs.createWriteStream(filePath);
279284

280285
https.get(downloadUrl, (response) => {

0 commit comments

Comments
 (0)