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
4d2f62f4
Commit
4d2f62f4
authored
9 years ago
by
Mick Jordan
Browse files
Options
Downloads
Patches
Plain Diff
mx_fastr: add command to analyse package test outputs
parent
d252e878
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
mx.fastr/mx_fastr.py
+2
-0
2 additions, 0 deletions
mx.fastr/mx_fastr.py
mx.fastr/mx_fastr_pkgtest.py
+98
-0
98 additions, 0 deletions
mx.fastr/mx_fastr_pkgtest.py
with
100 additions
and
0 deletions
mx.fastr/mx_fastr.py
+
2
−
0
View file @
4d2f62f4
...
...
@@ -25,6 +25,7 @@ from os.path import join, sep, dirname, abspath
from
argparse
import
ArgumentParser
import
mx
import
mx_gate
import
mx_fastr_pkgtest
import
os
import
shutil
...
...
@@ -564,6 +565,7 @@ _commands = {
'
test
'
:
[
test
,
[
'
options
'
]],
'
rrepl
'
:
[
rrepl
,
'
[options]
'
],
'
installcran
'
:
[
installcran
,
'
[options]
'
],
'
pkgtestanalyze
'
:
[
mx_fastr_pkgtest
.
pkgtestanalyze
,
'
[options]
'
]
}
mx
.
update_commands
(
_fastr_suite
,
_commands
)
This diff is collapsed.
Click to expand it.
mx.fastr/mx_fastr_pkgtest.py
0 → 100644
+
98
−
0
View file @
4d2f62f4
#
# Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
import
os
from
os.path
import
join
from
argparse
import
ArgumentParser
def
_gather_test_outputs_forpkg
(
pkgdirpath
):
'''
return a list of paths to .Rout/.fail files in pkgdirpath
'''
result
=
[]
for
dirpath
,
_
,
files
in
os
.
walk
(
pkgdirpath
):
for
f
in
files
:
if
f
.
endswith
(
"
.Rout
"
)
or
f
.
endswith
(
"
.fail
"
):
result
.
append
(
join
(
dirpath
,
f
))
result
.
sort
()
return
result
def
_gather_test_outputs
(
testdir
,
pkgonly
):
'''
return a dict mapping package name to list of output file paths
'''
result
=
dict
()
for
dirpath
,
dirs
,
_
in
os
.
walk
(
testdir
):
for
d
in
dirs
:
if
pkgonly
is
None
or
d
==
pkgonly
:
result
[
d
]
=
_gather_test_outputs_forpkg
(
join
(
dirpath
,
d
))
return
result
def
_find_start
(
content
):
marker
=
"
Type
'
q()
'
to quit R.
"
for
i
in
range
(
len
(
content
)):
line
=
content
[
i
]
if
marker
in
line
:
return
i
+
1
def
_fuzzy_compare
(
gnur_content
,
fastr_content
):
gnur_start
=
_find_start
(
gnur_content
)
+
1
# Gnu has extra empty line
fastr_start
=
_find_start
(
fastr_content
)
result
=
0
i
=
gnur_start
while
i
+
gnur_start
<
len
(
gnur_content
):
if
gnur_content
[
i
+
gnur_start
]
!=
fastr_content
[
i
+
fastr_start
]:
result
=
1
break
i
=
i
+
1
return
result
def
pkgtestanalyze
(
args
):
'''
Analyze test package test results by comparing with GnuR output.
Return 0 if passed, non-zero if failed
'''
parser
=
ArgumentParser
(
prog
=
'
mx pkgtestanalyze
'
)
parser
.
add_argument
(
'
--dir
'
,
action
=
'
store
'
,
help
=
'
dir containing results
'
,
default
=
os
.
getcwd
())
parser
.
add_argument
(
'
--pkg
'
,
action
=
'
store
'
,
help
=
'
pkg to compare, default all
'
)
args
=
parser
.
parse_args
(
args
)
gnur
=
_gather_test_outputs
(
join
(
args
.
dir
,
"
test_gnur
"
),
args
.
pkg
)
fastr
=
_gather_test_outputs
(
join
(
args
.
dir
,
"
test
"
),
args
.
pkg
)
# gnur is definitive
result
=
0
# optimistic
for
pkg
,
gnur_outputs
in
gnur
.
iteritems
():
fastr_outputs
=
fastr
[
pkg
]
if
len
(
fastr_outputs
)
!=
len
(
gnur_outputs
):
result
=
1
break
for
i
in
range
(
len
(
gnur_outputs
)):
fastr_output
=
fastr_outputs
[
i
]
gnur_output
=
gnur_outputs
[
i
]
gnur_content
=
None
with
open
(
gnur_output
)
as
f
:
gnur_content
=
f
.
readlines
()
fastr_content
=
None
with
open
(
fastr_output
)
as
f
:
fastr_content
=
f
.
readlines
()
result
=
_fuzzy_compare
(
gnur_content
,
fastr_content
)
if
result
!=
0
:
break
return
result
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