@@ -31,6 +31,7 @@ public class RuntimeOptions {
31
31
32
32
private final List <String > glue = new ArrayList <String >();
33
33
private final List <Object > filters = new ArrayList <Object >();
34
+ private final List <Object > lineFilters = new ArrayList <Object >();
34
35
private final List <Formatter > formatters = new ArrayList <Formatter >();
35
36
private final List <String > featurePaths = new ArrayList <String >();
36
37
private final FormatterFactory formatterFactory ;
@@ -47,12 +48,13 @@ public RuntimeOptions(Env env, String... argv) {
47
48
RuntimeOptions (Env env , FormatterFactory formatterFactory , String ... argv ) {
48
49
this .formatterFactory = formatterFactory ;
49
50
50
- parse (new ArrayList <String >(asList (argv )), false );
51
+ parse (new ArrayList <String >(asList (argv )));
51
52
52
53
String cucumberOptionsFromEnv = env .get ("cucumber.options" );
53
54
if (cucumberOptionsFromEnv != null ) {
54
- parse (shellWords (cucumberOptionsFromEnv ), true );
55
+ parse (shellWords (cucumberOptionsFromEnv ));
55
56
}
57
+ filters .addAll (lineFilters );
56
58
57
59
if (formatters .isEmpty ()) {
58
60
formatters .add (formatterFactory .create ("progress" ));
@@ -73,15 +75,12 @@ private List<String> shellWords(String cmdline) {
73
75
return matchList ;
74
76
}
75
77
76
- private void parse (List <String > args , boolean clobberFeaturePathsAndGlue ) {
78
+ private void parse (List <String > args ) {
77
79
List <Object > parsedFilters = new ArrayList <Object >();
80
+ List <Object > parsedLineFilters = new ArrayList <Object >();
81
+ List <String > parsedFeaturePaths = new ArrayList <String >();
82
+ List <String > parsedGlue = new ArrayList <String >();
78
83
79
- List <String > oldFeaturePaths = new ArrayList <String >(featurePaths );
80
- List <String > oldGlue = new ArrayList <String >(glue );
81
- if (clobberFeaturePathsAndGlue ) {
82
- featurePaths .clear ();
83
- glue .clear ();
84
- }
85
84
while (!args .isEmpty ()) {
86
85
String arg = args .remove (0 ).trim ();
87
86
@@ -93,7 +92,7 @@ private void parse(List<String> args, boolean clobberFeaturePathsAndGlue) {
93
92
System .exit (0 );
94
93
} else if (arg .equals ("--glue" ) || arg .equals ("-g" )) {
95
94
String gluePath = args .remove (0 );
96
- glue .add (gluePath );
95
+ parsedGlue .add (gluePath );
97
96
} else if (arg .equals ("--tags" ) || arg .equals ("-t" )) {
98
97
parsedFilters .add (args .remove (0 ));
99
98
} else if (arg .equals ("--format" ) || arg .equals ("-f" )) {
@@ -119,19 +118,23 @@ private void parse(List<String> args, boolean clobberFeaturePathsAndGlue) {
119
118
throw new CucumberException ("Unknown option: " + arg );
120
119
} else {
121
120
PathWithLines pathWithLines = new PathWithLines (arg );
122
- featurePaths .add (pathWithLines .path );
123
- parsedFilters .addAll (pathWithLines .lines );
121
+ parsedFeaturePaths .add (pathWithLines .path );
122
+ parsedLineFilters .addAll (pathWithLines .lines );
124
123
}
125
124
}
126
125
if (!parsedFilters .isEmpty ()) {
127
126
filters .clear ();
128
127
filters .addAll (parsedFilters );
129
128
}
130
- if (featurePaths .isEmpty ()) {
131
- featurePaths .addAll (oldFeaturePaths );
129
+ if (!parsedFeaturePaths .isEmpty ()) {
130
+ featurePaths .clear ();
131
+ lineFilters .clear ();
132
+ featurePaths .addAll (parsedFeaturePaths );
133
+ lineFilters .addAll (parsedLineFilters );
132
134
}
133
- if (glue .isEmpty ()) {
134
- glue .addAll (oldGlue );
135
+ if (!parsedGlue .isEmpty ()) {
136
+ glue .clear ();
137
+ glue .addAll (parsedGlue );
135
138
}
136
139
}
137
140
0 commit comments