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