feat: bru.setNextRequest(null) breaks execution without error

This commit is contained in:
Martin Hoecker 2023-11-01 23:41:37 +01:00
parent 129d659628
commit 8183ce03c5
No known key found for this signature in database
GPG Key ID: DD1434854AB52DD0
3 changed files with 15 additions and 8 deletions

View File

@ -371,13 +371,19 @@ const handler = async function (argv) {
collectionRoot
);
results.push(result);
// determine next request
const nextRequestName = result?.nextRequestName;
if (nextRequestName) {
if (nextRequestName !== undefined) {
nJumps++;
if (nJumps > 10000) {
console.error(chalk.red(`Too many jumps, possible infinite loop`));
process.exit(1);
}
if (nextRequestName === null) {
break;
}
const nextRequestIdx = bruJsons.findIndex((iter) => iter.bruJson.name === nextRequestName);
if (nextRequestIdx >= 0) {
currentRequestIndex = nextRequestIdx;
@ -388,8 +394,6 @@ const handler = async function (argv) {
} else {
currentRequestIndex++;
}
results.push(result);
}
const summary = printRunSummary(results);

View File

@ -77,7 +77,7 @@ const runSingleRequest = async function (
processEnvVars,
scriptingConfig
);
if (result?.nextRequestName) {
if (result?.nextRequestName !== undefined) {
nextRequestName = result.nextRequestName;
}
}
@ -252,7 +252,7 @@ const runSingleRequest = async function (
processEnvVars,
scriptingConfig
);
if (result?.nextRequestName) {
if (result?.nextRequestName !== undefined) {
nextRequestName = result.nextRequestName;
}
}

View File

@ -710,7 +710,7 @@ const registerNetworkIpc = (mainWindow) => {
scriptingConfig
);
if (preRequestScriptResult?.nextRequestName) {
if (preRequestScriptResult?.nextRequestName !== undefined) {
nextRequestName = preRequestScriptResult.nextRequestName;
}
@ -802,7 +802,7 @@ const registerNetworkIpc = (mainWindow) => {
scriptingConfig
);
if (postRequestScriptResult?.nextRequestName) {
if (postRequestScriptResult?.nextRequestName !== undefined) {
nextRequestName = postRequestScriptResult.nextRequestName;
}
@ -866,11 +866,14 @@ const registerNetworkIpc = (mainWindow) => {
...eventData
});
}
if (nextRequestName) {
if (nextRequestName !== undefined) {
nJumps++;
if (nJumps > 10000) {
throw new Error('Too many jumps, possible infinite loop');
}
if (nextRequestName === null) {
break;
}
const nextRequestIdx = folderRequests.findIndex((request) => request.name === nextRequestName);
if (nextRequestIdx >= 0) {
currentRequestIndex = nextRequestIdx;