@@ -30012,7 +30012,7 @@ async function run() {
30012
30012
});
30013
30013
// Parse k6 command output and extract test run URLs if running in cloud mode.
30014
30014
// Also, print the output to the console, excluding the progress lines.
30015
- child.stdout?.on('data', (data) => (0, k6OutputParser_1.parseK6Output)(data, isCloud ? TEST_RESULT_URLS_MAP : null , TOTAL_TEST_RUNS));
30015
+ child.stdout?.on('data', (data) => (0, k6OutputParser_1.parseK6Output)(data, TEST_RESULT_URLS_MAP, TOTAL_TEST_RUNS));
30016
30016
return child;
30017
30017
}
30018
30018
}
@@ -30083,7 +30083,7 @@ function extractTestRunUrl(data, testResultUrlsMap) {
30083
30083
* @param {string} data - The k6 command output data as string
30084
30084
* @param {TestResultUrlsMap} testResultUrlsMap - The map containing the script path and output URL
30085
30085
*
30086
- * @returns {void}
30086
+ * @returns {boolean} - Returns true if the script path and output URL were successfully extracted and added to the map. Otherwise, returns false.
30087
30087
*
30088
30088
*/
30089
30089
// Extracting the script path
@@ -30094,6 +30094,55 @@ function extractTestRunUrl(data, testResultUrlsMap) {
30094
30094
const output = outputMatch ? outputMatch[1] : null;
30095
30095
if (scriptPath && output) {
30096
30096
testResultUrlsMap[scriptPath] = output;
30097
+ return true;
30098
+ }
30099
+ else {
30100
+ return false;
30101
+ }
30102
+ }
30103
+ function checkIfK6ASCIIArt(data) {
30104
+ /**
30105
+ * This function checks if the given data is the k6 ASCII art or not.
30106
+ *
30107
+ * @param {string} data - The data to check
30108
+ *
30109
+ * @returns {boolean} - Returns true if the data is the k6 ASCII art. Otherwise, returns false.
30110
+ *
30111
+ * The k6 ASCII art is as follows:
30112
+ *
30113
+ *
30114
+ *
30115
+ * /\ |‾‾| /‾‾/ /‾‾/
30116
+ * /\ / \ | |/ / / /
30117
+ * / \/ \ | ( / ‾‾\
30118
+ * / \ | |\ \ | (‾) |
30119
+ * / __________ \ |__| \__\ \_____/ .io
30120
+ *
30121
+ * To determine if the data is the k6 ASCII art, the function checks the following:
30122
+ * 1. The function checks if the data contains only the following characters:
30123
+ * |, ' ', '\n', '/', '‾', '(', ')', '_', '.', 'i', 'o'
30124
+ *
30125
+ * 2. The function also checks if the data contains ".io" at the end.
30126
+ *
30127
+ * */
30128
+ if (!data.includes(".io")) {
30129
+ return false;
30130
+ }
30131
+ let K6_ASCII_ART_CHARS = [
30132
+ '|', ' ', '\n', '/',
30133
+ '‾', '(', ')', '_',
30134
+ '.', 'i', 'o', '\\'
30135
+ ], dataChars = new Set(data);
30136
+ if (dataChars.size !== K6_ASCII_ART_CHARS.length) {
30137
+ return false;
30138
+ }
30139
+ else {
30140
+ for (let char of dataChars) {
30141
+ if (!K6_ASCII_ART_CHARS.includes(char)) {
30142
+ return false;
30143
+ }
30144
+ }
30145
+ return true;
30097
30146
}
30098
30147
}
30099
30148
function parseK6Output(data, testResultUrlsMap, totalTestRuns) {
@@ -30111,7 +30160,17 @@ function parseK6Output(data, testResultUrlsMap, totalTestRuns) {
30111
30160
const dataString = data.toString(), lines = dataString.split('\n');
30112
30161
// Extract test run URLs
30113
30162
if (testResultUrlsMap && Object.keys(testResultUrlsMap).length < totalTestRuns) {
30114
- extractTestRunUrl(dataString, testResultUrlsMap);
30163
+ if (extractTestRunUrl(dataString, testResultUrlsMap)) {
30164
+ // Test URL was extracted successfully and added to the map.
30165
+ // Ignore further output parsing for this data.
30166
+ return;
30167
+ }
30168
+ if (checkIfK6ASCIIArt(dataString)) {
30169
+ // Ignore the k6 ASCII art.
30170
+ // Checking the k6 ASCII art here because it is printed at the start of execution,
30171
+ // hence if all the test URLs are extracted, the ASCII art will not be printed.
30172
+ return;
30173
+ }
30115
30174
}
30116
30175
const filteredLines = lines.filter((line) => {
30117
30176
const isRegexMatch = REGEX_EXPRESSIONS.runningIteration.test(line) || REGEX_EXPRESSIONS.runProgress.test(line);
0 commit comments