@@ -13,8 +13,11 @@ defmodule Mix.Tasks.RunTest do
13
13
end
14
14
end
15
15
16
- test "run requires files before evaling commands" do
16
+ setup do
17
17
Mix.Project . push MixTest.Case.Sample
18
+ end
19
+
20
+ test "run requires files before evaling commands" do
18
21
git_repo = fixture_path ( "git_repo/lib/git_repo.ex" )
19
22
20
23
in_fixture "no_mixfile" , fn ->
@@ -27,4 +30,33 @@ defmodule Mix.Tasks.RunTest do
27
30
after
28
31
purge [ GitRepo ]
29
32
end
33
+
34
+ test "run rewrites System.argv" do
35
+ in_fixture "no_mixfile" , fn ->
36
+ File . write! file = "argv.exs" , "send self, {:system_argv, System.argv}"
37
+ unload_file = fn ->
38
+ Code . unload_files [ Path . expand ( file ) ]
39
+ end
40
+
41
+ Mix.Tasks.Run . run [ file ]
42
+ assert_received { :system_argv , [ ] }
43
+
44
+ unload_file . ( )
45
+ Mix.Tasks.Run . run [ file , "foo" , "-e" , "bar" ]
46
+ assert_received { :system_argv , [ "foo" , "-e" , "bar" ] }
47
+
48
+ unload_file . ( )
49
+ Mix.Tasks.Run . run [ "-e" , "send self, {:system_argv, System.argv}" , file , "foo" , "-x" , "bar" ]
50
+ assert_received { :system_argv , [ file , "foo" , "-x" , "bar" ] }
51
+
52
+ unload_file . ( )
53
+ Mix.Tasks.Run . run [
54
+ "-e" , "send self, :evaled" ,
55
+ "-e" , "send self, {:system_argv, System.argv}" ,
56
+ "--no-compile" , file , "-x" , "bar"
57
+ ]
58
+ assert_received :evaled
59
+ assert_received { :system_argv , [ file , "-x" , "bar" ] }
60
+ end
61
+ end
30
62
end
0 commit comments