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
98a40118
Commit
98a40118
authored
8 years ago
by
Lukas Stadler
Browse files
Options
Downloads
Patches
Plain Diff
show percentage of passing tests in rbcheck
parent
b5744e1c
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
com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/tools/RBuiltinCheck.java
+29
-10
29 additions, 10 deletions
...st/src/com/oracle/truffle/r/test/tools/RBuiltinCheck.java
with
29 additions
and
10 deletions
com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/tools/RBuiltinCheck.java
+
29
−
10
View file @
98a40118
...
...
@@ -28,10 +28,10 @@ import java.nio.file.Files;
import
java.nio.file.Paths
;
import
java.util.Arrays
;
import
java.util.EnumSet
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.TreeMap
;
import
java.util.TreeSet
;
import
java.util.function.BiPredicate
;
import
java.util.function.Function
;
import
java.util.regex.Matcher
;
...
...
@@ -44,6 +44,7 @@ import com.oracle.truffle.r.nodes.builtin.base.BasePackage;
import
com.oracle.truffle.r.runtime.RBuiltin
;
import
com.oracle.truffle.r.runtime.RBuiltinKind
;
import
com.oracle.truffle.r.runtime.RVisibility
;
import
com.oracle.truffle.r.test.TestBase.Ignored
;
/**
* Utility to analyze builtins implemented in FastR vs. builtins available in GNU R. The GNU R
...
...
@@ -62,6 +63,7 @@ import com.oracle.truffle.r.runtime.RVisibility;
public
final
class
RBuiltinCheck
{
private
static
final
String
DEFAULT_NAMESC
=
"com.oracle.truffle.r.native/gnur/R-3.2.4/src/main/names.c"
;
private
static
final
String
BUILTIN_TEST_PATH
=
"com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_%s.java"
;
// old-style code annotation to get rid of javadoc error.
/**
...
...
@@ -170,7 +172,7 @@ public final class RBuiltinCheck {
return
;
// so that gnur can be final
}
Set
<
String
>
both
=
new
Hash
Set
<>(
fastr
.
keySet
());
Set
<
String
>
both
=
new
Tree
Set
<>(
fastr
.
keySet
());
both
.
retainAll
(
gnur
.
keySet
());
Set
<
String
>
fastrOnly
=
keysWithout
(
fastr
,
both
);
...
...
@@ -181,14 +183,14 @@ public final class RBuiltinCheck {
both
.
removeAll
(
descriptorsDiff
.
keySet
());
// Print the results
printOutput
(
show
,
both
,
descriptorsDiff
,
fastrOnly
,
gnurOnly
);
printOutput
(
suitePath
,
show
,
both
,
descriptorsDiff
,
fastrOnly
,
gnurOnly
);
}
private
static
void
printOutput
(
EnumSet
<
FilterOption
>
show
,
Set
<
String
>
both
,
Map
<
String
,
BuiltinTuple
>
descriptorsDiff
,
Set
<
String
>
fastrOnly
,
Set
<
String
>
gnurOnly
)
{
private
static
void
printOutput
(
String
suitePath
,
EnumSet
<
FilterOption
>
show
,
Set
<
String
>
both
,
Map
<
String
,
BuiltinTuple
>
descriptorsDiff
,
Set
<
String
>
fastrOnly
,
Set
<
String
>
gnurOnly
)
{
String
prefix
=
""
;
if
(
show
.
contains
(
FilterOption
.
BOTH
))
{
prefix
=
printHeader
(
prefix
,
show
,
"Builtins in both GNU R and FastR with matching descriptors: "
+
both
.
size
());
both
.
stream
().
forEach
(
System
.
out
::
println
);
both
.
stream
().
forEach
(
b
->
printBuiltinWithTest
(
b
,
suitePath
)
);
}
if
(
show
.
contains
(
FilterOption
.
BOTH_DIFF
))
{
...
...
@@ -220,6 +222,24 @@ public final class RBuiltinCheck {
}
}
private
static
void
printBuiltinWithTest
(
String
builtin
,
String
suitePath
)
{
String
name
=
builtin
.
replace
(
"."
,
""
);
name
=
name
.
replace
(
"<-"
,
"assign"
);
try
{
String
content
=
Files
.
lines
(
Paths
.
get
(
suitePath
,
String
.
format
(
BUILTIN_TEST_PATH
,
name
))).
collect
(
Collectors
.
joining
(
"\n"
));
int
tests
=
content
.
split
(
"assertEval"
).
length
-
1
;
int
ignoredTests
=
content
.
split
(
Ignored
.
class
.
getSimpleName
()).
length
-
1
;
if
(
tests
>
0
)
{
String
testDetails
=
String
.
format
(
"%3d%% (%d/%d)"
,
(
tests
-
ignoredTests
)
*
100
/
tests
,
tests
-
ignoredTests
,
tests
);
System
.
out
.
printf
(
"%-15s %s%n"
,
builtin
,
testDetails
);
return
;
}
}
catch
(
IOException
e
)
{
// nothing to do
}
System
.
out
.
printf
(
"%-20s (no tests found)%n"
,
builtin
);
}
private
static
String
formatTableCell
(
String
format
,
BuiltinTuple
tuple
,
Function
<
BuiltinInfo
,
Object
>
selector
,
BiPredicate
<
BuiltinInfo
,
BuiltinInfo
>
cmp
)
{
String
result
=
String
.
format
(
format
,
selector
.
apply
(
tuple
.
fastr
),
selector
.
apply
(
tuple
.
gnur
));
if
(!
cmp
.
test
(
tuple
.
fastr
,
tuple
.
gnur
))
{
...
...
@@ -235,19 +255,18 @@ public final class RBuiltinCheck {
if
(
show
.
size
()
>
1
)
{
System
.
out
.
println
(
prefix
+
header
);
}
return
"\n\n"
;
}
private
static
Set
<
String
>
keysWithout
(
Map
<
String
,
BuiltinInfo
>
map
,
Set
<
String
>
both
)
{
Set
<
String
>
mapOnly
=
new
Hash
Set
<>(
map
.
keySet
());
Set
<
String
>
mapOnly
=
new
Tree
Set
<>(
map
.
keySet
());
mapOnly
.
removeAll
(
both
);
return
mapOnly
;
}
private
static
Map
<
String
,
BuiltinInfo
>
extractFastRBuiltins
()
{
BasePackage
base
=
new
BasePackage
();
Hash
Map
<
String
,
BuiltinInfo
>
result
=
new
Hash
Map
<>();
Map
<
String
,
BuiltinInfo
>
result
=
new
Tree
Map
<>();
for
(
Map
.
Entry
<
String
,
RBuiltinFactory
>
builtin
:
base
.
getBuiltins
().
entrySet
())
{
Class
<?>
clazz
=
builtin
.
getValue
().
getBuiltinNodeClass
();
RBuiltin
annotation
=
clazz
.
getAnnotation
(
RBuiltin
.
class
);
...
...
@@ -264,7 +283,7 @@ public final class RBuiltinCheck {
private
static
Map
<
String
,
BuiltinInfo
>
extractGnuRBuiltins
(
String
suiteDir
)
throws
IOException
{
String
content
=
Files
.
lines
(
Paths
.
get
(
suiteDir
,
DEFAULT_NAMESC
)).
collect
(
Collectors
.
joining
(
"\n"
));
Matcher
matcher
=
Pattern
.
compile
(
FUNTAB_REGEXP
).
matcher
(
content
);
Hash
Map
<
String
,
BuiltinInfo
>
result
=
new
Hash
Map
<>();
Map
<
String
,
BuiltinInfo
>
result
=
new
Tree
Map
<>();
while
(
matcher
.
find
())
{
// normalize eval to three digits, e.g. '2' to '002'
String
eval
=
String
.
format
(
"%1$3s"
,
matcher
.
group
(
"eval"
)).
replace
(
' '
,
'0'
);
...
...
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