-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added support for writing output to file (close #90) #188
Conversation
this PR is invalidated by #215 As a side note this output redirect is quite simple using a unix pipe via the command line. +1 to close |
@samccone I am not sure that I am totally agreed. Please clarify if I understand incorrectly. For example, the currentl json formatter does not have a way to output file. Use unix pipe will include other output before and after cucumber runner. Thus, we should still have a way to output to a file from any formatter. Once it is outputted into a file, we can start customizing it. |
I agree to @jlin412, there is no possibility to get the output of the formatter only to file. This should be made possible in Cucumber.js. I think my pull request is not perfect, but at least a working setup. Missing this functionality is a showstopper for our Cucumber.js use (running it in Jenkins). |
Ok, cool I have been convinced. Lets get the to the finish line. So regardless of the formatter we want to redirect console.log to a file correct? |
@stejanse Please excuse my ignorance. Is this the same as nicolassenechal/cucumber-js@b337b18? |
Yes, he merged my commit into his repository. |
@stejanse can you rebase this off of master please |
I rebased the pull request. |
thanks so much @stejanse :) |
Thanks! Could you add I still think this should disappear once we got #215 merged in. Each plugin (or formatter) should be configurable and passed an output file path. It will also cause troubles once we allow multiple formatters (#91) as the |
|
||
finish: function finish(result) { | ||
if (configuration.getReportFile() !== null) { | ||
fs.writeFileSync(configuration.getReportFile(), listeners.getLast().getLogs(), { flag: 'w' }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need to pass the flag option here since it defaults to w
http://nodejs.org/api/fs.html#fs_fs_writefile_filename_data_options_callback
We will want to add a feature test to this also to test how it all works. Thanks again for the work |
+1 |
I processed all feedback in this thread! Let me know if there are still some issues. |
@jbpros Is it possible to have this PR merged into next minor release? |
@jlin412 that is the plan, I am planing on doing a release early next week |
perfect. Though I hope that a fix for On Thu, Aug 21, 2014 at 9:57 AM, Sam Saccone [email protected]
|
Any hold up before this can get merged? |
Any news on this ? I see the Travis CI build failed? |
As a work around this seems to work from AndreKanig
|
Would be great to get this in. Had to add a really kludgy hack to get cucumber-js to function in jenkins where we need to pickup the cucumber json and junit formats. var Cucumber = require('cucumber');
var CucumberJunit = require('cucumber-junit');
var cli = Cucumber.Cli(process.argv);
var fs = require('fs-extra');
var reportFileJson = "cucumber-reports/cucumber.json";
var reportFileJunit = "cucumber-reports/cucumber.xml";
var configuration = Cucumber.Cli.Configuration(process.argv);
var handler = function(succeeded) {
var code = succeeded ? 0 : 1;
var report = formatter.getLogs();
fs.outputFile(reportFileJson, report, function(err) {
if(err) {
return console.log("Error saving report => " + err);
}
console.log()
console.log("Cucumber report saved to " + reportFileJson);
fs.outputFile(reportFileJunit, CucumberJunit(report), function(err) {
if(err) {
return console.log("Error saving report => " + err);
}
console.log("Cucumber junit report save to " + reportFileJunit);
});
});
process.on('exit', function () {
process.exit(code);
});
var timeoutId = setTimeout(function () {
console.error('Cucumber process timed out after waiting 60 seconds for the node.js event loop to empty. There may be a resource leak. Have all resources like database connections and network connections been closed properly?');
process.exit(code);
}, 60 * 1000);
if (timeoutId.unref) {
timeoutId.unref();
}
else {
clearTimeout(timeoutId);
}
};
if (configuration.isHelpRequested()) {
cli.displayHelp(handler);
}
else if (configuration.isVersionRequested()) {
cli.displayVersion(handler);
}
else {
var runtime = Cucumber.Runtime(configuration);
var formatter = configuration.getFormatter();
runtime.attachListener(formatter);
runtime.start(handler);
} |
closing in favor of #425 |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Implemented CLI argument --report for specifying a file location to which the formatter output will be written.