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

Replace external process by simple unzip step 165 #258

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package nl.tudelft.cse1110.andy.config;

import nl.tudelft.cse1110.andy.execution.Context.Context;
import nl.tudelft.cse1110.andy.execution.externalprocess.ExternalProcess;
import nl.tudelft.cse1110.andy.execution.metatest.AbstractMetaTestFactory;

public interface MetaTest {
Expand Down Expand Up @@ -37,11 +36,4 @@ static MetaTest insertAt(String name, int lineToInsertStartingIn1, String conten
return new AbstractMetaTestFactory().insertAt(name, lineToInsertStartingIn1, contentToAdd);
}

static MetaTest withExternalProcess(int weight, String name, ExternalProcess externalProcess) {
return new AbstractMetaTestFactory().withExternalProcess(weight, name, externalProcess);
}

static MetaTest withExternalProcess(String name, ExternalProcess externalProcess) {
return new AbstractMetaTestFactory().withExternalProcess(name, externalProcess);
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package nl.tudelft.cse1110.andy.config;

import nl.tudelft.cse1110.andy.codechecker.engine.CheckScript;
import nl.tudelft.cse1110.andy.execution.externalprocess.EmptyExternalProcess;
import nl.tudelft.cse1110.andy.execution.mode.Mode;
import nl.tudelft.cse1110.andy.execution.externalprocess.ExternalProcess;

import java.util.Collections;
import java.util.List;
Expand All @@ -29,10 +27,19 @@ public abstract class RunConfiguration {
"EXPERIMENTAL_BIG_INTEGER", "EXPERIMENTAL_NAKED_RECEIVER", "EXPERIMENTAL_MEMBER_VARIABLE", "ABS",
"AOR", "AOD", "CRCR", "OBBN", "ROR", "UOI");

private static List<String> ZIPPED = Collections.emptyList();

public abstract List<String> classesUnderTest();

public abstract Map<String, Float> weights();

public void setZippedFiles(List<String> files) {
ZIPPED = files;
};

public List<String> getZippedFiles() {
return ZIPPED;
}
public CheckScript checkScript() {
return new CheckScript(Collections.emptyList());
}
Expand All @@ -57,10 +64,6 @@ public Mode mode() {
return Mode.PRACTICE;
}

public ExternalProcess externalProcess() {
return new EmptyExternalProcess();
}

public String successMessage() {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package nl.tudelft.cse1110.andy.config;

import com.google.common.collect.ImmutableMap;
import nl.tudelft.cse1110.andy.execution.externalprocess.ExternalProcess;
import nl.tudelft.cse1110.andy.execution.mode.Mode;

import java.util.Collections;
Expand All @@ -15,13 +13,11 @@ public class SecureExamRunConfiguration extends RunConfiguration {
private final String successMessage;
private final List<String> listOfMutants;
private final int numberOfMutationsToConsider;
private final ExternalProcess externalProcess;

public SecureExamRunConfiguration(RunConfiguration runConfigurationToClone) {
this.classesUnderTest = runConfigurationToClone.classesUnderTest();
this.listOfMutants = runConfigurationToClone.listOfMutants();
this.numberOfMutationsToConsider = runConfigurationToClone.numberOfMutationsToConsider();
this.externalProcess = runConfigurationToClone.externalProcess();
this.successMessage = runConfigurationToClone.successMessage();
}

Expand All @@ -30,13 +26,14 @@ public Mode mode() {
}

@Override
@SuppressWarnings("DoubleBraceInitialization")
public Map<String, Float> weights() {
return new HashMap<>(ImmutableMap.of(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would expect this to break with errorprone! ImmutableMap.of(...) is how it should be now, I think!

"coverage", 0.25f,
"mutation", 0.25f,
"meta", 0.25f,
"codechecks", 0.25f
));
return new HashMap<>() {{
put("coverage", 0.25f);
put("mutation", 0.25f);
put("meta", 0.25f);
put("codechecks", 0.25f);
}};
}

@Override
Expand All @@ -52,10 +49,6 @@ public int numberOfMutationsToConsider() {
return numberOfMutationsToConsider;
}

public ExternalProcess externalProcess() {
return externalProcess;
}

public String successMessage() {
return successMessage;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
import nl.tudelft.cse1110.andy.config.DirectoryConfiguration;
import nl.tudelft.cse1110.andy.config.RunConfiguration;
import nl.tudelft.cse1110.andy.execution.ExecutionFlow;
import nl.tudelft.cse1110.andy.execution.externalprocess.EmptyExternalProcess;
import nl.tudelft.cse1110.andy.execution.mode.Action;
import nl.tudelft.cse1110.andy.execution.mode.ModeActionSelector;
import nl.tudelft.cse1110.andy.execution.externalprocess.ExternalProcess;
import org.jacoco.core.runtime.IRuntime;
import org.jacoco.core.runtime.RuntimeData;

Expand All @@ -21,15 +19,14 @@ public class Context {
private ExecutionFlow flow;
private final Action action;
private ModeActionSelector modeActionSelector;
private ExternalProcess externalProcess;
private ClassLoader classloaderWithStudentsCode;
private final List<String> librariesToBeIncludedInCompilation;
private IRuntime jacocoRuntime;
private RuntimeData jacocoData;

public Context(ClassLoader cleanClassloader, DirectoryConfiguration directoryConfiguration,
RunConfiguration runConfiguration, List<String> fullClassNames, ExecutionFlow flow,
Action action, ModeActionSelector modeActionSelector, ExternalProcess externalProcess,
Action action, ModeActionSelector modeActionSelector,
ClassLoader classloaderWithStudentsCode, List<String> librariesToBeIncludedInCompilation,
IRuntime jacocoRuntime, RuntimeData jacocoData) {
this.cleanClassloader = cleanClassloader;
Expand All @@ -39,7 +36,6 @@ public Context(ClassLoader cleanClassloader, DirectoryConfiguration directoryCon
this.flow = flow;
this.action = action;
this.modeActionSelector = modeActionSelector;
this.externalProcess = externalProcess;
this.classloaderWithStudentsCode = classloaderWithStudentsCode;
this.librariesToBeIncludedInCompilation = librariesToBeIncludedInCompilation;
this.jacocoRuntime = jacocoRuntime;
Expand All @@ -60,16 +56,6 @@ public void setModeSelector(ModeActionSelector modeActionSelector) {
this.modeActionSelector = modeActionSelector;
}

public void setExternalProcess(ExternalProcess externalProcess) {
this.externalProcess = externalProcess;
}

public void killExternalProcess() {
// Retrieve error messages before killing process
externalProcess.extractErrorMessages();

externalProcess.kill();
}

public void setClassloaderWithStudentsCode(ClassLoader classloaderWithStudentsCode) {
this.classloaderWithStudentsCode = classloaderWithStudentsCode;
Expand Down Expand Up @@ -112,10 +98,6 @@ public ModeActionSelector getModeActionSelector() {
return modeActionSelector;
}

public ExternalProcess getExternalProcess() {
return externalProcess;
}

public ClassLoader getClassloaderWithStudentsCode() {
return classloaderWithStudentsCode;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import nl.tudelft.cse1110.andy.config.DirectoryConfiguration;
import nl.tudelft.cse1110.andy.config.RunConfiguration;
import nl.tudelft.cse1110.andy.execution.ExecutionFlow;
import nl.tudelft.cse1110.andy.execution.externalprocess.ExternalProcess;
import nl.tudelft.cse1110.andy.execution.mode.Action;
import nl.tudelft.cse1110.andy.execution.mode.ModeActionSelector;
import org.jacoco.core.runtime.IRuntime;
Expand All @@ -19,7 +18,6 @@ public class ContextBuilder {
private ExecutionFlow flow;
private Action action;
private ModeActionSelector modeActionSelector;
private ExternalProcess externalProcess;
private ClassLoader classloaderWithStudentsCode;
private List<String> librariesToBeIncludedInCompilation;
private IRuntime jacocoRuntime;
Expand All @@ -45,17 +43,14 @@ public void setAction(Action action) {
this.action = action;
}

public void setExternalProcess(ExternalProcess externalProcess) {
this.externalProcess = externalProcess;
}

public void setLibrariesToBeIncludedInCompilation(List<String> librariesToBeIncludedInCompilation) {
this.librariesToBeIncludedInCompilation = librariesToBeIncludedInCompilation;
}

public Context buildContext() {
return new Context(cleanClassloader, directoryConfiguration, runConfiguration, fullClassNames, flow,
action, modeActionSelector, externalProcess, classloaderWithStudentsCode,
action, modeActionSelector, classloaderWithStudentsCode,
librariesToBeIncludedInCompilation, jacocoRuntime, jacocoData);
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package nl.tudelft.cse1110.andy.execution.Context;

import nl.tudelft.cse1110.andy.config.DirectoryConfiguration;
import nl.tudelft.cse1110.andy.execution.externalprocess.EmptyExternalProcess;
import nl.tudelft.cse1110.andy.execution.mode.Action;

import java.util.List;
Expand Down Expand Up @@ -53,6 +52,5 @@ private void setBase(Action action, DirectoryConfiguration directoryConfiguratio
contextBuilder.setCleanClassloader(Thread.currentThread().getContextClassLoader());
contextBuilder.setAction(action);
contextBuilder.setDirectoryConfiguration(directoryConfiguration);
contextBuilder.setExternalProcess(new EmptyExternalProcess());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ public Result run() {
}
} while (!steps.isEmpty() && !resultBuilder.hasFailed());

ctx.killExternalProcess();

return resultBuilder.build();
}

Expand All @@ -63,6 +61,7 @@ public static List<ExecutionStep> basicSteps() {
new CompilationStep(),
new ReplaceClassloaderStep(),
new GetRunConfigurationStep(),
new UnzipStep(),
new ExamModeSecurityGuardStep(),
new InjectModeActionStepsStep());
}
Expand Down

This file was deleted.

Loading