-
Notifications
You must be signed in to change notification settings - Fork 17
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
Improve functionality for preparing tasks to be sent to sandbox #82
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR, looking good!
Most of my comments are super nitpicky stuff about whitespace and line widths.
The tar
thing seems pretty tricky: I don't really have any good suggestions on how to deal with it. I'll be happy with anything that @nygrenh is happy with :)
try { | ||
tarCreator.createTarFromProject(tempdir, tmcLangsPath, tmcRunPath, outputPath); | ||
} catch (ArchiveException ex) { | ||
java.util.logging.Logger.getLogger(TaskExecutorImpl.class.getName()).log(Level.SEVERE, null, ex); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a log message that says what project failed. Perhaps "Failed to create tar from project {}" where {} is either a project name, path or something like that?
@@ -134,6 +134,8 @@ ValidationResult checkCodeStyle(Path path, Locale messageLocale) | |||
* @return The compressed file as a byte array. | |||
*/ | |||
byte[] compressProject(Path path) throws IOException; | |||
|
|||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra whitespace
tmc-langs-util/pom.xml
Outdated
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<version>RELEASE</version> | ||
</dependency> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's been a long time since I've actually compiled any code for this project: @nygrenh, are we running maven 2 or 3?
I'm asking 'cause maven 3 does not support the RELEASE
metaversion. As there is already a dependency for junit on lines 46-50, I suggest we simply update the version number of that to the latest. That way we'll be compatible with both mvn2 and mvn3.
logger.error( | ||
"An error occurred while preparing task.", e); | ||
printErrAndExit( | ||
"ERROR: Could not prepare task." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most of the logger.error()
and printErrAndExit()
calls in this chunk of changes probably fit on single lines.
@@ -140,4 +153,6 @@ public void clean(Path path) throws NoLanguagePluginFoundException { | |||
private LanguagePlugin getLanguagePlugin(Path path) throws NoLanguagePluginFoundException { | |||
return ProjectType.getProjectType(path).getLanguagePlugin(); | |||
} | |||
|
|||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra whitespace
Path outputDirectory = Files.createTempDirectory("output-directory"); | ||
Path outputPath = new File("/tmp/output.tar").toPath();//outputDirectory.resolve("output.tar"); | ||
Path tmcRunPath = new File("/home/local/onniaarn/Visulahti.R").toPath();//Files.createTempFile("fake-tmc-run", ".sh"); | ||
Path tmcLangsPath = new File("/home/local/onniaarn/Projects/tmc-langs/tmc-langs-cli/target/tmc-langs-cli-0.7.7-SNAPSHOT.jar").toPath();//Files.createTempFile("fake-tmc-langs", ".jar"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These paths seem weird.
import fi.helsinki.cs.tmc.langs.java.ant.AntPlugin; | ||
import fi.helsinki.cs.tmc.langs.utils.TestUtils; | ||
|
||
import java.io.*; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid wild-card imports.
executor.prepareSandboxTask(exercisePath, submissionPath, outputPath, tmcRunPath, tmcLangsPath); | ||
Path testDirectory = Files.createTempDirectory("test-directory"); | ||
|
||
Process untarringProcess = new ProcessBuilder("tar", "-C", testDirectory.toString(), "-xf", outputPath.toString()).start(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a tricky one. I don't think this'll work on Windows as-is, but at the same time any other solution is going to be incredibly annoying to implement and have other, almost as significant downsides.
Can we somehow check if tar
is available on the system and only run the test then, perhaps outputting a warning or something such if it's not available?
ping @nygrenh
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The offending test is now set to be skipped if the functionality is not available, i.e. when on Windows. Shouldn't be an issue since the code will only ever be deployed to Linux. This solution is @nygrenh approved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@@ -16,13 +16,19 @@ | |||
import com.google.common.base.Optional; | |||
|
|||
import org.apache.commons.compress.archivers.ArchiveException; | |||
|
|||
import org.codehaus.plexus.util.FileUtils; | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra whitespace
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure? It's a unique domain, so it's surrounded by empty lines just like the other unique domains in the imports.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. Seems that we've been using styles for imports even within this project. Better keep it the way it's now to keep the style consistent within the file.
9628f92
to
607b323
Compare
Good job, LGTM! I'll let @nygrenh do the actual merge. |
607b323
to
0abbdd2
Compare
Add CLI command for preparing tasks to be sent to sandbox and implement the functionality in TaskExecutorImpl.