-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun.apls
74 lines (59 loc) · 2.03 KB
/
run.apls
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
#!/usr/local/bin/dyalogscript
⍝ Full session start-up
⎕SE.(⍎⊃2⎕FIX'/StartupSession.aplf',⍨2⎕NQ#'GetEnvironment' 'DYALOG')
⍝ Load the code from the current directory
⎕SE.Link.Import # (⎕SE.Dyalog.Utils.CD '')
retry←{
fn←∇
11::{⎕←'→ ',⎕DMX.EM ⋄ fn ⍵}⍵
⍺⍺ ⍵⍵ ⍵
}
testnames←tests.⎕NL ¯9
⎕←'Available tests:'
⎕←'∘ ',⍤1⊢↑testnames
readName←{
⍵≡'all': testnames
(⊂⍵)∊testnames: ⊂⍵
('Invalid test name: ',⍵)⎕SIGNAL 11
}
askNames←{
⍞←'Choose tests to run, or hit ENTER to run all: '
in←¯1⎕C⍞ ⍝ lowercase stdin
in≡'':⊂'all'
' '(≠⊆⊢)in ⍝ split on spaces
}
choosen←⊃,⌿readName¨ retry askNames ⍬
⎕←'Tests choosen:'
⎕←'∘ ',⍤1⊢↑choosen
options ←⊂1 'prod' 'Production mode (0 or 1)'
options,←⊂0 'verbose' 'Verbose output (0 or 1)'
options,←⊂1 'reps' 'How many repetitions of the tests to run'
options,←⊂0 'randlink' 'Initial value of ⎕RL. 0 for random ⎕RL'
(optionValues optionNames optionDescriptions)←↓⍉↑options
readOption←{
''≡⍵:⍬ ⍝ done
(name val)←'='(≠⊆⊢)⍵
name←optionNames⍳⊂name
(valid val)←⎕VFI val
(1≠+⌿'='=⍵)∨(name>≢optionNames)∨(0∊valid): ('Invalid option update: ',⍵)⎕SIGNAL 11
(name⊃optionValues)←val
('Updated ',(name⊃optionNames),': ',⍕val)⎕SIGNAL 11
}
askOptions←{
⎕←'Change test options, or hit ENTER to use the current values.'
⎕←'Type ? for more information, or OPTION=NEWVAL to update.'
⎕←'Current options:'
_←optionNames{⎕←'∘ ',⍺,': ',⍕⍵ ⋄ 0}¨optionValues
{⍞}⍣{
⍺≢,'?': 1
⎕←↑optionNames{'∘ ',⍺,': ',⍵}¨optionDescriptions
0
}⍬
}
readOption retry askOptions ⍬
optionNames,←⊂'stop'
optionValues,←0
:For test :In choosen
⎕←'Running test: ',test
unittest.RunTests (⍎'tests.',test),optionValues[optionNames⍳'prod' 'verbose' 'stop' 'reps' 'randlink']
:EndFor