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

テストクラスへのTimeout フィールド追加処理を実装 #408

Merged
merged 4 commits into from
Nov 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion src/main/java/jp/kusumotolab/kgenprog/KGenProgMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public KGenProgMain(final Configuration config, final FaultLocalization faultLoc
public List<Variant> run() {
final Strategies strategies = new Strategies(faultLocalization, astConstruction,
sourceCodeGeneration, sourceCodeValidation, testExecutor, variantSelection);
final VariantStore variantStore = new VariantStore(config.getTargetProject(), strategies);
final VariantStore variantStore = new VariantStore(config, strategies);
final Variant initialVariant = variantStore.getInitialVariant();

sourceCodeGeneration.initialize(initialVariant);
Expand Down
20 changes: 13 additions & 7 deletions src/main/java/jp/kusumotolab/kgenprog/ga/VariantStore.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,27 @@
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import jp.kusumotolab.kgenprog.Configuration;
import jp.kusumotolab.kgenprog.OrdinalNumber;
import jp.kusumotolab.kgenprog.Strategies;
import jp.kusumotolab.kgenprog.fl.Suspiciousness;
import jp.kusumotolab.kgenprog.project.GeneratedSourceCode;
import jp.kusumotolab.kgenprog.project.factory.TargetProject;
import jp.kusumotolab.kgenprog.project.Operation;
import jp.kusumotolab.kgenprog.project.jdt.InsertTimeoutRuleFieldOperation;
import jp.kusumotolab.kgenprog.project.test.TestResults;

public class VariantStore {

private final TargetProject targetProject;
private final Configuration config;
private final Strategies strategies;
private final Variant initialVariant;
private List<Variant> currentVariants;
private List<Variant> generatedVariants;
private final List<Variant> foundSolutions;
private final OrdinalNumber generation;

public VariantStore(final TargetProject targetProject, final Strategies strategies) {
this.targetProject = targetProject;
public VariantStore(final Configuration config, final Strategies strategies) {
this.config = config;
this.strategies = strategies;

generation = new OrdinalNumber(0);
Expand All @@ -39,7 +41,7 @@ public VariantStore(final TargetProject targetProject, final Strategies strategi
*/
@Deprecated
public VariantStore(final Variant initialVariant) {
this.targetProject = null;
this.config = null;
this.strategies = null;
this.initialVariant = initialVariant;

Expand Down Expand Up @@ -135,8 +137,12 @@ public void changeGeneration() {
}

private Variant createInitialVariant() {
final GeneratedSourceCode sourceCode = strategies.execASTConstruction(targetProject);
return createVariant(new Gene(Collections.emptyList()), sourceCode,
final GeneratedSourceCode sourceCode =
strategies.execASTConstruction(config.getTargetProject());
final Operation operation =
new InsertTimeoutRuleFieldOperation(config.getTestTimeLimitSeconds());
final GeneratedSourceCode appliedSourceCode = operation.apply(sourceCode, null);
return createVariant(new Gene(Collections.emptyList()), appliedSourceCode,
new OriginalHistoricalElement());
}

Expand Down
Loading