Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Q
QueryR
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Julien Lopez
QueryR
Commits
3081b502
Commit
3081b502
authored
7 years ago
by
Florian Angerer
Browse files
Options
Downloads
Patches
Plain Diff
Fix: syntax errors.
parent
c379ce67
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
com.oracle.truffle.r.test.packages.analyzer/src/com/oracle/truffle/r/test/packages/analyzer/parser/LogFileParser.java
+108
-41
108 additions, 41 deletions
...ruffle/r/test/packages/analyzer/parser/LogFileParser.java
with
108 additions
and
41 deletions
com.oracle.truffle.r.test.packages.analyzer/src/com/oracle/truffle/r/test/packages/analyzer/parser/LogFileParser.java
+
108
−
41
View file @
3081b502
...
@@ -26,6 +26,7 @@ import java.io.BufferedReader;
...
@@ -26,6 +26,7 @@ import java.io.BufferedReader;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.nio.file.Files
;
import
java.nio.file.Files
;
import
java.nio.file.Path
;
import
java.nio.file.Path
;
import
java.nio.file.Paths
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.Collection
;
import
java.util.HashMap
;
import
java.util.HashMap
;
...
@@ -103,7 +104,7 @@ public class LogFileParser {
...
@@ -103,7 +104,7 @@ public class LogFileParser {
private
boolean
parseOverallStatus
()
throws
IOException
{
private
boolean
parseOverallStatus
()
throws
IOException
{
expect
(
Token
.
TEST_STATUS
);
expect
(
Token
.
TEST_STATUS
);
consumeLine
();
consumeLine
();
return
parseStatus
(
trim
(
curLine
.
text
).
substring
((
getPkgName
()
+
": "
).
length
()));
return
parseStatus
(
trim
(
curLine
.
text
).
substring
((
getPkgName
()
+
": "
).
length
()))
.
toBoolean
()
;
}
}
private
static
boolean
isEOF
(
Line
l
)
{
private
static
boolean
isEOF
(
Line
l
)
{
...
@@ -119,41 +120,49 @@ public class LogFileParser {
...
@@ -119,41 +120,49 @@ public class LogFileParser {
private
Section
parseCheckResults
()
throws
IOException
{
private
Section
parseCheckResults
()
throws
IOException
{
expect
(
Token
.
BEGIN_CHECKING
);
expect
(
Token
.
BEGIN_CHECKING
);
consumeLine
();
Section
checkResults
=
new
Section
(
logFile
,
Token
.
BEGIN_CHECKING
.
linePrefix
,
curLine
.
lineNr
);
Section
checkResults
=
new
Section
(
logFile
,
Token
.
BEGIN_CHECKING
.
linePrefix
,
curLine
.
lineNr
);
checkResults
.
problems
=
new
LinkedList
<>();
checkResults
.
problems
=
new
LinkedList
<>();
// TODO depending on the result, parse other files
// TODO depending on the result, parse other files
if
(
curLine
.
text
.
contains
(
Token
.
FAIL_OUTPUT_GNUR
.
linePrefix
))
{
for
(;;)
{
// TODO
if
(
la
.
text
.
contains
(
Token
.
FAIL_OUTPUT_GNUR
.
linePrefix
))
{
}
else
if
(
curLine
.
text
.
contains
(
Token
.
FAIL_OUTPUT_FASTR
.
linePrefix
))
{
consumeLine
();
// TODO
// TODO
}
else
if
(
curLine
.
text
.
contains
(
Token
.
MISSING_OUTPUT_FILE
.
linePrefix
))
{
}
else
if
(
la
.
text
.
contains
(
Token
.
FAIL_OUTPUT_FASTR
.
linePrefix
))
{
// TODO
consumeLine
();
}
else
if
(
curLine
.
text
.
contains
(
Token
.
CONTENT_MALFORMED
.
linePrefix
))
{
// TODO
// TODO
}
else
if
(
la
.
text
.
contains
(
Token
.
MISSING_OUTPUT_FILE
.
linePrefix
))
{
}
else
if
(
curLine
.
text
.
contains
(
Token
.
OUTPUT_MISMATCH_FASTR
.
linePrefix
))
{
consumeLine
();
// extract file name of output file
// TODO
// format: <pkg name>: FastR output mismatch: <out file name>
}
else
if
(
la
.
text
.
contains
(
Token
.
CONTENT_MALFORMED
.
linePrefix
))
{
int
idx
=
curLine
.
text
.
indexOf
(
Token
.
OUTPUT_MISMATCH_FASTR
.
linePrefix
);
consumeLine
();
String
fileNameStr
=
curLine
.
text
.
substring
(
idx
+
Token
.
OUTPUT_MISMATCH_FASTR
.
linePrefix
.
length
()).
trim
();
int
idx
=
curLine
.
text
.
indexOf
(
Token
.
CONTENT_MALFORMED
.
linePrefix
);
Path
outputFile
=
logFile
.
path
.
resolveSibling
(
fileNameStr
);
String
fileNameStr
=
curLine
.
text
.
substring
(
idx
+
Token
.
CONTENT_MALFORMED
.
linePrefix
.
length
()).
trim
();
checkResults
.
problems
.
add
(
new
ContentMalformedProblem
(
pkg
,
getCurrentLocation
(),
fileNameStr
));
// report the problem
}
else
if
(
la
.
text
.
contains
(
Token
.
OUTPUT_MISMATCH_FASTR
.
linePrefix
))
{
checkResults
.
problems
.
add
(
new
OutputMismatchProblem
(
pkg
,
getCurrentLocation
(),
fileNameStr
));
consumeLine
();
// extract file name of output file
if
(!
Files
.
isReadable
(
outputFile
))
{
// format: <pkg name>: FastR output mismatch: <out file name>
LOGGER
.
warning
(
"Cannot read output file "
+
outputFile
);
int
idx
=
curLine
.
text
.
indexOf
(
Token
.
OUTPUT_MISMATCH_FASTR
.
linePrefix
);
String
fileNameStr
=
curLine
.
text
.
substring
(
idx
+
Token
.
OUTPUT_MISMATCH_FASTR
.
linePrefix
.
length
()).
trim
();
// consume any lines to be able to continue
Path
outputFile
=
logFile
.
path
.
resolveSibling
(
Paths
.
get
(
"testfiles"
,
"fastr"
,
fileNameStr
));
collectBody
(
Token
.
END_CHECKING
);
// report the problem
checkResults
.
problems
.
add
(
new
OutputMismatchProblem
(
pkg
,
getCurrentLocation
(),
fileNameStr
));
if
(!
Files
.
isReadable
(
outputFile
))
{
LOGGER
.
warning
(
"Cannot read output file "
+
outputFile
);
// consume any lines to be able to continue
collectBody
(
Token
.
END_CHECKING
);
}
else
{
checkResults
.
problems
.
addAll
(
applyDetectors
(
Token
.
OUTPUT_MISMATCH_FASTR
,
outputFile
,
0
,
Files
.
readAllLines
(
outputFile
)));
}
checkResults
.
setSuccess
(
false
);
}
else
{
}
else
{
checkResults
.
problems
.
addAll
(
applyDetectors
(
Token
.
OUTPUT_MISMATCH_FASTR
,
outputFile
,
0
,
Files
.
readAllLines
(
outputFile
)))
;
break
;
}
}
checkResults
.
setSuccess
(
false
);
}
else
{
throw
parseError
(
"Unexpected checking message: "
+
curLine
.
text
);
}
}
expect
(
Token
.
END_CHECKING
);
expect
(
Token
.
END_CHECKING
);
...
@@ -173,11 +182,12 @@ public class LogFileParser {
...
@@ -173,11 +182,12 @@ public class LogFileParser {
if
(!(
"FastR"
.
equals
(
mode
)
||
"GnuR"
.
equals
(
mode
)))
{
if
(!(
"FastR"
.
equals
(
mode
)
||
"GnuR"
.
equals
(
mode
)))
{
throw
parseError
(
"Invalid mode: "
+
mode
);
throw
parseError
(
"Invalid mode: "
+
mode
);
}
}
installTest
.
setMode
(
mode
);
Section
installationTask
=
parseInstallationTask
();
Section
installationTask
=
parseInstallationTask
();
installTest
.
addSection
(
installationTask
);
installTest
.
addSection
(
installationTask
);
if
(
"FastR"
.
equals
(
mode
))
{
if
(
"FastR"
.
equals
(
mode
))
{
installTest
.
setSuccess
(
parseInstallStatus
()
&&
success
);
installTest
.
setSuccess
(
parseInstallStatus
()
.
toBoolean
()
&&
success
);
}
}
installTest
.
addSection
(
parseInstallSuggests
());
installTest
.
addSection
(
parseInstallSuggests
());
...
@@ -222,8 +232,6 @@ public class LogFileParser {
...
@@ -222,8 +232,6 @@ public class LogFileParser {
if
(
laMatches
(
Token
.
RUNNING_SPECIFIC_TESTS
))
{
if
(
laMatches
(
Token
.
RUNNING_SPECIFIC_TESTS
))
{
consumeLine
();
consumeLine
();
boolean
success
=
true
;
// e.g.: Running ‘runRUnitTests.R’
// e.g.: Running ‘runRUnitTests.R’
while
(
laMatches
(
"Running "
))
{
while
(
laMatches
(
"Running "
))
{
consumeLine
();
consumeLine
();
...
@@ -244,10 +252,12 @@ public class LogFileParser {
...
@@ -244,10 +252,12 @@ public class LogFileParser {
testing
.
problems
.
addAll
(
applyDetectors
(
Token
.
RUNNING_SPECIFIC_TESTS
,
chunk
.
getRightFile
(),
chunk
.
getRightStartLine
(),
chunk
.
getRight
()));
testing
.
problems
.
addAll
(
applyDetectors
(
Token
.
RUNNING_SPECIFIC_TESTS
,
chunk
.
getRightFile
(),
chunk
.
getRightStartLine
(),
chunk
.
getRight
()));
}
}
});
});
consumeLine
();
parseStatus
(
trim
(
curLine
.
text
));
}
else
{
int
dotsIdx
=
curLine
.
text
.
lastIndexOf
(
"..."
);
parseStatus
(
trim
(
curLine
.
text
.
substring
(
dotsIdx
+
"..."
.
length
())));
}
}
consumeLine
();
success
=
parseStatus
(
trim
(
curLine
.
text
))
&&
success
;
}
}
}
}
}
}
...
@@ -288,24 +298,26 @@ public class LogFileParser {
...
@@ -288,24 +298,26 @@ public class LogFileParser {
return
installation
;
return
installation
;
}
}
private
boolean
parseInstallStatus
()
throws
IOException
{
private
TestResult
parseInstallStatus
()
throws
IOException
{
expect
(
Token
.
BEGIN_INSTALL_STATUS
);
expect
(
Token
.
BEGIN_INSTALL_STATUS
);
// pkgName: FAILED / OK
// pkgName: FAILED / OK
expect
(
getPkgName
());
expect
(
getPkgName
());
boolean
succes
s
=
parseStatus
(
trim
(
curLine
.
text
).
substring
((
getPkgName
()
+
": "
).
length
()));
TestResult
re
s
=
parseStatus
(
trim
(
curLine
.
text
).
substring
((
getPkgName
()
+
": "
).
length
()));
expect
(
Token
.
END_INSTALL_STATUS
);
expect
(
Token
.
END_INSTALL_STATUS
);
return
succes
s
;
return
re
s
;
}
}
private
String
getPkgName
()
{
private
String
getPkgName
()
{
return
pkg
.
getPackage
().
getName
();
return
pkg
.
getPackage
().
getName
();
}
}
private
boolean
parseStatus
(
String
substring
)
{
private
TestResult
parseStatus
(
String
substring
)
{
if
(
Token
.
OK
.
linePrefix
.
equals
(
substring
.
trim
()))
{
if
(
Token
.
OK
.
linePrefix
.
equals
(
substring
.
trim
()))
{
return
true
;
return
TestResult
.
OK
;
}
else
if
(
Token
.
FAILED
.
linePrefix
.
equals
(
substring
.
trim
()))
{
}
else
if
(
Token
.
FAILED
.
linePrefix
.
equals
(
substring
.
trim
()))
{
return
false
;
return
TestResult
.
FAILED
;
}
else
if
(
Token
.
INDETERMINATE
.
linePrefix
.
equals
(
substring
.
trim
()))
{
return
TestResult
.
INDETERMINATE
;
}
}
throw
parseError
(
"Unexpected status: "
+
substring
);
throw
parseError
(
"Unexpected status: "
+
substring
);
}
}
...
@@ -494,6 +506,16 @@ public class LogFileParser {
...
@@ -494,6 +506,16 @@ public class LogFileParser {
}
}
}
}
public
enum
TestResult
{
OK
,
FAILED
,
INDETERMINATE
;
boolean
toBoolean
()
{
return
OK
.
equals
(
this
);
}
}
public
enum
Token
{
public
enum
Token
{
BEGIN_INSTALL_TEST
(
"BEGIN install/test with "
),
BEGIN_INSTALL_TEST
(
"BEGIN install/test with "
),
...
@@ -526,6 +548,7 @@ public class LogFileParser {
...
@@ -526,6 +548,7 @@ public class LogFileParser {
RUNNING_VIGNETTES
(
"Running vignettes for package"
),
RUNNING_VIGNETTES
(
"Running vignettes for package"
),
FAILED
(
"FAILED"
),
FAILED
(
"FAILED"
),
INDETERMINATE
(
"INDETERMINATE"
),
OK
(
"OK"
);
OK
(
"OK"
);
String
linePrefix
;
String
linePrefix
;
...
@@ -594,6 +617,7 @@ public class LogFileParser {
...
@@ -594,6 +617,7 @@ public class LogFileParser {
public
static
class
Section
extends
AbstractSection
{
public
static
class
Section
extends
AbstractSection
{
private
String
name
;
private
String
name
;
private
String
mode
;
private
int
startLine
;
private
int
startLine
;
private
AbstractSection
parent
;
private
AbstractSection
parent
;
Collection
<
Problem
>
problems
;
Collection
<
Problem
>
problems
;
...
@@ -608,6 +632,14 @@ public class LogFileParser {
...
@@ -608,6 +632,14 @@ public class LogFileParser {
return
parent
;
return
parent
;
}
}
public
String
getMode
()
{
return
mode
;
}
public
void
setMode
(
String
mode
)
{
this
.
mode
=
mode
;
}
@Override
@Override
public
String
toString
()
{
public
String
toString
()
{
return
String
.
format
(
"Section %s (start: %d, problems: %d)"
,
name
,
startLine
,
problems
!=
null
?
problems
.
size
()
:
0
);
return
String
.
format
(
"Section %s (start: %d, problems: %d)"
,
name
,
startLine
,
problems
!=
null
?
problems
.
size
()
:
0
);
...
@@ -662,4 +694,39 @@ public class LogFileParser {
...
@@ -662,4 +694,39 @@ public class LogFileParser {
}
}
}
}
public
static
class
ContentMalformedProblem
extends
Problem
{
private
final
String
details
;
protected
ContentMalformedProblem
(
RPackageTestRun
pkg
,
Location
location
,
String
details
)
{
super
(
pkg
,
location
);
this
.
details
=
details
;
}
@Override
public
String
getSummary
()
{
return
Token
.
CONTENT_MALFORMED
.
linePrefix
;
}
@Override
public
String
getDetails
()
{
return
details
;
}
@Override
public
String
toString
()
{
return
getSummary
()
+
details
;
}
@Override
public
int
getSimilarityTo
(
Problem
other
)
{
return
0
;
}
@Override
public
boolean
isSimilarTo
(
Problem
other
)
{
return
true
;
}
}
}
}
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