@@ -5,7 +5,7 @@ import PathHelpers
55defmodule Kernel.CLI.InitTest do
66 use ExUnit.Case , async: true
77
8- test :code_init do
8+ test "handles code on initialization" do
99 assert elixir ( '-e "IO.puts [?3]"' ) == '3\n '
1010
1111 result = elixir ( '-e "IO.puts inspect(System.argv)" #{ fixture_path ( "init_sample.exs" ) } -o 1 2 3' )
1616defmodule Kernel.CLI.OptionParsingTest do
1717 use ExUnit.Case , async: true
1818
19- test :path do
19+ test "properly parses paths" do
2020 root = fixture_path ( "../../.." ) |> to_char_list
2121 list = elixir ( '-pa "#{ root } /*" -pz "#{ root } /lib/*" -e "IO.inspect(:code.get_path, limit: :infinity)"' )
2222 { path , _ } = Code . eval_string list , [ ]
3434defmodule Kernel.CLI.AtExitTest do
3535 use ExUnit.Case , async: true
3636
37- test : at_exit do
37+ test "invokes at_exit callbacks" do
3838 assert elixir ( fixture_path ( "at_exit.exs" ) |> to_char_list ) ==
3939 'goodbye cruel world with status 0\n '
4040 end
4343defmodule Kernel.CLI.ErrorTest do
4444 use ExUnit.Case , async: true
4545
46- test :code_error do
46+ test "properly format errors" do
4747 assert :string . str ( '** (throw) 1' , elixir ( '-e "throw 1"' ) ) == 0
4848 assert :string . str ( '** (ErlangError) erlang error: 1' , elixir ( '-e "error 1"' ) ) == 0
4949
@@ -52,32 +52,18 @@ defmodule Kernel.CLI.ErrorTest do
5252 end
5353end
5454
55- defmodule Kernel.CLI.SyntaxErrorTest do
56- use ExUnit.Case , async: true
57-
58- defp check_output ( elixir_cmd , expected_msg ) do
59- o = elixir ( elixir_cmd )
60- assert :string . str ( o , expected_msg ) == 1 , "Expected this output: `#{ expected_msg } `\n but got this output: `#{ o } `"
61- end
62-
63- test :syntax_code_error do
64- check_output ( '-e "[1,2"' , '** (TokenMissingError) nofile:1: missing terminator: ]' )
65- check_output ( '-e "case 1 end"' , % C "** (SyntaxError) nofile:1: unexpected token: end" )
66- end
67- end
68-
6955defmodule Kernel.CLI.CompileTest do
7056 use ExUnit.Case , async: true
7157
72- test :compile_code do
58+ test "compiles code" do
7359 fixture = fixture_path "compile_sample.ex"
7460 assert elixirc ( '#{ fixture } -o #{ tmp_path } ' ) == ''
7561 assert File . regular? ( tmp_path "Elixir.CompileSample.beam" )
7662 after
7763 File . rm ( tmp_path ( "Elixir.CompileSample.beam" ) )
7864 end
7965
80- test :compile_code_verbose do
66+ test "compiles code with verbose mode" do
8167 fixture = fixture_path "compile_sample.ex"
8268 assert elixirc ( '#{ fixture } -o #{ tmp_path } --verbose' ) ==
8369 'Compiled #{ fixture } \n '
@@ -86,16 +72,7 @@ defmodule Kernel.CLI.CompileTest do
8672 File . rm ( tmp_path ( "Elixir.CompileSample.beam" ) )
8773 end
8874
89- test :possible_deadlock do
90- output = elixirc ( '#{ fixture_path ( "parallel_deadlock" ) } -o #{ tmp_path } ' )
91- foo = '* #{ fixture_path "parallel_deadlock/foo.ex" } is missing module Bar'
92- bar = '* #{ fixture_path "parallel_deadlock/bar.ex" } is missing module Foo'
93- assert :string . str ( output , foo ) > 0 , "expected foo.ex to miss module Bar"
94- assert :string . str ( output , bar ) > 0 , "expected bar.ex to miss module Foo"
95- assert :string . str ( output , 'elixir_compiler' ) == 0 , "expected elixir_compiler to not be in output"
96- end
97-
98- test :compile_missing_patterns do
75+ test "fails on missing patterns" do
9976 fixture = fixture_path "compile_sample.ex"
10077 output = elixirc ( '#{ fixture } non_existing.ex -o #{ tmp_path } ' )
10178 assert :string . str ( output , 'non_existing.ex' ) > 0 , "expected non_existing.ex to be mentionned"
@@ -108,14 +85,36 @@ defmodule Kernel.CLI.ParallelCompilerTest do
10885 use ExUnit.Case
10986 import ExUnit.CaptureIO
11087
111- test : files do
88+ test "compiles files solving dependencies" do
11289 fixtures = [ fixture_path ( "parallel_compiler/bar.ex" ) , fixture_path ( "parallel_compiler/foo.ex" ) ]
11390 assert capture_io ( fn ->
11491 assert [ Bar , Foo ] = Kernel.ParallelCompiler . files fixtures
11592 end ) =~ "message_from_foo"
11693 end
11794
118- test :warnings_as_errors do
95+ test "does not hang on missing dependencies" do
96+ fixtures = [ fixture_path ( "parallel_compiler/bat.ex" ) ]
97+ assert capture_io ( fn ->
98+ assert_raise CompileError , fn ->
99+ Kernel.ParallelCompiler . files fixtures
100+ end
101+ end ) =~ "Compilation error"
102+ end
103+
104+ test "handles possible deadlocks" do
105+ fixtures = [ fixture_path ( "parallel_deadlock/foo.ex" ) , fixture_path ( "parallel_deadlock/bar.ex" ) ]
106+
107+ msg = capture_io ( fn ->
108+ assert_raise UndefinedFunctionError , fn ->
109+ Kernel.ParallelCompiler . files fixtures
110+ end
111+ end )
112+
113+ assert msg =~ "* #{ fixture_path "parallel_deadlock/foo.ex" } is missing module Bar"
114+ assert msg =~ "* #{ fixture_path "parallel_deadlock/bar.ex" } is missing module Foo"
115+ end
116+
117+ test "warnings_as_errors" do
119118 warnings_as_errors = Code . compiler_options [ :warnings_as_errors ]
120119
121120 try do
0 commit comments