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

Feature/allow single submissions #1975

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
95d2cd7
refactor(core): remove check on duplicate names
euberdeveloper Aug 26, 2024
e96cf70
refactor(core): remove throws into method checkForConfigurationConsis…
euberdeveloper Aug 26, 2024
e25e584
style(core): use String format
euberdeveloper Aug 26, 2024
67923b9
refactor(core): remove unused imports
euberdeveloper Aug 26, 2024
5f50854
feat(core): add support for same name submissions to SubmissionSetBui…
euberdeveloper Aug 26, 2024
407b629
test(core): fix should not throw
euberdeveloper Aug 26, 2024
5eb1c74
style: apply spotless
euberdeveloper Aug 26, 2024
6071f1b
test(core): add test about different submissions with same root name
euberdeveloper Aug 26, 2024
018293f
test(core): add test about different submissions with same root name
euberdeveloper Aug 26, 2024
c87778f
test(core): add test about single new submission with an old submission
euberdeveloper Aug 26, 2024
a6761b4
test(core): add test about single new submission with an old submission
euberdeveloper Aug 26, 2024
9964301
style: execute spotless
euberdeveloper Aug 26, 2024
92a729d
test(e2e): add test about single new submission
euberdeveloper Aug 27, 2024
e1db53e
test(e2e): add test about matching names on submissions
euberdeveloper Aug 27, 2024
dcf45bc
test(core): refactor tests on new features
euberdeveloper Aug 27, 2024
c300fc1
style: apply spotless
euberdeveloper Aug 27, 2024
37bfdc6
fix(report-viewer): fix regex for e2e tests
euberdeveloper Aug 28, 2024
68065f6
test(report-viewer): fix e2e test
euberdeveloper Aug 30, 2024
26a58f7
fix(viewer): fix missing backslash in regexp for e2e tests
euberdeveloper Sep 2, 2024
331557f
test(viewer): try to fix e2e test
euberdeveloper Sep 2, 2024
85ce7a2
ci(complete-e2e): remove additional hyphen to --old
euberdeveloper Sep 2, 2024
4fcf51f
test(viewer): fix e2e regexp
euberdeveloper Sep 2, 2024
39110d0
ci(complete-e2e): fix old argument by using comma and not spaces
euberdeveloper Sep 3, 2024
dc09aba
refactor(e2e): rename var
euberdeveloper Sep 4, 2024
4e19222
ci(e2e): remove submissions with same name part
euberdeveloper Sep 6, 2024
66bbaad
refactor: rollback feature of multiple submissions same name
euberdeveloper Sep 6, 2024
81b30c0
style(JPlag.java): use explicit imports
euberdeveloper Sep 6, 2024
bfdfd55
style: apply spotless
euberdeveloper Sep 6, 2024
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
1 change: 1 addition & 0 deletions .github/workflows/complete-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ jobs:
{zip: "folderMultiRoot.zip", name: "folderMultiRoot", folder: "f0", language: "java", cliArgs: "--new f1"},
{zip: "mixedMultiRoot.zip", name: "mixedBaseFile", folder: "f0", language: "java", cliArgs: "--new f1"},
{zip: "mixedMultiRoot.zip", name: "mixedBaseFolder", folder: "f1", language: "java", cliArgs: "--new f0"},
{zip: "singleNewSubmission.zip", name: "singleNewSubmission", folder: "2023", language: "java", cliArgs: "--old 2022,2021,2020"},
{zip: "cpp.zip", name: "cpp", folder: "./cpp", language: "cpp", cliArgs: ""},
{zip: "csharp.zip", name: "csharp", folder: "./csharp", language: "csharp", cliArgs: ""},
{zip: "python.zip", name: "python", folder: "./python", language: "python3", cliArgs: ""}
Expand Down
Binary file added .github/workflows/files/singleNewSubmission.zip
Binary file not shown.
4 changes: 2 additions & 2 deletions core/src/main/java/de/jplag/JPlag.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,11 @@ private static void logSkippedSubmissions(SubmissionSet submissionSet, JPlagOpti

private static void checkForConfigurationConsistency(JPlagOptions options) throws RootDirectoryException {
if (options.normalize() && !options.language().supportsNormalization()) {
logger.error(String.format("The language %s cannot be used with normalization.", options.language().getName()));
logger.error("The language {} cannot be used with normalization.", options.language().getName());
}

List<String> duplicateNames = getDuplicateSubmissionFolderNames(options);
if (duplicateNames.size() > 0) {
if (!duplicateNames.isEmpty()) {
throw new RootDirectoryException(String.format("Duplicate root directory names found: %s", String.join(", ", duplicateNames)));
}
}
Expand Down
19 changes: 17 additions & 2 deletions core/src/test/java/de/jplag/RootFolderTest.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package de.jplag;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.*;

import java.io.File;
import java.util.List;
Expand Down Expand Up @@ -84,4 +83,20 @@ void testBasecodeInOldDirectory() throws ExitException {
int numberOfExpectedComparison = 1 + ROOT_COUNT_2 * (ROOT_COUNT_1 - 1); // -1 for basecode
assertEquals(numberOfExpectedComparison, result.getAllComparisons().size());
}

@Test
@DisplayName("test single new submission")
void testSingleNewSubmission() throws ExitException {
List<String> newSubmissionsNames = List.of("2023");
List<String> oldSubmissionsNames = List.of("2022", "2021", "2020");
List<String> newSubmissions = newSubmissionsNames.stream().map(it -> getBasePath("SingleNewSubmission" + File.separator + it)).toList();
List<String> oldSubmissions = oldSubmissionsNames.stream().map(it -> getBasePath("SingleNewSubmission" + File.separator + it)).toList();

JPlagResult result = runJPlag(newSubmissions, oldSubmissions, it -> it);

long numberOfNewSubmissions = result.getSubmissions().getSubmissions().stream().filter(Submission::isNew).count();
long numberOfOldSubmissions = result.getSubmissions().getSubmissions().stream().filter(it -> !it.isNew()).count();
assertEquals(1, numberOfNewSubmissions);
assertEquals(3, numberOfOldSubmissions);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import java.util.ArrayList;
import java.util.List;

public class QSort2020 {
public String[] qsort(String[] array) {
if (array == null || array.length == 0) {
return array;
}
List<String> sortedList = quickSort(List.of(array));
return sortedList.toArray(new String[0]);
}

private List<String> quickSort(List<String> list) {
if (list.size() <= 1) {
return list;
}

String pivot = list.get(list.size() / 2);
List<String> less = new ArrayList<>();
List<String> equal = new ArrayList<>();
List<String> greater = new ArrayList<>();

for (String s : list) {
int comparison = s.compareTo(pivot);
if (comparison < 0) {
less.add(s);
} else if (comparison > 0) {
greater.add(s);
} else {
equal.add(s);
}
}

List<String> sorted = new ArrayList<>();
sorted.addAll(quickSort(less));
sorted.addAll(equal);
sorted.addAll(quickSort(greater));
return sorted;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import java.util.Stack;

public class QSort2021 {
public String[] qsort(String[] array) {
if (array == null || array.length == 0) {
return array;
}

Stack<int[]> stack = new Stack<>();
stack.push(new int[] { 0, array.length - 1 });

while (!stack.isEmpty()) {
int[] range = stack.pop();
int low = range[0], high = range[1];

if (low < high) {
int pivotIndex = partition(array, low, high);
stack.push(new int[] { low, pivotIndex - 1 });
stack.push(new int[] { pivotIndex + 1, high });
}
}

return array;
}

private int partition(String[] array, int low, int high) {
String pivot = array[high];
int i = low - 1;
for (int j = low; j < high; j++) {
if (array[j].compareTo(pivot) <= 0) {
i++;
swap(array, i, j);
}
}
swap(array, i + 1, high);
return i + 1;
}

private void swap(String[] array, int i, int j) {
String temp = array[i];
array[i] = array[j];
array[j] = temp;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
public class QSort2022 {
public String[] qsort(String[] array) {
if (array == null || array.length == 0) {
return array;
}
quickSort(array, 0, array.length - 1);
return array;
}

private void quickSort(String[] array, int low, int high) {
while (low < high) {
int pivotIndex = partition(array, low, high);
if (pivotIndex - low < high - pivotIndex) {
quickSort(array, low, pivotIndex - 1);
low = pivotIndex + 1;
} else {
quickSort(array, pivotIndex + 1, high);
high = pivotIndex - 1;
}
}
}

private int partition(String[] array, int low, int high) {
String pivot = array[high];
int i = low - 1;
for (int j = low; j < high; j++) {
if (array[j].compareTo(pivot) <= 0) {
i++;
swap(array, i, j);
}
}
swap(array, i + 1, high);
return i + 1;
}

private void swap(String[] array, int i, int j) {
String temp = array[i];
array[i] = array[j];
array[j] = temp;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
public class QSort2023 {
public String[] qsort(String[] array) {
if (array == null || array.length == 0) {
return array;
}
quickSort(array, 0, array.length - 1);
return array;
}

private void quickSort(String[] array, int low, int high) {
if (low < high) {
int pivotIndex = partition(array, low, high);
quickSort(array, low, pivotIndex - 1);
quickSort(array, pivotIndex + 1, high);
}
}

private int partition(String[] array, int low, int high) {
String pivot = array[high];
int i = low - 1;
for (int j = low; j < high; j++) {
if (array[j].compareTo(pivot) <= 0) {
i++;
swap(array, i, j);
}
}
swap(array, i + 1, high);
return i + 1;
}

private void swap(String[] array, int i, int j) {
String temp = array[i];
array[i] = array[j];
array[j] = temp;
}

}
7 changes: 7 additions & 0 deletions report-viewer/tests/e2e/OpenComparisonTest.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ interface DataSet {
secondSubmissionName: string
}

const regexPathSeparator = '(\\\\|\\/)';

const testSets: DataSet[] = [
{
datasetName: 'fileSingleRoot-report.zip',
Expand Down Expand Up @@ -39,6 +41,11 @@ const testSets: DataSet[] = [
firstSubmissionName: 'f0\\\\|/0',
secondSubmissionName: 'f1\\\\|/1'
},
{
datasetName: 'singleNewSubmission-report.zip',
firstSubmissionName: `2023${regexPathSeparator}QSort2023.java`,
secondSubmissionName: `2022${regexPathSeparator}QSort2022.java`,
},
{
datasetName: 'python-report.zip',
firstSubmissionName: '01.py',
Expand Down