]> gitweb.factorcode.org Git - factor.git/blob - extra/io/unix/launcher/launcher-tests.factor
Fix io.unix.launcher unit test
[factor.git] / extra / io / unix / launcher / launcher-tests.factor
1 IN: io.unix.launcher.tests
2 USING: io.files tools.test io.launcher arrays io namespaces
3 continuations math io.encodings.ascii io.encodings.latin1
4 accessors kernel sequences ;
5
6 [ ] [
7     [ "launcher-test-1" temp-file delete-file ] ignore-errors
8 ] unit-test
9
10 [ ] [
11     "touch"
12     "launcher-test-1" temp-file
13     2array
14     try-process
15 ] unit-test
16
17 [ t ] [ "launcher-test-1" temp-file exists? ] unit-test
18
19 [ ] [
20     [ "launcher-test-1" temp-file delete-file ] ignore-errors
21 ] unit-test
22
23 [ ] [
24     <process>
25         "echo Hello" >>command
26         "launcher-test-1" temp-file >>stdout
27     try-process
28 ] unit-test
29
30 [ "Hello\n" ] [
31     "cat"
32     "launcher-test-1" temp-file
33     2array
34     ascii <process-stream> contents
35 ] unit-test
36
37 [ f ] [
38     <process>
39         "cat"
40         "launcher-test-1" temp-file
41         2array >>command
42         +inherit+ >>stdout
43     ascii <process-stream> contents
44 ] unit-test
45
46 [ ] [
47     [ "launcher-test-1" temp-file delete-file ] ignore-errors
48 ] unit-test
49
50 [ ] [
51     <process>
52         "cat" >>command
53         +closed+ >>stdin
54         "launcher-test-1" temp-file >>stdout
55     try-process
56 ] unit-test
57
58 [ f ] [
59     "cat"
60     "launcher-test-1" temp-file
61     2array
62     ascii <process-stream> contents
63 ] unit-test
64
65 [ ] [
66     2 [
67         "launcher-test-1" temp-file ascii <file-appender> [
68             <process>
69                 swap >>stdout
70                 "echo Hello" >>command
71             try-process
72         ] with-disposal
73     ] times
74 ] unit-test
75
76 [ "Hello\nHello\n" ] [
77     "cat"
78     "launcher-test-1" temp-file
79     2array
80     ascii <process-stream> contents
81 ] unit-test
82
83 [ t ] [
84     <process>
85         "env" >>command
86         { { "A" "B" } } >>environment
87     latin1 <process-stream> lines
88     "A=B" swap member?
89 ] unit-test
90
91 [ { "A=B" } ] [
92     <process>
93         "env" >>command
94         { { "A" "B" } } >>environment
95         +replace-environment+ >>environment-mode
96     latin1 <process-stream> lines
97 ] unit-test