Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export async function getFailures(log: ToolingLog, testReportPath: string) {
const xml = await readAsync(testReportPath, 'utf8');
// Parses junit XML files
const report: TestReport = await xml2js.parseStringPromise(xml);
// Grab the failures. Reporters may report multiple testsuites in a single file.
const testSuites = 'testsuites' in report ? report.testsuites.testsuite : [report.testsuite];
const failures: TestFailure[] = [];
for (const testSuite of testSuites) {
for (const testCase of testSuite.testcase) {
const { failure } = testCase;
if (!failure) {
continue;
}
// unwrap xml weirdness
const failureCase: TestFailure = {
...testCase.$,
export async function parseTestReport(xml: string): Promise {
return await xml2js.parseStringPromise(xml);
}
async function injectMetricsCollectorIntoPomXmlForSpring(pathToPomXml) {
const originalPomXmlFileData = await fs.readFile(pathToPomXml);
const originalPomXml = await xml2js.parseStringPromise(originalPomXmlFileData);
const newPomXmlInJsonFormat = getNewContentsOfPomXmlForSpring(originalPomXml);
const xmlBuilder = new xml2js.Builder();
const newPomXml = xmlBuilder.buildObject(newPomXmlInJsonFormat);
log.debug(`Injecting metrics collector into project's pom.xml, which is now:\n${newPomXml}`);
await fs.writeFile(pathToPomXml, newPomXml);
}
async function injectMetricsCollectorIntoPomXml(pathToPomXml) {
const originalPomXmlFileData = await fs.readFile(pathToPomXml);
const originalPomXml = await xml2js.parseStringPromise(originalPomXmlFileData);
const newPomXmlInJsonFormat = getNewContentsOfPomXml(originalPomXml);
const xmlBuilder = new xml2js.Builder();
const newPomXml = xmlBuilder.buildObject(newPomXmlInJsonFormat);
log.trace(`Injecting metrics collector into project's pom.xml, which is now ${util.inspect(newPomXml)}`);
await fs.writeFile(pathToPomXml, newPomXml);
}
async function readWSDLFile(filePath: string) {
const xmlData = await fs.readFile(filePath, 'utf8');
const json = await xml2js.parseStringPromise(xmlData, {
explicitArray: false,
});
return castTypeUsingSchema(json, WSDLSchema) as WSDL;
}