Skip to content

Commit

Permalink
Merge branch 'master' into update-docs
Browse files Browse the repository at this point in the history
  • Loading branch information
hrtwt authored Dec 8, 2020
2 parents 7064472 + c5c26ce commit 51e0dbf
Show file tree
Hide file tree
Showing 10 changed files with 309 additions and 304 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ $ java -jar path/to/kGenProg.jar
| `-t`, `--test` | Specifies paths to test source code, or to directories containing them. Paths are separated with spaces. | Nothing |
| `-x`, `--exec-test` | Specifies fully qualified names of test classes executed during evaluation of variants (i.e. fix-candidates). It is recommended to specify test classes detecting a bug. Class names are separated with spaces. | All test classes |
| `-c`, `--cp` | Specifies class paths needed to build the target project. Paths are separated with spaces. | Nothing |
| `-o`, `--out-dir` | Writes patches kGenProg generated under the specified directory. Patches are outputted to a directory having a name of the execution time and date under the specified directory. | A directory named `kgenprog-out` is created in the current directory. |
| `-o`, `--out-dir` | Specifies an output directory. Generated files include patches and history json. They can be enabled by `--patch-output` or `--history-record` | `./kgenprog-out` |
| `-v`, `--verbose` | Be more verbose, printing DEBUG level logs. | `false` |
| `-q`, `--quiet` | Be more quiet, suppressing non-ERROR logs. | `false` |
| `--mutation-generating-count` | Specifies how many variants are generated in a generation by a mutation. | 10 |
Expand All @@ -112,7 +112,8 @@ $ java -jar path/to/kGenProg.jar
| `--crossover-type` | Specifies crossover type. (`Random`, `Single`, `Uniform`, `Cascade`). | `Random` |
| `--crossover-first-variant` | Specifies first variant selection strategy for crossover. (`Elite`, `Random`). | `Random` |
| `--crossover-second-variant` | Specifies second variant selection strategy for crossover. (`Elite`, `GeneSimilarity`, `Random`, `TestSimilarity`). | `Random` |
| `--history-record` | Stores generation process of each variant and all generated variants. | `false` |
| `--patch-output` | Writes patch files to the output directory specified in `-o` option. | `false` |
| `--history-record` | Records and writes generation process of all generated variants as JSON format. Note that, this feature significantly reduces overall performance. | `false` |
| `--version` | Prints the kGenProg version number. | `false` |


Expand Down
6 changes: 4 additions & 2 deletions doc/ja/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ $ java -jar path/to/kGenProg.jar
| `-t`, `--test` | テストコード(単体テスト用のソースコード)へのパス,もしくはテストコードを含むディレクトリへのパス.スペース区切りで複数指定可能. | なし |
| `-x`, `--exec-test` | 遺伝的アルゴリズム中に実行されるテストクラスの完全限定名.バグを発現させるテストクラスを指定してください.スペース区切りで複数指定可能. | すべてのテストクラス |
| `-c`, `--cp` | 修正対象プロジェクトのビルドに必要なクラスパス.スペース区切りで複数指定可能. | なし |
| `-o`, `--out-dir` | kGenProg が結果の出力を行うディレクトリへのパス.指定ディレクトリ直下に実行時のタイムスタンプを名前とするディレクトリが生成され,そのディレクトリに結果が出力されます. | カレントディレクトリ直下に `kgenprog-out` というディレクトリが作成される |
| `-o`, `--out-dir` | kGenProg が結果を出力するディレクトリへのパス.出力ファイルはパッチファイルとGAの生成過程.それぞれ `--patch-output``--history-record` でon/offを切り替え可能. | `./kgenprog-out` |
| `-v`, `--verbose` | 詳細なログを出力する | `false` |
| `-q`, `--quiet` | エラー出力のみを行う | `false` |
| `--mutation-generating-count` | 遺伝的アルゴリズムの変異操作によって1つの世代に生成する個体の数 | 10 |
Expand All @@ -112,9 +112,11 @@ $ java -jar path/to/kGenProg.jar
| `--crossover-type` | 交叉種別(`Random``Single``Uniform`, `Cascade`| `Random` |
| `--crossover-first-variant` | 交叉対象の第一バリアントの選択方法(`Elite``Random`| `Random` |
| `--crossover-second-variant` | 交叉対象の第二バリアントの選択方法(`Elite``GeneSimilarity``Random``TestComplementary`) | `Random` |
| `--history-record` | 個体の生成過程および生成された全個体を記録する | `false` |
| `--patch-output` | 解のパッチファイル生成の有無 | `false` |
| `--history-record` | 個体の生成過程および生成された全個体を記録するJSONファイルの記録の有無.この機能は実行速度の低下に繋がる点に注意 | `false` |
| `--version` | kGenProg のバーションを出力し終了する | `false` |


## 受賞
- [Best Poster Award - APSEC 2018](http://www.apsec2018.org/)
kGenProg: A High-Performance, High-Extensibility and High-Portability APR System
Expand Down
7 changes: 5 additions & 2 deletions doc/kgenprog-config-template.toml
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,8 @@ test = ["path/to/test/source/code"]
# Acceptable values are "Elite", "GeneSimilarity", "Random" or "TestSimilarity"
#crossover-second-variant = <strategy>

# Stores generation process of each variant and all generated variants.
#history-record = <boolean>
# Writes patch files to the output directory specified in `-o` option.
#patch-output = true/false

# Records and writes generation process of all generated variants as JSON format.
#history-record = true/false
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
root-dir = "./"
src = ["src/"]
test = ["test/"]
no-output = true
patch-output = false
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
root-dir = "./"
src = ["src/"]
test = ["test/"]
no-output = false
patch-output = true
61 changes: 34 additions & 27 deletions src/main/java/jp/kusumotolab/kgenprog/Configuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ public class Configuration {
public static final Path DEFAULT_OUT_DIR = Paths.get("kgenprog-out");
public static final long DEFAULT_RANDOM_SEED = 0;
public static final Scope.Type DEFAULT_SCOPE = Scope.Type.PACKAGE;
public static final boolean DEFAULT_NEED_NOT_OUTPUT = false;
public static final FaultLocalization.Technique DEFAULT_FAULT_LOCALIZATION =
FaultLocalization.Technique.Ochiai;
public static final Mutation.Type DEFAULT_MUTATION_TYPE = Mutation.Type.Simple;
Expand All @@ -65,7 +64,8 @@ public class Configuration {
FirstVariantSelectionStrategy.Strategy.Random;
public static final SecondVariantSelectionStrategy.Strategy DEFAULT_SECOND_VARIANT_SELECTION_STRATEGY =
SecondVariantSelectionStrategy.Strategy.Random;
public static final boolean DEFAULT_HISTORY_RECORD = false;
public static final boolean DEFAULT_IS_PATCH_OUTPUT = false;
public static final boolean DEFAULT_IS_HISTORY_RECORD = false;

private final TargetProject targetProject;
private final List<String> executionTests;
Expand All @@ -80,13 +80,13 @@ public class Configuration {
private final Level logLevel;
private final long randomSeed;
private final Scope.Type scope;
private final boolean needNotOutput;
private final FaultLocalization.Technique faultLocalization;
private final Mutation.Type mutationType;
private final Crossover.Type crossoverType;
private final FirstVariantSelectionStrategy.Strategy firstVariantSelectionStrategy;
private final SecondVariantSelectionStrategy.Strategy secondVariantSelectionStrategy;
private final boolean historyRecord;
private final boolean isPatchOutput;
private final boolean isHistoryRecord;
private final Builder builder;

private Configuration(final Builder builder) {
Expand All @@ -103,13 +103,13 @@ private Configuration(final Builder builder) {
this.logLevel = builder.logLevel;
this.randomSeed = builder.randomSeed;
this.scope = builder.scope;
this.needNotOutput = builder.needNotOutput;
this.faultLocalization = builder.faultLocalization;
this.mutationType = builder.mutationType;
this.crossoverType = builder.crossoverType;
this.firstVariantSelectionStrategy = builder.firstVariantSelectionStrategy;
this.secondVariantSelectionStrategy = builder.secondVariantSelectionStrategy;
this.historyRecord = builder.historyRecord;
this.isPatchOutput = builder.isPatchOutput;
this.isHistoryRecord = builder.isHistoryRecord;
this.builder = builder;
}

Expand Down Expand Up @@ -173,9 +173,6 @@ public Scope.Type getScope() {
return scope;
}

public boolean needNotOutput() {
return needNotOutput;
}

public FaultLocalization.Technique getFaultLocalization() {
return faultLocalization;
Expand All @@ -197,8 +194,12 @@ public SecondVariantSelectionStrategy.Strategy getSecondVariantSelectionStrategy
return secondVariantSelectionStrategy;
}

public boolean isPatchOutput() {
return isPatchOutput;
}

public boolean isHistoryRecord() {
return historyRecord;
return isHistoryRecord;
}

@Override
Expand Down Expand Up @@ -287,11 +288,6 @@ public static class Builder {
@Conversion(ScopeTypeToString.class)
private Scope.Type scope = DEFAULT_SCOPE;

@Option(name = "--no-output", usage = "Do not output anything.", hidden = true)
@com.electronwill.nightconfig.core.conversion.Path("no-output")
@PreserveNotNull
private boolean needNotOutput = DEFAULT_NEED_NOT_OUTPUT;

@com.electronwill.nightconfig.core.conversion.Path("fault-localization")
@PreserveNotNull
@Conversion(FaultLocalizationTechniqueToString.class)
Expand Down Expand Up @@ -319,9 +315,13 @@ public static class Builder {
private SecondVariantSelectionStrategy.Strategy secondVariantSelectionStrategy =
DEFAULT_SECOND_VARIANT_SELECTION_STRATEGY;

@com.electronwill.nightconfig.core.conversion.Path("patch-output")
@PreserveNotNull
private boolean isPatchOutput = DEFAULT_IS_PATCH_OUTPUT;

@com.electronwill.nightconfig.core.conversion.Path("history-record")
@PreserveNotNull
private boolean historyRecord = DEFAULT_HISTORY_RECORD;
private boolean isHistoryRecord = DEFAULT_IS_HISTORY_RECORD;

private final transient Set<String> optionsSetByCmdLineArgs = new HashSet<>();
private final transient Set<String> optionsSetByConfigFile = new HashSet<>();
Expand Down Expand Up @@ -483,10 +483,6 @@ public Builder setScope(final Scope.Type scope) {
return this;
}

public Builder setNeedNotOutput(final boolean needNotOutput) {
this.needNotOutput = needNotOutput;
return this;
}

public Builder setFaultLocalization(final FaultLocalization.Technique faultLocalization) {
this.faultLocalization = faultLocalization;
Expand Down Expand Up @@ -515,8 +511,13 @@ public Builder setSecondVariantSelectionStrategy(
return this;
}

public Builder setHistoryRecord(final boolean historyRecord) {
this.historyRecord = historyRecord;
public Builder setPatchOutput(final boolean isPatchOutput) {
this.isPatchOutput = isPatchOutput;
return this;
}

public Builder setHistoryRecord(final boolean isHistoryRecord) {
this.isHistoryRecord = isHistoryRecord;
return this;
}

Expand All @@ -534,7 +535,7 @@ private static void validateExistences(final Builder builder) {

private static void validateExistence(final Path path) {
if (Files.notExists(path)) {
log.error(path.toString() + " does not exist.");
log.error("{} does not exist.", path);
throw new IllegalArgumentException(path.toString() + " does not exist.");
}
}
Expand Down Expand Up @@ -736,7 +737,7 @@ private void addClassPathFromCmdLineParser(final String classPath) {
}

@Option(name = "-o", aliases = "--out-dir", metaVar = "<path>",
usage = "Writes patches kGenProg generated to the specified directory.")
usage = "Specifies an output directory storing patch and/or history json.")
private void setOutDirFromCmdLineParser(final String outDir) {
this.outDir = Paths.get(outDir);
this.optionsSetByCmdLineArgs.add("outDir");
Expand Down Expand Up @@ -855,9 +856,15 @@ private void setSecondVariantSelectionStrategyFromCmdLineParser(
this.optionsSetByCmdLineArgs.add("secondVariantSelectionStrategy");
}

@Option(name = "--history-record", usage = "Record historical element.")
private void setHistoryRecordFromCmdLineParser(final boolean historyRecord) {
this.historyRecord = historyRecord;
@Option(name = "--patch-output", usage = "Write patch files to output dir.")
private void setPatchOutputFromCmdLineParser(final boolean isPatchOutput) {
this.isPatchOutput = isPatchOutput;
this.optionsSetByCmdLineArgs.add("patchOutput");
}

@Option(name = "--history-record", usage = "Record and write generation history to output dir.")
private void setHistoryRecordFromCmdLineParser(final boolean isHistoryRecord) {
this.isHistoryRecord = isHistoryRecord;
this.optionsSetByCmdLineArgs.add("historyRecord");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ private Set<Exporter> createExporterSet(final Configuration config) {
final Set<Exporter> exporters = new HashSet<>();
exporters.add(new PatchLogExporter()); // always write patch to log

if (!config.needNotOutput()) {
if (config.isPatchOutput()) {
exporters.add(new PatchFileExporter(outdir));
}
if (config.isHistoryRecord()) {
Expand Down
Loading

0 comments on commit 51e0dbf

Please sign in to comment.