Skip to content

Fix debug mode #745

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

Merged
merged 2 commits into from
Oct 17, 2022
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
15 changes: 6 additions & 9 deletions core/src/main/java/de/jplag/Submission.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
Expand Down Expand Up @@ -209,23 +210,19 @@ public String toString() {
* This method is used to copy files that can not be parsed to a special folder.
*/
private void copySubmission() {
File rootDirectory = submissionRootFile.getParentFile();
assert rootDirectory != null;
File submissionDirectory = createSubdirectory(rootDirectory, ERROR_FOLDER, language.getIdentifier(), name);
File errorDirectory = createErrorDirectory(language.getIdentifier(), name);
logger.info("Copying erroneous submission to {}", errorDirectory.getAbsolutePath());
for (File file : files) {
try {
Files.copy(file.toPath(), new File(submissionDirectory, file.getName()).toPath());
Files.copy(file.toPath(), new File(errorDirectory, file.getName()).toPath());
} catch (IOException exception) {
logger.error("Error copying file: " + exception.getMessage(), exception);
}
}
}

private static File createSubdirectory(File parent, String... subdirectoryNames) {
File subdirectory = parent;
for (String name : subdirectoryNames) {
subdirectory = new File(subdirectory, name);
}
private static File createErrorDirectory(String... subdirectoryNames) {
File subdirectory = Path.of(ERROR_FOLDER, subdirectoryNames).toFile();
if (!subdirectory.exists()) {
subdirectory.mkdirs();
}
Expand Down
2 changes: 1 addition & 1 deletion core/src/test/java/de/jplag/InvalidSubmissionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ void testInvalidSubmissionsWithDebug() throws ExitException {
} catch (SubmissionException e) {
System.out.println(e.getMessage());
} finally {
File errorFolder = new File(Path.of(BASE_PATH, SAMPLE_NAME, "errors", "java").toString());
File errorFolder = new File(Path.of("errors", "java").toString());
assertTrue(errorFolder.exists());
String[] errorSubmissions = errorFolder.list();
if (errorSubmissions != null)
Expand Down