Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
DefaultTestRunner
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
YAPEX
DefaultTestRunner
Commits
f8601464
Commit
f8601464
authored
8 years ago
by
Janis Daniel Dähne
Browse files
Options
Downloads
Patches
Plain Diff
- timeout was not applied (runner was not terminating when the users program not terminated)
parent
65aa5dd5
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Main.java
+41
-10
41 additions, 10 deletions
src/Main.java
with
41 additions
and
10 deletions
src/Main.java
+
41
−
10
View file @
f8601464
...
...
@@ -119,8 +119,13 @@ public class Main {
static
String
DefaultCGroupName
=
"syndrom"
;
public
static
void
main
(
String
[]
myArgs
)
throws
IOException
{
if
(
isDebug
)
{
System
.
out
.
println
(
Arrays
.
toString
(
myArgs
));
}
...
...
@@ -294,9 +299,9 @@ public class Main {
ArrayList
<
String
>
testContents
=
new
ArrayList
<>();
if
(
useDebugTestContent
)
{
testContents
.
add
(
"$ 1"
);
//
testContents.add("$ 1");
testContents
.
add
(
"> 0"
);
testContents
.
add
(
"> 1"
);
//
testContents.add("> 1");
//testContents.add("< 42");
//testContents.add("> 42");
//testContents.add("> 42");
...
...
@@ -656,18 +661,22 @@ public class Main {
}
catch
(
InterruptedException
e
)
{
//timeout hit
returnValue
=
1
;
futureResult
=
-
100
;
}
catch
(
ExecutionException
e
)
{
//this also happens if the program (to test) throws an error
//System.out.println("ExecutionException occurred");
returnValue
=
2
;
futureResult
=
-
100
;
}
catch
(
TimeoutException
e
)
{
//timeout hit
returnValue
=
3
;
futureResult
=
-
100
;
}
catch
(
IllegalThreadStateException
e
)
{
//executor.shutdownNow();
p
.
destroy
();
//TODO does not stop child processes --> http://stackoverflow.com/questions/6356340/killing-a-process-using-java
returnValue
=
3
;
futureResult
=
-
100
;
}
if
(
isDebug
)
{
...
...
@@ -681,13 +690,29 @@ public class Main {
readDebugFromErrorStream
(
errReader
,
true
);
String
line
=
null
;
while
(
reader
[
0
].
ready
())
{
//if the test ended and the program outputs something the test should fail...
if
((
line
=
reader
[
0
].
readLine
())
!=
null
)
{
Conversation
.
add
(
outputFromProgramChar
+
" "
+
toSafeLine
(
line
.
trim
()));
Conversation
.
add
(
expectedOutputPrefix
+
" "
+
""
);
//no more output expected... -> empty
outputMismatch
[
0
]
=
true
;
if
(
returnValue
==
0
)
{
//process has finished normally so we can safely check the reader.ready()
//when there is a timeout (because user program waits for input reader.ready() would block this program...
//but the program terminated normally here...
while
(
reader
[
0
].
ready
())
{
//this line blocks if the process has not yet ended (user program waits for input??)
//if the test ended and the program outputs something the test should fail...
if
((
line
=
reader
[
0
].
readLine
())
!=
null
)
{
Conversation
.
add
(
outputFromProgramChar
+
" "
+
toSafeLine
(
line
.
trim
()));
Conversation
.
add
(
expectedOutputPrefix
+
" "
+
""
);
//no more output expected... -> empty
outputMismatch
[
0
]
=
true
;
}
}
}
else
{
//process has ended in an unusual way...
//Conversation.add(outputFromProgramChar + " " + toSafeLine(line.trim()));
//Conversation.add(expectedOutputPrefix + " " + ""); //no more output expected... -> empty
//pretend false output
//outputMismatch[0] = true;
//some thread exception ... pretend timeout...
returnValue
=
3
;
}
writer
[
0
].
close
();
...
...
@@ -696,8 +721,11 @@ public class Main {
//e.printStackTrace();
}
if
(
futureResult
!=
0
)
{
// 0 = all went well (java code)
// 0 = all went well (java code)
//-100 is timeout --> returnValue is 3
//this if would change this to 2
if
(
futureResult
!=
0
&&
futureResult
!=
-
100
)
{
//else some error?
errorReader
=
new
BufferedReader
(
new
InputStreamReader
(
p
.
getErrorStream
()));
...
...
@@ -715,6 +743,9 @@ public class Main {
//e.printStackTrace();
}
//}
//some error occurred during execution of the users program (e.g. numberformat exception....)
returnValue
=
2
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment