]> gitweb.factorcode.org Git - factor.git/blob - basis/io/launcher/windows/nt/nt-tests.factor
Fixing assorted compile errors and help lint warnings
[factor.git] / basis / io / launcher / windows / nt / nt-tests.factor
1 USING: io.launcher tools.test calendar accessors environment
2 namespaces kernel system arrays io io.files io.encodings.ascii
3 sequences parser assocs hashtables math continuations eval
4 io.files.temp io.directories io.pathnames ;
5 IN: io.launcher.windows.nt.tests
6
7 [ ] [
8     <process>
9         "notepad" >>command
10         1/2 seconds >>timeout
11     "notepad" set
12 ] unit-test
13
14 [ f ] [ "notepad" get process-running? ] unit-test
15
16 [ f ] [ "notepad" get process-started? ] unit-test
17
18 [ ] [ "notepad" [ run-detached ] change ] unit-test
19
20 [ "notepad" get wait-for-process ] must-fail
21
22 [ t ] [ "notepad" get killed>> ] unit-test
23
24 [ f ] [ "notepad" get process-running? ] unit-test
25
26 [ ] [
27     <process>
28         vm "-quiet" "-run=hello-world" 3array >>command
29         "out.txt" temp-file >>stdout
30     try-process
31 ] unit-test
32
33 [ "Hello world" ] [
34     "out.txt" temp-file ascii file-lines first
35 ] unit-test
36
37 [ ] [
38     <process>
39         vm "-run=listener" 2array >>command
40         +closed+ >>stdin
41     try-process
42 ] unit-test
43
44 [ ] [
45     "resource:basis/io/windows/nt/launcher/test" [
46         <process>
47             vm "-script" "stderr.factor" 3array >>command
48             "out.txt" temp-file >>stdout
49             "err.txt" temp-file >>stderr
50         try-process
51     ] with-directory
52 ] unit-test
53
54 [ "output" ] [
55     "out.txt" temp-file ascii file-lines first
56 ] unit-test
57
58 [ "error" ] [
59     "err.txt" temp-file ascii file-lines first
60 ] unit-test
61
62 [ ] [
63     "resource:basis/io/windows/nt/launcher/test" [
64         <process>
65             vm "-script" "stderr.factor" 3array >>command
66             "out.txt" temp-file >>stdout
67             +stdout+ >>stderr
68         try-process
69     ] with-directory
70 ] unit-test
71
72 [ "outputerror" ] [
73     "out.txt" temp-file ascii file-lines first
74 ] unit-test
75
76 [ "output" ] [
77     "resource:basis/io/windows/nt/launcher/test" [
78         <process>
79             vm "-script" "stderr.factor" 3array >>command
80             "err2.txt" temp-file >>stderr
81         ascii <process-reader> lines first
82     ] with-directory
83 ] unit-test
84
85 [ "error" ] [
86     "err2.txt" temp-file ascii file-lines first
87 ] unit-test
88
89 [ t ] [
90     "resource:basis/io/windows/nt/launcher/test" [
91         <process>
92             vm "-script" "env.factor" 3array >>command
93         ascii <process-reader> contents
94     ] with-directory eval
95
96     os-envs =
97 ] unit-test
98
99 [ t ] [
100     "resource:basis/io/windows/nt/launcher/test" [
101         <process>
102             vm "-script" "env.factor" 3array >>command
103             +replace-environment+ >>environment-mode
104             os-envs >>environment
105         ascii <process-reader> contents
106     ] with-directory eval
107     
108     os-envs =
109 ] unit-test
110
111 [ "B" ] [
112     "resource:basis/io/windows/nt/launcher/test" [
113         <process>
114             vm "-script" "env.factor" 3array >>command
115             { { "A" "B" } } >>environment
116         ascii <process-reader> contents
117     ] with-directory eval
118
119     "A" swap at
120 ] unit-test
121
122 [ f ] [
123     "resource:basis/io/windows/nt/launcher/test" [
124         <process>
125             vm "-script" "env.factor" 3array >>command
126             { { "USERPROFILE" "XXX" } } >>environment
127             +prepend-environment+ >>environment-mode
128         ascii <process-reader> contents
129     ] with-directory eval
130
131     "USERPROFILE" swap at "XXX" =
132 ] unit-test
133
134 2 [
135     [ ] [
136         <process>
137             "cmd.exe /c dir" >>command
138             "dir.txt" temp-file >>stdout
139         try-process
140     ] unit-test
141
142     [ ] [ "dir.txt" temp-file delete-file ] unit-test
143 ] times
144
145 [ "append-test" temp-file delete-file ] ignore-errors
146
147 [ "Hello appender\r\nHello appender\r\n" ] [
148     2 [
149         "resource:basis/io/windows/nt/launcher/test" [
150             <process>
151                 vm "-script" "append.factor" 3array >>command
152                 "append-test" temp-file <appender> >>stdout
153             try-process
154         ] with-directory
155     ] times
156    
157     "append-test" temp-file ascii file-contents
158 ] unit-test