defmodule Mix.Tasks.Ct do use Mix.Task @shortdoc "Run ejabberd Common Test suite" def run(_args) do Mix.env :test # TODO: Support passing compile options through ct task Mix.Task.run "compile" # This is run independently, so that the test modules don't end up in the # .app file # ebin_dir = Path.join([Mix.Project.app_path, "test"]) # MixErlangTasks.Util.compile_files(Path.wildcard("test/**/*_SUITE.erl"), ebin_dir) logdir = "logs" File.mkdir_p!(logdir) :ok = System.put_env("CT_BACKEND", "mnesia,no_db") IO.inspect(:code.get_path()) # depdir = Mix.Project.deps_paths() depdir = "_build/test/lib/" {:ok, dirs} = File.ls(depdir) # dirs |> Enum.each(fn(dir) -> Code.append_path(depdir <> dir <> "/ebin") end) includes = dirs |> Enum.map(fn(dir) -> String.to_charlist(depdir <> dir <> "/include") end) :ct.run_test([ {:dir, ['test']}, {:logdir, String.to_charlist(logdir)}, {:auto_compile, false}, {:include, includes ++ ['include']}, {:suite, ['ejabberd_SUITE']}, {:ct_hooks, :cth_surefire}, {:cover, 'cover.spec'} ]) end end