Skip to content
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

Adding short stack traces as an option #227

Closed
wants to merge 32 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
c25a97c
Added command line parameter to allow shorter stack traces to be outp…
AndrewJohnBenjamin Aug 13, 2014
d757f8b
Changed command to show short stack traces from string to boolean
AndrewJohnBenjamin Aug 13, 2014
ef90eae
Merge with https://github.com/cucumber/cucumber-js branch 'master'
i-e-b Nov 7, 2014
195795b
fixed tests around stack format setting.
i-e-b Nov 7, 2014
e3e1caf
Special tags to filter applicable step definition sources.
i-e-b Nov 10, 2014
315b373
Tests green
i-e-b Nov 14, 2014
4c62e12
package file changes for Sigma repo
i-e-b Nov 11, 2014
449096f
Message when failing to load steps, ignore 'node_modules' dir
i-e-b Nov 17, 2014
bb9288b
bump
i-e-b Nov 17, 2014
cb700f1
Updated the table object to include a method that gets the row for th…
AndrewJohnBenjamin Nov 19, 2014
b2ca0f6
getRowForKey on table data
i-e-b Nov 19, 2014
8f27b1e
Added a command line option that tells cucumber to trigger a breakpoi…
AndrewJohnBenjamin Nov 25, 2014
0a72950
Bumped Version Number : 0.4.7
AndrewJohnBenjamin Nov 25, 2014
a97320a
Merge pull request #2 from AndrewJohnBenjamin/master
i-e-b Nov 26, 2014
307588b
Merging sigmaNPM package changes
i-e-b Mar 4, 2015
077e37c
Bringing Sigma changes up to most recent official line
i-e-b Mar 4, 2015
cb1f2c5
npm bump
i-e-b Mar 4, 2015
bfb081f
Merging upstream
i-e-b Mar 24, 2015
b77d134
Basic tests passing again
i-e-b Mar 24, 2015
3b23ab8
mapping file locations in short stack traces
i-e-b Mar 24, 2015
24123b7
Closes #1
i-e-b Mar 24, 2015
ffb77c4
Find step definitions given a line in feature file
i-e-b Mar 25, 2015
b90e3a5
npm bump
i-e-b Mar 25, 2015
302e89f
Option to show unused step definitions
i-e-b Mar 26, 2015
49b2e57
Ability to defer scenarios based on steps
i-e-b Mar 26, 2015
e99bec6
npm version bump
i-e-b Mar 27, 2015
1a587e3
bug fix for long paths
i-e-b Mar 27, 2015
89587fc
Bug fixes against deferred code check
i-e-b Mar 30, 2015
dbe2e09
bringing before/after tag use back into line
i-e-b Mar 30, 2015
2c00ec1
Defer across features
i-e-b Mar 30, 2015
914054d
npm bump 0.4.16
i-e-b Mar 30, 2015
7d022b4
Merge pull request #1 from i-e-b/master
AndrewJohnBenjamin Apr 2, 2015
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ node_modules
doc/
tmp/
npm-debug.log
*.orig
3 changes: 3 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ node_modules
doc/
tmp/
Procfile
example/
features/
spec/
2 changes: 2 additions & 0 deletions features/asynchronous_failing_steps.feature
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
@featureTag @ft2
Feature: Asynchronous failing steps

@scentag
Scenario: see asynchronously failing scenarios
Given the following feature:
"""
Expand Down
2 changes: 1 addition & 1 deletion lib/cucumber.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ Cucumber.Type = require('./cucumber/type');
Cucumber.Util = require('./cucumber/util');
Cucumber.VolatileConfiguration = require('./cucumber/volatile_configuration');

Cucumber.VERSION = '0.4.8';
Cucumber.VERSION = '0.4.10';

module.exports = Cucumber;
1 change: 1 addition & 0 deletions lib/cucumber/ast/assembler.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// vim: noai:ts=2:sw=2
function Assembler(features, filter) {
var currentFeature, currentFeatureElement, currentStep, suggestedFeature;
var stashedTags = [];
Expand Down
28 changes: 28 additions & 0 deletions lib/cucumber/ast/data_table.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,34 @@ function DataTable() {
return rawRows;
},

getRowForKey: function(key, aliases)
{
var positionOfPrimaryKey = 0;
var matchingRow = null;

if(key === null)
return null;

if (rowsCollection.length <= 1)
return null;

rowsCollection.syncForEach(function (row)
{
var rawRow = row.raw();
var cellValue = aliases ? aliases[rawRow[positionOfPrimaryKey]] : rawRow[positionOfPrimaryKey];

if(cellValue === null || cellValue === undefined)
return;

if (cellValue.trim() === key.trim())
{
matchingRow = rawRow;
}
});

return matchingRow;
},

hashes: function hashes() {
var raw = self.raw();
var hashDataTable = Cucumber.Type.HashDataTable(raw);
Expand Down
11 changes: 8 additions & 3 deletions lib/cucumber/ast/feature.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// vim: noai:ts=2:sw=2
function Feature(keyword, name, description, uri, line) {
var Cucumber = require('../../cucumber');

Expand Down Expand Up @@ -77,6 +78,10 @@ function Feature(keyword, name, description, uri, line) {
return featureElements.length() > 0;
},

getFeatureElements: function getFeatureElements() {
return featureElements;
},

addTags: function setTags(newTags) {
tags = tags.concat(newTags);
},
Expand All @@ -101,9 +106,9 @@ function Feature(keyword, name, description, uri, line) {
},

instructVisitorToVisitScenarios: function instructVisitorToVisitScenarios(visitor, callback) {
featureElements.forEach(function (scenario, iterate) {
visitor.visitScenario(scenario, iterate);
}, callback);
featureElements.forEach(function (scenario, iterate, allowDefer) {
visitor.visitScenario(scenario, iterate, allowDefer);
}, callback, true);
}
};
return self;
Expand Down
6 changes: 4 additions & 2 deletions lib/cucumber/ast/scenario.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// vim: noai:ts=2:sw=2
function Scenario(keyword, name, description, uri, line) {
var Cucumber = require('../../cucumber');

Expand Down Expand Up @@ -94,8 +95,9 @@ function Scenario(keyword, name, description, uri, line) {
},

instructVisitorToVisitSteps: function instructVisitorToVisitSteps(visitor, steps, callback) {
steps.forEach(function (step, iterate) {
visitor.visitStep(step, iterate);
var tagNames = self.getTags().map(function(t){return t.getName();});
steps.forEach(function(step, iterate) {
visitor.visitStep(step, iterate, tagNames);
}, callback);
}
};
Expand Down
12 changes: 11 additions & 1 deletion lib/cucumber/ast/step.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
// vim: noai:ts=2:sw=2
function Step(keyword, name, uri, line) {
var Cucumber = require('../../cucumber');
var docString, dataTable, previousStep;
var tags = [];

var self = {
setTags:function setTags(tagNames) {
tags = tagNames;
},

getTags: function getTags() {
return tags;
},

setPreviousStep: function setPreviousStep(newPreviousStep) {
previousStep = newPreviousStep;
},
Expand Down Expand Up @@ -150,7 +160,7 @@ function Step(keyword, name, uri, line) {
},

getStepDefinition: function getStepDefinition(visitor) {
return visitor.lookupStepDefinitionByName(name);
return visitor.lookupStepDefinitionByName(name, tags);
},

execute: function execute(visitor, callback) {
Expand Down
14 changes: 14 additions & 0 deletions lib/cucumber/cli.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// vim: noai:ts=2:sw=2:colorcolumn=80
function Cli(argv) {
var Cucumber = require('../cucumber');

Expand Down Expand Up @@ -66,6 +67,19 @@ function Cli(argv) {
summary : prints a summary only, after all\n\
scenarios were executed\n\
\n\
--shortStackTraces Show only top stack frame for errors\n\
\n\
--findStepDef Find a step definition for a feature file line\n\
Example:\n\
--findStepDef specification.feature:24\n\
Outputs file with location, like\n\
~/support/mydefs.js:86\n\
\n\
--brkOnSupportCodeLoaded Trigger a debugger break once support code\n\
is loaded.\n\
\n\
--unusedSteps Show unused step definitions\n\
\n\
-i, --no-snippets Don't print snippets for pending steps.\n\
\n\
-S, --strict Fail if there are any undefined or pending steps.\n\
Expand Down
29 changes: 29 additions & 0 deletions lib/cucumber/cli/argument_parser.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// vim: noai:ts=2:sw=2
function ArgumentParser(argv) {
var Cucumber = require('../../cucumber');

Expand Down Expand Up @@ -57,16 +58,29 @@ function ArgumentParser(argv) {
return tagGroups;
},

getStackFormat: function getStackFormat() {
var stackFormat = self.getOptionOrDefault(ArgumentParser.USE_SHORT_STACK_OPTION_NAME , ArgumentParser.DEFAULT_USE_SHORT_STACK_VALUE);
return stackFormat;
},

getFormat: function getFormat() {
var format = self.getOptionOrDefault(ArgumentParser.FORMAT_OPTION_NAME, ArgumentParser.DEFAULT_FORMAT_VALUE);
return format;
},

getBreakOnSupportCodeLoaded: function getBreakOnSupportCodeLoaded() {
var breakOnSupportCodeLoaded = self.getOptionOrDefault(ArgumentParser.BRK_ON_SUPPORT_CODE_LOADED, ArgumentParser.DEFAULT_BRK_ON_SUPPORT_CODE_LOADED);
return breakOnSupportCodeLoaded;
},

getKnownOptionDefinitions: function getKnownOptionDefinitions() {
var definitions = {};
definitions[ArgumentParser.REQUIRE_OPTION_NAME] = [path, Array];
definitions[ArgumentParser.TAGS_OPTION_NAME] = [String, Array];
definitions[ArgumentParser.FIND_STEP_DEFINITION] = [String, String];
definitions[ArgumentParser.FORMAT_OPTION_NAME] = String;
definitions[ArgumentParser.USE_SHORT_STACK_OPTION_NAME] = Boolean;
definitions[ArgumentParser.SHOW_UNUSED_STEPS] = Boolean;
definitions[ArgumentParser.HELP_FLAG_NAME] = Boolean;
definitions[ArgumentParser.VERSION_FLAG_NAME] = Boolean;
definitions[ArgumentParser.COFFEE_SCRIPT_SNIPPETS_FLAG_NAME] = Boolean;
Expand All @@ -85,6 +99,14 @@ function ArgumentParser(argv) {
return definitions;
},

findStepDef: function findStepDef(){
return self.getOptionOrDefault(ArgumentParser.FIND_STEP_DEFINITION);
},

shouldShowUnusedSteps: function findStepDef(){
return self.getOptionOrDefault(ArgumentParser.SHOW_UNUSED_STEPS, ArgumentParser.DEFAULT_UNUSED_STEPS);
},

isStrictRequested: function isStrictRequested() {
return self.getOptionOrDefault(ArgumentParser.STRICT_FLAG_NAME, ArgumentParser.DEFAULT_STRICT_FLAG_VALUE);
},
Expand Down Expand Up @@ -136,6 +158,13 @@ ArgumentParser.FORMAT_OPTION_SHORT_NAME = 'f';
ArgumentParser.DEFAULT_FORMAT_VALUE = 'progress';
ArgumentParser.TAGS_OPTION_NAME = 'tags';
ArgumentParser.TAGS_OPTION_SHORT_NAME = 't';
ArgumentParser.USE_SHORT_STACK_OPTION_NAME = 'shortStackTraces';
ArgumentParser.SHOW_UNUSED_STEPS = 'unusedSteps';
ArgumentParser.DEFAULT_UNUSED_STEPS = false;
ArgumentParser.BRK_ON_SUPPORT_CODE_LOADED = 'brkOnSupportCodeLoaded';
ArgumentParser.FIND_STEP_DEFINITION = 'findStepDef';
ArgumentParser.DEFAULT_BRK_ON_SUPPORT_CODE_LOADED = false;
ArgumentParser.DEFAULT_USE_SHORT_STACK_VALUE = false;
ArgumentParser.HELP_FLAG_NAME = 'help';
ArgumentParser.HELP_FLAG_SHORT_NAME = 'h';
ArgumentParser.STRICT_FLAG_NAME = 'strict';
Expand Down
29 changes: 21 additions & 8 deletions lib/cucumber/cli/argument_parser/path_expander.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// vim: noai:ts=2:sw=2
var fs = require('fs');
var path = require('path');
var _ = require('underscore');
var walk = require('walkdir');

var PathExpander = {
expandPathsWithRegexp: function expandPathsWithRegexp(paths, regexp) {
Expand Down Expand Up @@ -31,13 +32,25 @@ var PathExpander = {
},

expandDirectoryWithRegexp: function expandDirectoryWithRegexp(directory, regexp) {
var paths = [];
var scannedPaths = walk.sync(directory);
scannedPaths.forEach(function (path) {
if (regexp.test(path))
paths.push(path);
});
return paths;
var results = [];

var recur = function recurseDirectory(dir) {
var xs = fs.readdirSync(dir);
xs.forEach(function (p) {
var x = path.join(dir, p);
var s = fs.statSync(x);

if (s.isFile() && regexp.test(x)) {
return results.push(x);
}
if (s.isDirectory()) {
if (p !== 'node_modules') return recurseDirectory(x);
}
});
};

recur(directory);
return results;
}
};
module.exports = PathExpander;
24 changes: 20 additions & 4 deletions lib/cucumber/cli/configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ function Configuration(argv) {
return formatter;
},

getStackFormat: function getStackFormat() {
return argumentParser.getStackFormat();
},

getFeatureSources: function getFeatureSources() {
var featureFilePaths = argumentParser.getFeatureFilePaths();
var featureSourceLoader = Cucumber.Cli.FeatureSourceLoader(featureFilePaths);
Expand All @@ -46,6 +50,12 @@ function Configuration(argv) {
var supportCodeFilePaths = argumentParser.getSupportCodeFilePaths();
var supportCodeLoader = Cucumber.Cli.SupportCodeLoader(supportCodeFilePaths);
var supportCodeLibrary = supportCodeLoader.getSupportCodeLibrary();

/*jshint -W087 */
if(argumentParser.getBreakOnSupportCodeLoaded())
debugger;
/*jshint +W087 */

return supportCodeLibrary;
},

Expand All @@ -59,6 +69,10 @@ function Configuration(argv) {
return rules;
},

findStepDef: function findStepDef() {
return argumentParser.findStepDef();
},

getSingleScenarioAstFilterRule: function getSingleScenarioAstFilterRule() {
var rule = Cucumber.Ast.Filter.ScenarioAtLineRule();
return rule;
Expand All @@ -76,14 +90,16 @@ function Configuration(argv) {
return argumentParser.isVersionRequested();
},

shouldShowUnusedSteps: function shouldShowUnusedSteps() {
return argumentParser.shouldShowUnusedSteps();
},

shouldSnippetsBeInCoffeeScript: function shouldSnippetsBeInCoffeeScript() {
var coffeeDisplay = argumentParser.shouldSnippetsBeInCoffeeScript();
return coffeeDisplay;
return argumentParser.shouldSnippetsBeInCoffeeScript();
},

shouldSnippetsBeShown: function shouldSnippetsBeShown() {
var snippetsDisplay = argumentParser.shouldSnippetsBeShown();
return snippetsDisplay;
return argumentParser.shouldSnippetsBeShown();
}

};
Expand Down
30 changes: 19 additions & 11 deletions lib/cucumber/cli/support_code_loader.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// vim: noai:ts=2:sw=2
var os = require('os');

function SupportCodeLoader(supportCodeFilePaths) {
var Cucumber = require('../../cucumber');
var CoffeeScript = require('coffee-script');
Expand All @@ -25,19 +25,19 @@ function SupportCodeLoader(supportCodeFilePaths) {

getPrimeSupportCodeInitializer: function getPrimeSupportCodeInitializer() {
var primeSupportCodeFilePaths = self.getPrimeSupportCodeFilePaths();
var primeSupportCodeInitializer = self.buildSupportCodeInitializerFromPaths(primeSupportCodeFilePaths);
var primeSupportCodeInitializer = self.buildSupportCodeInitializerFromPaths(primeSupportCodeFilePaths, 'primary');
return primeSupportCodeInitializer;
},
},

getSecondarySupportCodeInitializer: function getSecondarySupportCodeBlocks() {
var secondarySupportCodeFilePaths = self.getSecondarySupportCodeFilePaths();
var secondarySupportCodeInitializer = self.buildSupportCodeInitializerFromPaths(secondarySupportCodeFilePaths);
var secondarySupportCodeInitializer = self.buildSupportCodeInitializerFromPaths(secondarySupportCodeFilePaths, 'secondary');
return secondarySupportCodeInitializer;
},

getPrimeSupportCodeFilePaths: function getPrimeSupportCodeFilePaths() {
var primeSupportCodeFilePaths = [];
supportCodeFilePaths.forEach(function (path) {
supportCodeFilePaths.forEach(function(path) {
if (path.match(SupportCodeLoader.PRIME_SUPPORT_CODE_PATH_REGEXP))
primeSupportCodeFilePaths.push(path);
});
Expand All @@ -46,20 +46,28 @@ function SupportCodeLoader(supportCodeFilePaths) {

getSecondarySupportCodeFilePaths: function getSecondarySupportCodeFilePaths() {
var secondarySupportCodeFilePaths = [];
supportCodeFilePaths.forEach(function (path) {

supportCodeFilePaths.forEach(function(path) {
if (!path.match(SupportCodeLoader.PRIME_SUPPORT_CODE_PATH_REGEXP))
secondarySupportCodeFilePaths.push(path);
});
return secondarySupportCodeFilePaths;
},

buildSupportCodeInitializerFromPaths: function buildSupportCodeInitializerFromPaths(paths) {
var wrapper = function () {
buildSupportCodeInitializerFromPaths: function buildSupportCodeInitializerFromPaths(paths, codeType) {
var wrapper = function(){
var supportCodeHelper = this;
paths.forEach(function (path) {
paths.forEach(function(path) {
global.CUKE_SUPPORT_CODE_TYPE = codeType;
global.CUKE_LAST_CODE_PATH = path; // TODO: *Really* need a better way to for this
var initializer = require(path);
if (typeof(initializer) === 'function')
initializer.call(supportCodeHelper);
if (typeof(initializer) === 'function') {
try {
initializer.call(supportCodeHelper);
} catch (err) {
console.error('COULD NOT LOAD STEPS AT "'+path+'": '+err);
}
}
});
};
return wrapper;
Expand Down
Loading