Skip to content

Commit 6713379

Browse files
committed
Remove test mode flag in backend
1 parent 5d73cc2 commit 6713379

File tree

5 files changed

+4
-65
lines changed

5 files changed

+4
-65
lines changed

docs/dg/cli.md

-16
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,6 @@ syntax reference under Appendix section of User Guide.
1111

1212
<!-- ------------------------------------------------------------------------------------------------------ -->
1313

14-
### `--test-mode`
15-
16-
**`--test-mode`**: Enables test mode behavior.
17-
18-
<box type="info" seamless>
19-
20-
* Used in `ConfigSystemTest`.
21-
* Can be used for behaviors specific to test code.
22-
* E.g. `--fresh-cloning`. Fresh cloning is always `false` when running RepoSense normally, and is only used in
23-
system tests.
24-
25-
</box>
26-
27-
<!-- ------------------------------------------------------------------------------------------------------ -->
28-
2914
### `--fresh-cloning`
3015

3116
**`--fresh-cloning`**: Clones the repo again if it has been cloned before.
@@ -36,6 +21,5 @@ syntax reference under Appendix section of User Guide.
3621
* Some test cases performs shallow cloning while some does not. Fresh cloning ensures that the test cases that does
3722
not perform shallow cloning will clone the repo again if the previous test case uses shallow cloning, ensuring
3823
correctness of the analysis.
39-
* Requires `--test-mode` flag to be enabled.
4024

4125
</box>

src/main/java/reposense/model/CliArguments.java

-16
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ public class CliArguments {
3737
private boolean isFindingPreviousAuthorsPerformed;
3838
private boolean isAuthorshipAnalyzed;
3939
private double originalityThreshold;
40-
private boolean isTestMode = ArgsParser.DEFAULT_IS_TEST_MODE;
4140
private boolean isFreshClonePerformed = ArgsParser.DEFAULT_SHOULD_FRESH_CLONE;
4241

4342
private List<String> locations;
@@ -122,10 +121,6 @@ public boolean isFindingPreviousAuthorsPerformed() {
122121
return isFindingPreviousAuthorsPerformed;
123122
}
124123

125-
public boolean isTestMode() {
126-
return isTestMode;
127-
}
128-
129124
public boolean isFreshClonePerformed() {
130125
return isFreshClonePerformed;
131126
}
@@ -207,7 +202,6 @@ public boolean equals(Object other) {
207202
&& Objects.equals(this.zoneId, otherCliArguments.zoneId)
208203
&& this.isFindingPreviousAuthorsPerformed == otherCliArguments.isFindingPreviousAuthorsPerformed
209204
&& this.isFileSizeLimitIgnored == otherCliArguments.isFileSizeLimitIgnored
210-
&& this.isTestMode == otherCliArguments.isTestMode
211205
&& this.isFreshClonePerformed == otherCliArguments.isFreshClonePerformed
212206
&& Objects.equals(this.locations, otherCliArguments.locations)
213207
&& this.isViewModeOnly == otherCliArguments.isViewModeOnly
@@ -391,16 +385,6 @@ public Builder isFindingPreviousAuthorsPerformed(boolean isFindingPreviousAuthor
391385
return this;
392386
}
393387

394-
/**
395-
* Adds the {@code isTestMode} to CliArguments.
396-
*
397-
* @param isTestMode Is test mode.
398-
*/
399-
public Builder isTestMode(boolean isTestMode) {
400-
this.cliArguments.isTestMode = isTestMode;
401-
return this;
402-
}
403-
404388
/**
405389
* Adds the {@code isFreshClonePerformed} to CliArguments.
406390
*

src/main/java/reposense/parser/ArgsParser.java

+4-22
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import net.sourceforge.argparse4j.impl.Arguments;
1919
import net.sourceforge.argparse4j.impl.action.HelpArgumentAction;
2020
import net.sourceforge.argparse4j.impl.action.VersionArgumentAction;
21-
import net.sourceforge.argparse4j.inf.ArgumentGroup;
2221
import net.sourceforge.argparse4j.inf.ArgumentParser;
2322
import net.sourceforge.argparse4j.inf.ArgumentParserException;
2423
import net.sourceforge.argparse4j.inf.FeatureControl;
@@ -52,7 +51,6 @@ public class ArgsParser {
5251
public static final String DEFAULT_REPORT_NAME = "reposense-report";
5352
public static final int DEFAULT_NUM_CLONING_THREADS = 4;
5453
public static final int DEFAULT_NUM_ANALYSIS_THREADS = Runtime.getRuntime().availableProcessors();
55-
public static final boolean DEFAULT_IS_TEST_MODE = false;
5654
public static final boolean DEFAULT_SHOULD_FRESH_CLONE = false;
5755
public static final double DEFAULT_ORIGINALITY_THRESHOLD = 0.51;
5856

@@ -75,7 +73,6 @@ public class ArgsParser {
7573
public static final String[] FIND_PREVIOUS_AUTHORS_FLAGS = new String[] {"--find-previous-authors", "-F"};
7674
public static final String[] CLONING_THREADS_FLAG = new String[] {"--cloning-threads"};
7775
public static final String[] ANALYSIS_THREADS_FLAG = new String[] {"--analysis-threads"};
78-
public static final String[] TEST_MODE_FLAG = new String[] {"--test-mode"};
7976
public static final String[] FRESH_CLONING_FLAG = new String[] {"--fresh-cloning"};
8077
public static final String[] ANALYZE_AUTHORSHIP_FLAGS = new String[] {"--analyze-authorship", "-A"};
8178
public static final String[] ORIGINALITY_THRESHOLD_FLAGS = new String[] {"--originality-threshold", "-ot"};
@@ -86,7 +83,6 @@ public class ArgsParser {
8683
private static final String PROGRAM_DESCRIPTION =
8784
"RepoSense is a contribution analysis tool for Git repositories.";
8885
private static final String MESSAGE_HEADER_MUTEX = "mutual exclusive arguments";
89-
private static final String MESSAGE_HEADER_TESTING = "test mode arguments";
9086
private static final String MESSAGE_HAVE_SINCE_DATE_UNTIL_DATE_AND_PERIOD =
9187
"\"Since Date\", \"Until Date\", and \"Period\" cannot be applied together.";
9288
private static final String MESSAGE_USING_DEFAULT_CONFIG_PATH =
@@ -121,9 +117,6 @@ private static ArgumentParser getArgumentParser() {
121117
.addMutuallyExclusiveGroup(MESSAGE_HEADER_MUTEX)
122118
.required(false);
123119

124-
ArgumentGroup argumentGroup = parser
125-
.addArgumentGroup(MESSAGE_HEADER_TESTING);
126-
127120
// Boolean flags
128121
parser.addArgument(HELP_FLAGS)
129122
.help("Show help message.")
@@ -272,13 +265,7 @@ private static ArgumentParser getArgumentParser() {
272265
.setDefault(DEFAULT_NUM_ANALYSIS_THREADS)
273266
.help(FeatureControl.SUPPRESS);
274267

275-
// Testing flags
276-
argumentGroup.addArgument(TEST_MODE_FLAG)
277-
.dest(TEST_MODE_FLAG[0])
278-
.action(Arguments.storeTrue())
279-
.help("Enables testing mode.");
280-
281-
argumentGroup.addArgument(FRESH_CLONING_FLAG)
268+
parser.addArgument(FRESH_CLONING_FLAG)
282269
.dest(FRESH_CLONING_FLAG[0])
283270
.action(Arguments.storeTrue())
284271
.help("Enables fresh cloning. Requires testing mode to be enabled.");
@@ -317,11 +304,11 @@ public static CliArguments parse(String[] args) throws HelpScreenException, Pars
317304
boolean shouldIncludeLastModifiedDate = results.get(LAST_MODIFIED_DATE_FLAGS[0]);
318305
boolean shouldPerformShallowCloning = results.get(SHALLOW_CLONING_FLAGS[0]);
319306
boolean shouldFindPreviousAuthors = results.get(FIND_PREVIOUS_AUTHORS_FLAGS[0]);
320-
boolean isTestMode = results.get(TEST_MODE_FLAG[0]);
321307
boolean isAuthorshipAnalyzed = results.get(ANALYZE_AUTHORSHIP_FLAGS[0]);
322308
double originalityThreshold = results.get(ORIGINALITY_THRESHOLD_FLAGS[0]);
323309
int numCloningThreads = results.get(CLONING_THREADS_FLAG[0]);
324310
int numAnalysisThreads = results.get(ANALYSIS_THREADS_FLAG[0]);
311+
boolean shouldPerformFreshCloning = results.get(FRESH_CLONING_FLAG[0]);
325312

326313
CliArguments.Builder cliArgumentsBuilder = new CliArguments.Builder()
327314
.configFolderPath(configFolderPath)
@@ -338,9 +325,9 @@ public static CliArguments parse(String[] args) throws HelpScreenException, Pars
338325
.isFindingPreviousAuthorsPerformed(shouldFindPreviousAuthors)
339326
.numCloningThreads(numCloningThreads)
340327
.numAnalysisThreads(numAnalysisThreads)
341-
.isTestMode(isTestMode)
342328
.isAuthorshipAnalyzed(isAuthorshipAnalyzed)
343-
.originalityThreshold(originalityThreshold);
329+
.originalityThreshold(originalityThreshold)
330+
.isFreshClonePerformed(shouldPerformFreshCloning);
344331

345332
LogsManager.setLogFolderLocation(outputFolderPath);
346333

@@ -364,11 +351,6 @@ public static CliArguments parse(String[] args) throws HelpScreenException, Pars
364351
}
365352
cliArgumentsBuilder.isAutomaticallyLaunching(isAutomaticallyLaunching);
366353

367-
boolean shouldPerformFreshCloning = isTestMode
368-
? results.get(FRESH_CLONING_FLAG[0])
369-
: DEFAULT_SHOULD_FRESH_CLONE;
370-
cliArgumentsBuilder.isFreshClonePerformed(shouldPerformFreshCloning);
371-
372354
return cliArgumentsBuilder.build();
373355
}
374356

src/systemtest/java/reposense/ConfigSystemTest.java

-2
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,6 @@ public void test30DaysFromUntilDateWithFindPreviousAuthors() {
136136
* <br>Formats: {@link ConfigSystemTest#TESTING_FILE_FORMATS TESTING_FILE_FORMATS}
137137
* <br>Timezone: {@link ConfigSystemTest#TEST_TIME_ZONE TEST_TIME_ZONE}
138138
* <br>Output Folder Path: {@link ConfigSystemTest#OUTPUT_DIRECTORY OUTPUT_DIRECTORY}
139-
* <br>Test Mode: {@code Enabled}
140139
*/
141140
private InputBuilder initInputBuilder() {
142141
Path configFolder = loadResource(getClass(), "ConfigSystemTest");
@@ -145,7 +144,6 @@ private InputBuilder initInputBuilder() {
145144
return new InputBuilder().addConfig(configFolder)
146145
.addFormats(formats)
147146
.addTimezone(TEST_TIME_ZONE)
148-
.addTestMode()
149147
.addOutput(OUTPUT_DIRECTORY);
150148
}
151149

src/test/java/reposense/util/InputBuilder.java

-9
Original file line numberDiff line numberDiff line change
@@ -223,15 +223,6 @@ public InputBuilder addFindPreviousAuthors() {
223223
return this;
224224
}
225225

226-
/**
227-
* Adds the flag to enable test mode.
228-
* This method should only be called once in one build.
229-
*/
230-
public InputBuilder addTestMode() {
231-
input.append(ArgsParser.TEST_MODE_FLAG[0] + WHITESPACE);
232-
return this;
233-
}
234-
235226
/**
236227
* Adds the flag to include modified date in lines.
237228
* This method should only be called once in one build.

0 commit comments

Comments
 (0)