-
Notifications
You must be signed in to change notification settings - Fork 326
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #159 from kalviumcommunity/enh/nodejs-eval-PMF
New eval mode in multifile
- Loading branch information
Showing
7 changed files
with
163 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
JUNIT: 'junit' | ||
} |
1 change: 1 addition & 0 deletions
1
enums/supportedMultifileSetupTypes.js → enums/supportedPMFTypes.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
module.exports = { | ||
FRONTEND_STATIC_JASMINE: 'frontend_static_jasmine', | ||
FRONTEND_REACT_JASMINE: 'frontend_react_jasmine', | ||
NODEJS_JUNIT: 'nodejs_junit', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
const logger = require('../loader').helpers.l | ||
|
||
const initExeca = async () => { | ||
const module = await import('execa') | ||
return module.execa | ||
} | ||
|
||
const runCommand = async (command, workingDir) => { | ||
const execa = await initExeca() | ||
logger.info(`Executing: ${command}`); | ||
try { | ||
const result = await execa(command, { | ||
cwd: workingDir, | ||
shell: true, // Usefull for npm commands having '&&' | ||
stdio: 'inherit', | ||
preferLocal: true, // Use local binaries if available | ||
localDir: workingDir, | ||
reject: false, // Don't throw on non-zero exit code | ||
}) | ||
|
||
if (result.failed) { | ||
throw new Error(`Command failed with exit code ${result.exitCode}`) | ||
} | ||
return result | ||
} catch (error) { | ||
if (error.exitCode !== undefined) { | ||
logger.error(`Command exited with code ${error.exitCode}`) | ||
if (error.stderr) logger.error(`Error output: ${error.stderr}`) | ||
} else if (error.signal) { | ||
logger.error(`Command was killed with signal ${error.signal}`) | ||
} else { | ||
logger.error(`Command failed to execute: ${error.message}`) | ||
} | ||
throw error | ||
} | ||
} | ||
|
||
const runCommandsSequentially = async ( | ||
commands, | ||
workingDir = process.cwd() | ||
) => { | ||
for (const command of commands) { | ||
try { | ||
await runCommand(command, workingDir) | ||
} catch (error) { | ||
logger.error(`Error executing "${command}"`) | ||
if (error.stdout) logger.info(`Command output: ${error.stdout}`) | ||
throw new Error(`Command sequence failed at: ${command}`) | ||
} | ||
} | ||
logger.info("All commands completed successfully") | ||
} | ||
|
||
module.exports = { runCommandsSequentially } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
const logger = require('../loader').helpers.l | ||
const fs = require('fs') | ||
const xml2js = require('xml2js') | ||
|
||
// recursively process all the test suites | ||
const processTestSuite = (testsuite, success, failed) => { | ||
if (testsuite.testsuite) { | ||
testsuite.testsuite.forEach(suite => processTestSuite(suite, success, failed)) | ||
} | ||
if (testsuite.testcase) { | ||
testsuite.testcase.forEach(testcase => { | ||
const testName = testcase.$.name | ||
|
||
if (testcase.failure) { | ||
failed.push(testName) | ||
} else { | ||
success.push(testName) | ||
} | ||
}) | ||
} | ||
} | ||
|
||
const extractTestCasesJunit = async (xmlFilePath) => { | ||
try { | ||
const xmlData = await fs.promises.readFile(xmlFilePath, 'utf8') | ||
const parser = new xml2js.Parser() | ||
const result = await parser.parseStringPromise(xmlData) | ||
|
||
const success = [] | ||
const failed = [] | ||
|
||
// Start processing from the root | ||
if (result.testsuites) { | ||
processTestSuite(result.testsuites, success, failed) | ||
} | ||
|
||
return { success, failed } | ||
} catch (error) { | ||
logger.error(`Error processing XML file: ${error.message}`) | ||
throw error | ||
} | ||
} | ||
|
||
module.exports = { extractTestCasesJunit } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters