@@ -73,6 +73,16 @@ defmodule SystemTest do
73
73
74
74
System . put_env ( % { @ test_var => "OTHER_SAMPLE" } )
75
75
assert System . get_env ( @ test_var ) == "OTHER_SAMPLE"
76
+
77
+ assert_raise ArgumentError , ~r[ cannot execute System.put_env/2 for key with \" =\" ] , fn ->
78
+ System . put_env ( "FOO=BAR" , "BAZ" )
79
+ end
80
+ end
81
+
82
+ test "cmd/2 raises for null bytes" do
83
+ assert_raise ArgumentError , ~r" cannot execute System.cmd/3 for program with null byte" , fn ->
84
+ System . cmd ( "null\0 byte" , [ ] )
85
+ end
76
86
end
77
87
78
88
if windows? ( ) do
@@ -107,19 +117,19 @@ defmodule SystemTest do
107
117
File . rm_rf! Path . dirname ( tmp_path ( @ echo ) )
108
118
end
109
119
else
110
- test "cmd/2 Unix " do
120
+ test "cmd/2 unix " do
111
121
assert { "hello\n " , 0 } = System . cmd "echo" , [ "hello" ]
112
122
end
113
123
114
- test "cmd/3 (with options) Unix " do
124
+ test "cmd/3 (with options) unix " do
115
125
assert { [ "hello\n " ] , 0 } = System . cmd "echo" , [ "hello" ] ,
116
126
into: [ ] , cd: System . cwd! , env: % { "foo" => "bar" , "baz" => nil } ,
117
127
arg0: "echo" , stderr_to_stdout: true , parallelism: true
118
128
end
119
129
120
130
@ echo "echo-elixir-test"
121
131
122
- test "cmd/2 with absolute and relative paths Unix " do
132
+ test "cmd/2 with absolute and relative paths ynix " do
123
133
echo = tmp_path ( @ echo )
124
134
File . mkdir_p! Path . dirname ( echo )
125
135
File . cp! System . find_executable ( "echo" ) , echo
@@ -143,6 +153,9 @@ defmodule SystemTest do
143
153
assert System . find_executable ( "erl" )
144
154
assert is_binary System . find_executable ( "erl" )
145
155
assert ! System . find_executable ( "does-not-really-exist-from-elixir" )
156
+ assert_raise ArgumentError , ~r" cannot execute System.find_executable/1 for program with null byte" , fn ->
157
+ System . find_executable ( "null\0 byte" )
158
+ end
146
159
end
147
160
148
161
test "monotonic_time/0" do
0 commit comments