Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
backend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Monitor
Service Desk
Analyze
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
subugoe
ahiqar
backend
Commits
e7d43557
Commit
e7d43557
authored
4 years ago
by
Michelle Weidling
Browse files
Options
Downloads
Patches
Plain Diff
tests: make output human and machine readable
Closes
#61
parent
70521260
Branches
Branches containing commit
Tags
Tags containing commit
4 merge requests
!75
Develop
,
!73
Merge `develop` into `main`
,
!70
Develop
,
!55
Feature/#52 annotationapi tests
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
exist-app/modules/testtrigger.xqm
+49
-63
49 additions, 63 deletions
exist-app/modules/testtrigger.xqm
with
49 additions
and
63 deletions
exist-app/modules/testtrigger.xqm
+
49
−
63
View file @
e7d43557
xquery
version
"3.1"
;
(:~
: Providing an API endpoint for triggering test execution.
: This endpoint has been established instead of the text execution in post-install.xq
: since at this point the RESTXQ API isn't fired up yet which causes the tests to throw errors.
:
: @author Michelle Weidling
: @since 0.4.0
: Script providing access to the test functions (XQSuite) for local unit test
: execution.
: Elevated rights (dba/admin) are required for some tests.
:)
module
namespace
t
esttrigger
=
"http://ahikar.sub.uni-goettingen.de/ns/t
esttrigger
"
;
import
module
namespace
res
t
=
"http://
exquery.org/ns/rest
xq"
;
import
module
namespace
t
tt
=
"http://ahikar.sub.uni-goettingen.de/ns/t
api/txt/tests"
at
"tapi-txt-tests.xqm
"
;
import
module
namespace
ct
=
"http://ahikar.sub.uni-goettingen.de/ns/commons-tests"
at
"commons-tests.xqm"
;
import
module
namespace
tc
t
=
"http://
ahikar.sub.uni-goettingen.de/ns/tapi/collection/tests"
at
"tapi-collection-tests.
xq
m
"
;
import
module
namespace
test
=
"http://exist-db.org/xquery/xqsuite"
at
"resource:org/exist/xquery/lib/xqsuite/xqsuite.xql"
;
import
module
namespace
ct
=
"http://ahikar.sub.uni-goettingen.de/ns/commons-tests"
at
"../tests/commons-tests.xqm"
;
import
module
namespace
t2ht
=
"http://ahikar.sub.uni-goettingen.de/ns/tei2html-tests"
at
"../tests/tei2html-tests.xqm"
;
import
module
namespace
t2htextt
=
"http://ahikar.sub.uni-goettingen.de/ns/tei2html-textprocessing-tests"
at
"../tests/tei2html-textprocessing-tests.xqm"
;
import
module
namespace
ttt
=
"http://ahikar.sub.uni-goettingen.de/ns/tapi/txt/tests"
at
"../tests/tapi-txt-tests.xqm"
;
import
module
namespace
tct
=
"http://ahikar.sub.uni-goettingen.de/ns/tapi/collection/tests"
at
"../tests/tapi-collection-tests.xqm"
;
import
module
namespace
thtmlt
=
"http://ahikar.sub.uni-goettingen.de/ns/tapi/html/tests"
at
"../tests/tapi-html-tests.xqm"
;
import
module
namespace
titemt
=
"http://ahikar.sub.uni-goettingen.de/ns/tapi/item/tests"
at
"../tests/tapi-item-tests.xqm"
;
import
module
namespace
tmt
=
"http://ahikar.sub.uni-goettingen.de/ns/tapi/manifest/tests"
at
"../tests/tapi-manifest-tests.xqm"
;
import
module
namespace
tt
=
"http://ahikar.sub.uni-goettingen.de/ns/tapi/tests"
at
"../tests/tapi-tests.xqm"
;
import
module
namespace
thtmlt
=
"http://ahikar.sub.uni-goettingen.de/ns/tapi/html/tests"
at
"tapi-html-tests.xqm"
;
import
module
namespace
titemt
=
"http://ahikar.sub.uni-goettingen.de/ns/tapi/item/tests"
at
"tapi-item-tests.xqm"
;
import
module
namespace
tmt
=
"http://ahikar.sub.uni-goettingen.de/ns/tapi/manifest/tests"
at
"tapi-manifest-tests.xqm"
;
import
module
namespace
tt
=
"http://ahikar.sub.uni-goettingen.de/ns/tapi/tests"
at
"tapi-tests.xqm"
;
import
module
namespace
t2ht
=
"http://ahikar.sub.uni-goettingen.de/ns/tei2html-tests"
at
"tei2html-tests.xqm"
;
import
module
namespace
t2htextt
=
"http://ahikar.sub.uni-goettingen.de/ns/tei2html-textprocessing-tests"
at
"tei2html-textprocessing-tests.xqm"
;
import
module
namespace
at
=
"http://ahikar.sub.uni-goettingen.de/ns/annotations/tests"
at
"../tests/annotation-tests.xqm"
;
(:~
: Triggers the tests for the Ahikar backend. Called by the CI.
:
: @param $token A CI token
: @return item() A log message to std out. In the Docker environment, this goes to exist.log.
: @error The deploy token provided is incorrect
:)
declare
%rest:GET
%rest:HEAD
%rest:path
(
"/trigger-tests"
)
%rest:query-param
(
"token"
,
"{$token}"
)
function
testtrigger:trigger
(
$token
)
as
item
()
?
{
if
(
$token
ne
environment-variable
(
"APP_DEPLOY_TOKEN"
))
then
error
(
QName
(
"error://1"
,
"deploy"
)
,
"Deploy token incorrect."
)
else
let
$sysout
:=
util:log-system-out
(
"TextAPI and package installation done. running tests…"
)
let
$tests
:=
(
test:suite
(
util:list-functions
(
"http://ahikar.sub.uni-goettingen.de/ns/tapi/tests"
))
,
test:suite
(
util:list-functions
(
"http://ahikar.sub.uni-goettingen.de/ns/commons-tests"
))
,
test:suite
(
util:list-functions
(
"http://ahikar.sub.uni-goettingen.de/ns/tapi/collection/tests"
))
,
test:suite
(
util:list-functions
(
"http://ahikar.sub.uni-goettingen.de/ns/tei2html-tests"
))
,
test:suite
(
util:list-functions
(
"http://ahikar.sub.uni-goettingen.de/ns/tei2html-textprocessing-tests"
))
,
test:suite
(
util:list-functions
(
"http://ahikar.sub.uni-goettingen.de/ns/tapi/txt/tests"
))
,
test:suite
(
util:list-functions
(
"http://ahikar.sub.uni-goettingen.de/ns/tapi/manifest/tests"
))
,
test:suite
(
util:list-functions
(
"http://ahikar.sub.uni-goettingen.de/ns/tapi/item/tests"
))
,
test:suite
(
util:list-functions
(
"http://ahikar.sub.uni-goettingen.de/ns/tapi/html/tests"
))
,
test:suite
(
util:list-functions
(
"http://ahikar.sub.uni-goettingen.de/ns/annotations/tests"
))
)
let
$fileSeparator
:=
util:system-property
(
"file.separator"
)
let
$system-path
:=
system:get-exist-home
()
||
$fileSeparator
let
$testWrap
:=
<tests
time=
"
{
current-dateTime
()}
"
>
{
$tests
}
</tests>
let
$filename
:=
$system-path
||
"ahikar-test-results.xml"
let
$file
:=
file:serialize
(
$testWrap
,
$filename
,
())
return
util:log-system-out
(
"Tests complete. See "
||
$filename
)
};
\ No newline at end of file
declare
function
local:get-human-readable-pkg-name
(
$package
as
xs:string
)
as
xs:string
?
{
switch
(
$package
)
case
"http://ahikar.sub.uni-goettingen.de/ns/tapi/tests"
return
"TextAPI general"
case
"http://ahikar.sub.uni-goettingen.de/ns/tapi/txt/tests"
return
"TXT creation"
case
"http://ahikar.sub.uni-goettingen.de/ns/commons-tests"
return
"Commons"
case
"http://ahikar.sub.uni-goettingen.de/ns/tapi/collection/tests"
return
"TextAPI Collections"
case
"http://ahikar.sub.uni-goettingen.de/ns/tapi/manifest/tests"
return
"TextAPI Manifests"
case
"http://ahikar.sub.uni-goettingen.de/ns/tapi/item/tests"
return
"TextAPI Items"
case
"http://ahikar.sub.uni-goettingen.de/ns/tapi/html/tests"
return
"HTML creation"
case
"http://ahikar.sub.uni-goettingen.de/ns/tei2html-tests"
return
"TEI2HTML transformation"
case
"http://ahikar.sub.uni-goettingen.de/ns/tei2html-textprocessing-tests"
return
"TEI2HTML text processing"
case
"http://ahikar.sub.uni-goettingen.de/ns/annotations/tests"
return
"AnnotationAPI"
default
return
()
};
let
$test-results
:=
(
test:suite
(
util:list-functions
(
"http://ahikar.sub.uni-goettingen.de/ns/tapi/tests"
))
,
test:suite
(
util:list-functions
(
"http://ahikar.sub.uni-goettingen.de/ns/tapi/txt/tests"
))
,
test:suite
(
util:list-functions
(
"http://ahikar.sub.uni-goettingen.de/ns/commons-tests"
))
,
test:suite
(
util:list-functions
(
"http://ahikar.sub.uni-goettingen.de/ns/tapi/collection/tests"
))
,
test:suite
(
util:list-functions
(
"http://ahikar.sub.uni-goettingen.de/ns/tapi/manifest/tests"
))
,
test:suite
(
util:list-functions
(
"http://ahikar.sub.uni-goettingen.de/ns/tapi/item/tests"
))
,
test:suite
(
util:list-functions
(
"http://ahikar.sub.uni-goettingen.de/ns/tapi/html/tests"
))
,
test:suite
(
util:list-functions
(
"http://ahikar.sub.uni-goettingen.de/ns/tei2html-tests"
))
,
test:suite
(
util:list-functions
(
"http://ahikar.sub.uni-goettingen.de/ns/tei2html-textprocessing-tests"
))
,
test:suite
(
util:list-functions
(
"http://ahikar.sub.uni-goettingen.de/ns/annotations/tests"
))
)
for
$result
in
$test-results
order
by
$result
//
@package
return
if
(
$result
//
@failures
=
0
and
$result
//
@errors
=
0
)
then
<OK
name=
"
{
local:get-human-readable-pkg-name
(
$result
//
@package
)}
"
package=
"
{
$result
//
@package
}
"
/>
else
$result
\ No newline at end of file
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