]> gitweb.factorcode.org Git - factor.git/blob - basis/io/unix/launcher/launcher-tests.factor
33988c273bc871d124de968898b92b5f515b9821
[factor.git] / basis / 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.binary io.encodings.ascii
4 accessors kernel sequences io.encodings.utf8 destructors
5 io.streams.duplex ;
6
7 [ ] [
8     [ "launcher-test-1" temp-file delete-file ] ignore-errors
9 ] unit-test
10
11 [ ] [
12     "touch"
13     "launcher-test-1" temp-file
14     2array
15     try-process
16 ] unit-test
17
18 [ t ] [ "launcher-test-1" temp-file exists? ] unit-test
19
20 [ ] [
21     [ "launcher-test-1" temp-file delete-file ] ignore-errors
22 ] unit-test
23
24 [ ] [
25     <process>
26         "echo Hello" >>command
27         "launcher-test-1" temp-file >>stdout
28     try-process
29 ] unit-test
30
31 [ "Hello\n" ] [
32     "cat"
33     "launcher-test-1" temp-file
34     2array
35     ascii <process-reader> contents
36 ] unit-test
37
38 [ ] [
39     [ "launcher-test-1" temp-file delete-file ] ignore-errors
40 ] unit-test
41
42 [ ] [
43     <process>
44         "cat" >>command
45         +closed+ >>stdin
46         "launcher-test-1" temp-file >>stdout
47     try-process
48 ] unit-test
49
50 [ f ] [
51     "cat"
52     "launcher-test-1" temp-file
53     2array
54     ascii <process-reader> contents
55 ] unit-test
56
57 [ ] [
58     2 [
59         "launcher-test-1" temp-file binary <file-appender> [
60             <process>
61                 swap >>stdout
62                 "echo Hello" >>command
63             try-process
64         ] with-disposal
65     ] times
66 ] unit-test
67
68 [ "Hello\nHello\n" ] [
69     "cat"
70     "launcher-test-1" temp-file
71     2array
72     ascii <process-reader> contents
73 ] unit-test
74
75 [ t ] [
76     <process>
77         "env" >>command
78         { { "A" "B" } } >>environment
79     ascii <process-reader> lines
80     "A=B" swap member?
81 ] unit-test
82
83 [ { "A=B" } ] [
84     <process>
85         "env" >>command
86         { { "A" "B" } } >>environment
87         +replace-environment+ >>environment-mode
88     ascii <process-reader> lines
89 ] unit-test
90
91 [ "hi\n" ] [
92     temp-directory [
93         [ "aloha" delete-file ] ignore-errors
94         <process>
95             { "echo" "hi" } >>command
96             "aloha" >>stdout
97         try-process
98     ] with-directory
99     temp-directory "aloha" append-path
100     utf8 file-contents
101 ] unit-test
102
103 [ "append-test" temp-file delete-file ] ignore-errors
104
105 [ "hi\nhi\n" ] [
106     2 [
107         <process>
108             "echo hi" >>command
109             "append-test" temp-file <appender> >>stdout
110         try-process
111     ] times
112     "append-test" temp-file utf8 file-contents
113 ] unit-test
114
115 [ t ] [ "ls" utf8 <process-stream> contents >boolean ] unit-test
116
117 [ "Hello world.\n" ] [
118     "cat" utf8 <process-stream> [
119         "Hello world.\n" write
120         output-stream get dispose
121         input-stream get contents
122     ] with-stream
123 ] unit-test