use of io.cucumber.core.feature.FeatureWithLines in project cucumber-jvm by cucumber.
the class CucumberOptionsAnnotationParser method addFeatures.
private void addFeatures(CucumberOptions options, RuntimeOptionsBuilder args) {
if (options != null && options.features().length != 0) {
for (String feature : options.features()) {
if (feature.startsWith("@")) {
Path rerunFile = Paths.get(feature.substring(1));
args.addRerun(parseFeatureWithLinesFile(rerunFile));
} else {
FeatureWithLines featureWithLines = FeatureWithLines.parse(feature);
args.addFeature(featureWithLines);
}
}
featuresSpecified = true;
}
}
use of io.cucumber.core.feature.FeatureWithLines in project cucumber-jvm by cucumber.
the class RerunFormatter method finishReport.
private void finishReport() {
for (Map.Entry<URI, Collection<Integer>> entry : featureAndFailedLinesMapping.entrySet()) {
FeatureWithLines featureWithLines = create(relativize(entry.getKey()), entry.getValue());
out.println(featureWithLines.toString());
}
out.close();
}
use of io.cucumber.core.feature.FeatureWithLines in project cucumber-jvm by cucumber.
the class CommandlineOptionsParser method parse.
private RuntimeOptionsBuilder parse(List<String> args) {
args = new ArrayList<>(args);
RuntimeOptionsBuilder parsedOptions = new RuntimeOptionsBuilder();
while (!args.isEmpty()) {
String arg = args.remove(0).trim();
if (arg.equals(HELP) || arg.equals(HELP_SHORT)) {
printUsage();
exitCode = 0;
return parsedOptions;
} else if (arg.equals(VERSION) || arg.equals(VERSION_SHORT)) {
out.println(CORE_VERSION);
exitCode = 0;
return parsedOptions;
} else if (arg.equals(I18N)) {
String nextArg = removeArgFor(arg, args);
exitCode = printI18n(nextArg);
return parsedOptions;
} else if (arg.equals(THREADS)) {
int threads = Integer.parseInt(removeArgFor(arg, args));
if (threads < 1) {
out.println("--threads must be > 0");
exitCode = 1;
return parsedOptions;
}
parsedOptions.setThreads(threads);
} else if (arg.equals(GLUE) || arg.equals(GLUE_SHORT)) {
String gluePath = removeArgFor(arg, args);
URI parse = GluePath.parse(gluePath);
parsedOptions.addGlue(parse);
} else if (arg.equals(TAGS) || arg.equals(TAGS_SHORT)) {
parsedOptions.addTagFilter(TagExpressionParser.parse(removeArgFor(arg, args)));
} else if (arg.equals(PUBLISH)) {
parsedOptions.setPublish(true);
} else if (arg.equals(PLUGIN) || arg.equals(PLUGIN_SHORT)) {
String pluginName = removeArgFor(arg, args);
if (pluginName.equals("null_summary")) {
log.warn(() -> "Use '--no-summary' instead of '-p/--plugin null_summary'. '-p/--plugin null_summary' will be removed in a future release.");
parsedOptions.setNoSummary();
} else if (pluginName.equals("default_summary")) {
log.warn(() -> "Use '-p/--plugin summary' instead of '-p/--plugin default_summary'. '-p/--plugin default_summary' will be removed in a future release.");
parsedOptions.addPluginName("summary");
} else {
parsedOptions.addPluginName(pluginName);
}
} else if (arg.equals(DRY_RUN) || arg.equals(DRY_RUN_SHORT)) {
parsedOptions.setDryRun(true);
} else if (arg.equals(NO_DRY_RUN)) {
parsedOptions.setDryRun(false);
} else if (arg.equals(NO_SUMMARY)) {
parsedOptions.setNoSummary();
} else if (arg.equals(MONOCHROME) || arg.equals(MONOCHROME_SHORT)) {
parsedOptions.setMonochrome(true);
} else if (arg.equals(NO_MONOCHROME)) {
parsedOptions.setMonochrome(false);
} else if (arg.equals(SNIPPETS)) {
String nextArg = removeArgFor(arg, args);
parsedOptions.setSnippetType(SnippetTypeParser.parseSnippetType(nextArg));
} else if (arg.equals(NAME) || arg.equals(NAME_SHORT)) {
String nextArg = removeArgFor(arg, args);
Pattern pattern = Pattern.compile(nextArg);
parsedOptions.addNameFilter(pattern);
} else if (arg.equals(WIP) || arg.equals(WIP_SHORT)) {
parsedOptions.setWip(true);
} else if (arg.equals(ORDER)) {
parsedOptions.setPickleOrder(PickleOrderParser.parse(removeArgFor(arg, args)));
} else if (arg.equals(COUNT)) {
int count = Integer.parseInt(removeArgFor(arg, args));
if (count < 1) {
out.println("--count must be > 0");
exitCode = 1;
return parsedOptions;
}
parsedOptions.setCount(count);
} else if (arg.equals(OBJECT_FACTORY)) {
String objectFactoryClassName = removeArgFor(arg, args);
parsedOptions.setObjectFactoryClass(parseObjectFactory(objectFactoryClassName));
} else if (arg.startsWith("-")) {
out.println("Unknown option: " + arg);
printUsage();
exitCode = 1;
return parsedOptions;
} else if (!arg.isEmpty()) {
if (arg.startsWith("@")) {
Path rerunFile = Paths.get(arg.substring(1));
parsedOptions.addRerun(parseFeatureWithLinesFile(rerunFile));
} else {
FeatureWithLines featureWithLines = FeatureWithLines.parse(arg);
parsedOptions.addFeature(featureWithLines);
}
}
}
return parsedOptions;
}
use of io.cucumber.core.feature.FeatureWithLines in project cucumber-jvm by cucumber.
the class CucumberOptionsAnnotationParser method addDefaultFeaturePathIfNoFeaturePathIsSpecified.
private void addDefaultFeaturePathIfNoFeaturePathIsSpecified(RuntimeOptionsBuilder args, Class<?> clazz) {
if (!featuresSpecified) {
String packageName = packagePath(clazz);
FeatureWithLines featureWithLines = FeatureWithLines.parse(packageName);
args.addFeature(featureWithLines);
}
}
use of io.cucumber.core.feature.FeatureWithLines in project cucumber-jvm by cucumber.
the class OptionsFileParser method parseFeatureWithLinesFile.
static Collection<FeatureWithLines> parseFeatureWithLinesFile(Path path) {
try {
List<FeatureWithLines> featurePaths = new ArrayList<>();
readAllLines(path).forEach(line -> {
Matcher matcher = RERUN_PATH_SPECIFICATION.matcher(line);
while (matcher.find()) {
featurePaths.add(FeatureWithLines.parse(matcher.group(1)));
}
});
return featurePaths;
} catch (Exception e) {
throw new CucumberException(format("Failed to parse '%s'", path), e);
}
}
Aggregations