Allow the CR character as part of a newline.
Since CodeOcean may send the `\r\n` newline.
This commit is contained in:
@ -24,7 +24,7 @@ class SimpleMakefile {
|
|||||||
private static final Pattern isMakeCommand = Pattern.compile("^make(?:\\s+(?<startRule>\\w*))?$");
|
private static final Pattern isMakeCommand = Pattern.compile("^make(?:\\s+(?<startRule>\\w*))?$");
|
||||||
|
|
||||||
// This pattern identifies the rules in a makefile.
|
// This pattern identifies the rules in a makefile.
|
||||||
private static final Pattern makeRules = Pattern.compile("(?<name>.*):\\n(?<commands>(?:\\t.+\\n?)*)");
|
private static final Pattern makeRules = Pattern.compile("(?<name>.*):\\r?\\n(?<commands>(?:\\t.+\\r?\\n?)*)");
|
||||||
|
|
||||||
// The first rule of the makefile.
|
// The first rule of the makefile.
|
||||||
private String firstRule = null;
|
private String firstRule = null;
|
||||||
|
@ -22,6 +22,15 @@ public class SimpleMakefileTest {
|
|||||||
"\techo Hi\n"
|
"\techo Hi\n"
|
||||||
).getBytes(StandardCharsets.UTF_8));
|
).getBytes(StandardCharsets.UTF_8));
|
||||||
|
|
||||||
|
static final String SuccessfulWindowsMakefile = Base64.getEncoder().encodeToString(
|
||||||
|
("run:\r\n" +
|
||||||
|
"\tjavac org/example/RecursiveMath.java\r\n" +
|
||||||
|
"\tjava org/example/RecursiveMath\r\n" +
|
||||||
|
"\r\n" +
|
||||||
|
"test:\r\n" +
|
||||||
|
"\techo Hi\r\n"
|
||||||
|
).getBytes(StandardCharsets.UTF_8));
|
||||||
|
|
||||||
static final String NotSupportedMakefile = Base64.getEncoder().encodeToString(
|
static final String NotSupportedMakefile = Base64.getEncoder().encodeToString(
|
||||||
("run: test\n" +
|
("run: test\n" +
|
||||||
"\tjavac org/example/RecursiveMath.java\n" +
|
"\tjavac org/example/RecursiveMath.java\n" +
|
||||||
@ -48,6 +57,23 @@ public class SimpleMakefileTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void sucessfullMakeWithCR() {
|
||||||
|
Map<String, String> files = new HashMap<>();
|
||||||
|
files.put("Makefile", SuccessfulWindowsMakefile);
|
||||||
|
files.put("org/example/RecursiveMath.java", RecursiveMathContent);
|
||||||
|
|
||||||
|
try {
|
||||||
|
String command = "make run";
|
||||||
|
SimpleMakefile makefile = new SimpleMakefile(files);
|
||||||
|
String cmd = makefile.parseCommand(command);
|
||||||
|
|
||||||
|
assertEquals("javac org/example/RecursiveMath.java && java org/example/RecursiveMath", cmd);
|
||||||
|
} catch (NoMakefileFoundException | InvalidMakefileException | NoMakeCommandException ignored) {
|
||||||
|
fail();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void withoutMake() {
|
public void withoutMake() {
|
||||||
Map<String, String> files = new HashMap<>();
|
Map<String, String> files = new HashMap<>();
|
||||||
|
@ -127,6 +127,7 @@ func (w *AWSFunctionWorkload) executeCommand(ctx context.Context, command []stri
|
|||||||
Cmd: command,
|
Cmd: command,
|
||||||
Files: w.fs,
|
Files: w.fs,
|
||||||
}
|
}
|
||||||
|
log.WithField("request", data).Trace("Sending request to AWS")
|
||||||
rawData, err := json.Marshal(data)
|
rawData, err := json.Marshal(data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
exit <- ExitInfo{uint8(1), fmt.Errorf("cannot stingify aws function request: %w", err)}
|
exit <- ExitInfo{uint8(1), fmt.Errorf("cannot stingify aws function request: %w", err)}
|
||||||
|
Reference in New Issue
Block a user