Skip to content
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
4 changes: 0 additions & 4 deletions tmc-langs-r/getAvailablePoints.sh

This file was deleted.

3 changes: 0 additions & 3 deletions tmc-langs-r/runTests.sh

This file was deleted.

27 changes: 10 additions & 17 deletions tmc-langs-r/src/main/java/fi/helsinki/cs/tmc/langs/r/RPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -144,32 +144,25 @@ public ValidationResult checkCodeStyle(Path path, Locale messageLocale) {
}

public String[] getTestCommand() {

String[] rscr;
String[] command;
String[] command = new String[] {"Rscript"};
String[] args;
if (SystemUtils.IS_OS_WINDOWS) {
rscr = new String[] {"Rscript", "-e"};
command = new String[] {"\"library('tmcRtestrunner');run_tests_with_default(TRUE)\""};
args = new String[] {"-e", "\"library('tmcRtestrunner');run_tests()\""};
} else {
rscr = new String[] {"bash"};
command = new String[] {Paths.get("").toAbsolutePath().toString() + "/runTests.sh"};
args = new String[] {"-e", "library(tmcRtestrunner);run_tests()"};
}
return ArrayUtils.addAll(rscr, command);
return ArrayUtils.addAll(command, args);
}

public String[] getAvailablePointsCommand() {
String[] rscr;
String[] command;
String[] command = new String[] {"Rscript"};
String[] args;
if (SystemUtils.IS_OS_WINDOWS) {
rscr = new String[] {"Rscript", "-e"};
command = new String[] {"\"library(tmcRtestrunner);"
+ "run_available_points(\"$PWD\")\""};
args = new String[] {"-e", "\"library('tmcRtestrunner');run_available_points()\""};
} else {
rscr = new String[] {"bash"};
command = new String[] {Paths.get("").toAbsolutePath().toString()
+ "/getAvailablePoints.sh"};
args = new String[] {"-e", "library(tmcRtestrunner);run_available_points()"};
}
return ArrayUtils.addAll(rscr, command);
return ArrayUtils.addAll(command, args);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import fi.helsinki.cs.tmc.langs.io.StudentFilePolicy;
import fi.helsinki.cs.tmc.langs.utils.TestUtils;

import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.SystemUtils;
import org.junit.After;
import org.junit.Assert;
Expand Down Expand Up @@ -38,32 +39,29 @@ public void tearDown() {

@Test
public void testGetTestCommand() {
String[] command = new String[] {"Rscript"};
String[] args;

if (SystemUtils.IS_OS_WINDOWS) {
String[] expectedCommand = new String[]{"Rscript", "-e",
"\"library('tmcRtestrunner');run_tests_with_default(TRUE)\""};

Assert.assertArrayEquals(expectedCommand,plugin.getTestCommand());
} else if (SystemUtils.IS_OS_LINUX) {
String[] expectedCommand = new String[]{"bash",
Paths.get("").toAbsolutePath().toString() + "/runTests.sh"};

Assert.assertArrayEquals(expectedCommand,plugin.getTestCommand());
args = new String[] {"-e", "\"library('tmcRtestrunner');run_tests()\""};
} else {
args = new String[] {"-e", "library(tmcRtestrunner);run_tests()"};
}
String[] expectedCommand = ArrayUtils.addAll(command, args);
Assert.assertArrayEquals(expectedCommand,plugin.getTestCommand());
}

@Test
public void testGetAvailablePointsCommand() {
String[] command = new String[] {"Rscript"};
String[] args;
if (SystemUtils.IS_OS_WINDOWS) {
String[] expectedCommand = new String[]{"Rscript", "-e","\"library('tmcRtestrunner');"
+ "get_available_points(\"$PWD\")\""};

Assert.assertArrayEquals(expectedCommand,plugin.getAvailablePointsCommand());
} else if (SystemUtils.IS_OS_LINUX) {
String[] expectedCommand = new String[]{"bash",
Paths.get("").toAbsolutePath().toString() + "/getAvailablePoints.sh"};

Assert.assertArrayEquals(expectedCommand,plugin.getAvailablePointsCommand());
args = new String[] {"-e", "\"library('tmcRtestrunner');run_available_points()\""};
} else {
args = new String[] {"-e", "library(tmcRtestrunner);run_available_points()"};
}
String[] expectedCommand = ArrayUtils.addAll(command, args);
Assert.assertArrayEquals(expectedCommand, plugin.getAvailablePointsCommand());
}

@Test
Expand Down