Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
clean-platform
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
17
Issues
17
List
Boards
Labels
Service Desk
Milestones
Merge Requests
3
Merge Requests
3
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
clean-and-itasks
clean-platform
Commits
10c417b3
Verified
Commit
10c417b3
authored
Aug 10, 2019
by
Camil Staps
🚀
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Testing.TestEvents: change module_name to more easily extensible TestLocation
parent
60386dc5
Pipeline
#27900
failed with stage
in 2 minutes and 15 seconds
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
15 deletions
+28
-15
src/libraries/OS-Independent/Testing/TestEvents.dcl
src/libraries/OS-Independent/Testing/TestEvents.dcl
+14
-6
src/libraries/OS-Independent/Testing/TestEvents.icl
src/libraries/OS-Independent/Testing/TestEvents.icl
+14
-9
No files found.
src/libraries/OS-Independent/Testing/TestEvents.dcl
View file @
10c417b3
...
...
@@ -19,19 +19,27 @@ from Text.GenJSON import generic JSONEncode, generic JSONDecode, :: JSONNode, ::
=
StartEvent
StartEvent
//* A test has started
|
EndEvent
EndEvent
//* A test has finished
/**
* The location of a test in a source file.
* This is not complete; more fields can be added as necessary.
*/
::
TestLocation
=
{
moduleName
::
!
Maybe
String
//* The module the test is defined in
}
/**
* Event emitted when a test is started.
* Specialised JSONEncode/JSONDecode instances are used for this type, which
* have to be adapted in case the type definition is changed!
*/
::
StartEvent
=
{
name
::
!
String
//* The test's name
,
module_name
::
!
Maybe
String
//* The module to which the test belongs
,
location
::
!
Maybe
TestLocation
//* The test's location
}
/**
* Event emitted after a test has finished.
*/
::
EndEvent
=
{
name
::
!
String
//* The test's name
,
module_name
::
!
Maybe
String
//* The module to which the test belongs
,
location
::
!
Maybe
TestLocation
//* The test's location
,
event
::
!
EndEventType
//* The event's type, indicating success
,
message
::
!
String
//* Message providing an explanation for the result
}
...
...
src/libraries/OS-Independent/Testing/TestEvents.icl
View file @
10c417b3
implementation
module
Testing
.
TestEvents
import
Text
.
GenJSON
,
Control
.
Monad
,
StdFunctions
,
StdTuple
,
StdList
,
Data
.
Maybe
,
Control
.
Applicative
,
Data
.
Func
import
StdEnv
import
Text
.
GenJSON
,
Control
.
Monad
,
Data
.
Maybe
,
Control
.
Applicative
,
Data
.
Func
import
Data
.
Functor
import
Data
.
List
...
...
@@ -16,9 +17,11 @@ JSONDecode{|TestEvent|} b json = case JSONDecode{|*|} b json of
JSONEncode
{|
StartEvent
|}
_
startEvent
=
[
JSONObject
[
(
"name"
,
JSONString
startEvent
.
StartEvent
.
name
)
,
(
"event"
,
JSONString
"start"
)
:
case
startEvent
.
StartEvent
.
module_name
of
:
case
startEvent
.
StartEvent
.
location
of
Nothing
->
[]
Just
m
->
[(
"module"
,
JSONString
m
)]
Just
l
->
case
JSONEncode
{|*|}
True
l
of
[
json
]
->
[(
"location"
,
json
)]
_
->
abort
"error in JSONEncode_StartEvent
\n
"
]]
JSONDecode
{|
StartEvent
|}
_
[
JSONObject
objFields
:
rest
]
=
(
mbEvent
,
rest
)
...
...
@@ -27,7 +30,7 @@ where
mbEvent
=
getField
"name"
>>=
\
name
->
getField
"event"
>>=
\
event
->
if
(
event
==
"start"
)
(
pure
{
StartEvent
|
name
=
name
,
module_name
=
getField
"module
"
})
(
pure
{
StartEvent
|
name
=
name
,
location
=
getField
"location
"
})
mzero
getField
::
String
->
Maybe
a
|
JSONDecode
{|*|}
a
...
...
@@ -38,9 +41,11 @@ JSONEncode{|EndEvent|} _ endEvent = [JSONObject
[
(
"name"
,
JSONString
endEvent
.
EndEvent
.
name
)
,
(
"message"
,
JSONString
endEvent
.
message
)
,
(
"event"
,
JSONString
(
typeToString
endEvent
.
event
))
:
case
endEvent
.
EndEvent
.
module_name
of
:
case
endEvent
.
EndEvent
.
location
of
Nothing
->
[]
Just
m
->
[(
"module"
,
JSONString
m
)]
Just
l
->
case
JSONEncode
{|*|}
True
l
of
[
json
]
->
[(
"location"
,
json
)]
_
->
abort
"error in JSONEncode_EndEvent
\n
"
++
case
endEvent
.
event
of
Failed
(
Just
r
)
->
[(
"failReason"
,
case
JSONEncode
{|*|}
False
r
of
[
JSONArray
r
]
->
JSONArray
r
...
...
@@ -60,7 +65,7 @@ where
getField
"name"
>>=
\
name
->
getField
"event"
>>=
\
event
->
getField
"message"
>>=
\
message
->
let
e
=
{
name
=
name
,
message
=
message
,
event
=
Passed
,
module_name
=
getField
"module
"
}
in
case
event
of
let
e
=
{
name
=
name
,
message
=
message
,
event
=
Passed
,
location
=
getField
"location
"
}
in
case
event
of
"passed"
->
pure
e
"failed"
->
pure
{
e
&
event
=
Failed
$
getField
"failReason"
}
"skipped"
->
pure
{
e
&
event
=
Skipped
}
...
...
@@ -135,5 +140,5 @@ where
f
->
Just
(
Other
f
)
JSONDecode
{|
Relation
|}
_
_
=
(
Nothing
,
[])
derive
JSONEncode
FailReason
,
CounterExample
derive
JSONDecode
FailReason
,
CounterExample
derive
JSONEncode
TestLocation
,
FailReason
,
CounterExample
derive
JSONDecode
TestLocation
,
FailReason
,
CounterExample
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment