This repository has been archived by the owner on Jul 1, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Unit Testing.dscript
85 lines (75 loc) · 2.3 KB
/
Unit Testing.dscript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
## Set current prefix for output keys
Unit Test Set Prefix:
type: task
speed: 0
definitions: prefix
debug: false
script:
- flag global "Unit Test Prefix:%prefix%."
## Write output values
Unit Test Write Output:
type: task
speed: 0
definitions: key|value
debug: false
script:
- yaml "write:<server.flag[Unit Test Section]>.<server.flag[Unit Test Prefix]>%key%" "value:%value%" "id:Unit Test Yaml"
## Create output Yaml object
Unit Test Create Output:
type: task
speed: 0
definitions: test_section
debug: false
script:
- flag global "Unit Test Section:%test_section%"
- flag global "Unit Test Prefix:"
## Save output to Yaml file
Unit Test Save Output:
type: task
speed: 0
script:
- flag global "Unit Test Section:_stats"
- flag global "Unit Test Prefix:"
- run "s@Unit Test Write Output" "def:Last Ran|<util.date> at <util.date.time>"
- run "s@Unit Test Write Output" "def:Denizen Version|<server.denizen_version>"
- run "s@Unit Test Write Output" "def:Server Version|<server.version>"
- yaml savefile:UnitTest.yml "id:Unit Test Yaml"
- yaml unload "id:Unit Test Yaml"
Unit Test Handler:
type: world
speed: 0
events:
on unittest command:
- if !<context.server> {
- if !<player.is_op> {
- narrate "<&c>Only an operator or the server may do this command."
- determine fulfilled
}
}
- narrate 'Starting unit tests.'
- yaml create "id:Unit Test Yaml"
- flag server ut_counter:0
- run locally 'do tests'
- determine fulfilled
do tests:
- ^if <server.flag[unit_tasks].as_list.size> <= <server.flag[ut_counter]>
&& <queue.exists[test_queue]> == false {
- ^inject 's@unit test save output'
- ^narrate 'Finished unit tests.'
- ^queue clear
}
- ^if <queue.exists[test_queue]> {
- narrate "Error<&co> test_queue already exists! Cannot complete!"
- queue clear
}
- ^if <player||null> == null {
- define player <server.list_players.get[1]>
}
else {
- define player <player>
}
- ^flag server ut_counter:++
- ^narrate 'Running test -> <server.flag[unit_tasks].as_list.get[<server.flag[ut_counter].as_int>]>'
- ~run <server.flag[unit_tasks].as_list.get[<server.flag[ut_counter].as_int>]> id:test_queue as:%player%
- ^wait 10t
- ^inject locally 'do tests'