@@ -430,6 +430,43 @@ defmodule MixTest do
430430 System . delete_env ( "MIX_INSTALL_RESTORE_PROJECT_DIR" )
431431 end
432432
433+ test "custom compilers" , % { tmp_dir: tmp_dir } do
434+ File . mkdir_p! ( "#{ tmp_dir } /install_test/lib/mix/tasks/compile/" )
435+
436+ File . write! ( "#{ tmp_dir } /install_test/lib/mix/tasks/compile/install_test.ex" , """
437+ defmodule Mix.Tasks.Compile.InstallTest do
438+ use Mix.Task.Compiler
439+
440+ def run(_args) do
441+ Mix.shell().info("Hello from custom compiler!")
442+
443+ :noop
444+ end
445+ end
446+ """ )
447+
448+ Mix . install (
449+ [
450+ { :install_test , path: Path . join ( tmp_dir , "install_test" ) }
451+ ] ,
452+ compilers: [ :elixir , :install_test ]
453+ )
454+
455+ assert File . dir? ( Path . join ( tmp_dir , "installs" ) )
456+
457+ assert Protocol . consolidated? ( InstallTest.Protocol )
458+
459+ assert_received { :mix_shell , :info , [ "==> install_test" ] }
460+ assert_received { :mix_shell , :info , [ "Compiling 3 files (.ex)" ] }
461+ assert_received { :mix_shell , :info , [ "Generated install_test app" ] }
462+ assert_received { :mix_shell , :info , [ "==> mix_install" ] }
463+ assert_received { :mix_shell , :info , [ "Hello from custom compiler!" ] }
464+ refute_received _
465+
466+ assert List . keyfind ( Application . started_applications ( ) , :install_test , 0 )
467+ assert apply ( InstallTest , :hello , [ ] ) == :world
468+ end
469+
433470 test "installed?" , % { tmp_dir: tmp_dir } do
434471 refute Mix . installed? ( )
435472
0 commit comments