Skip to content

Commit

Permalink
Merge pull request #59 from karma-runner/fix-output-file
Browse files Browse the repository at this point in the history
fix: Add back `outputFile` config
  • Loading branch information
dignifiedquire committed Sep 27, 2015
2 parents e0ca1e9 + b4583b5 commit 2e5e015
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ var JUnitReporter = function (baseReporterDecorator, config, logger, helper, for
var reporterConfig = config.junitReporter || {}
var pkgName = reporterConfig.suite || ''
var outputDir = reporterConfig.outputDir
var outputFile = reporterConfig.outputFile

var suites
var pendingFileWritings = 0
Expand All @@ -30,16 +31,24 @@ var JUnitReporter = function (baseReporterDecorator, config, logger, helper, for
var timestamp = (new Date()).toISOString().substr(0, 19)
var suite = suites[browser.id] = builder.create('testsuite')
suite.att('name', browser.name)
.att('package', pkgName)
.att('timestamp', timestamp)
.att('id', 0)
.att('hostname', os.hostname())
.att('package', pkgName)
.att('timestamp', timestamp)
.att('id', 0)
.att('hostname', os.hostname())

suite.ele('properties')
.ele('property', {name: 'browser.fullName', value: browser.fullName})
.ele('property', {name: 'browser.fullName', value: browser.fullName})
}

var writeXmlForBrowser = function (browser) {
var outputFile = outputDir + 'TESTS-' + browser.name.replace(/ /g, '_') + '.xml'
var safeBrowserName = browser.name.replace(/ /g, '_')
if (outputFile != null) {
outputDir = path.join(outputDir, safeBrowserName)
outputFile = path.join(outputDir, outputFile)
} else {
outputFile = path.join(outputDir, 'TESTS-' + safeBrowserName + '.xml')
}

var xmlToOutput = suites[browser.id]
if (!xmlToOutput) {
return // don't die if browser didn't start
Expand Down

3 comments on commit 2e5e015

@budde377
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In writeXmlForBrowser you are now modifying the global variable outputFile. This means that with multiple browsers, and outputFile initially null, this will first take the second branch and then the first for subsequent browsers (in the if statement at line 45). You will then continuously concatenate the paths. That can't be right....

@4kochi
Copy link

@4kochi 4kochi commented on 2e5e015 Sep 28, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have the problem too with version 0.3.5. The path for the first browser is fine, but for the second browser the path is wrong:

28 09 2015 14:41:24.416:WARN [reporter.junit]: Cannot write JUnit xml
    ENOENT: no such file or directory, open 'myProject/reports/PhantomJS_1.9.8_(Mac_OS_X_0.0.0)/myProject/reports/TESTS-Chrome_45.0.2454_(Mac_OS_X_10.10.5).xml'

@budde377
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe these observations should be written on the issue instead of the commit. See #65

Please sign in to comment.