From 80c65131e09d5e0784b910ca23573f129ffc8de6 Mon Sep 17 00:00:00 2001 From: jakeprem Date: Wed, 25 Sep 2019 11:20:41 -0400 Subject: [PATCH 1/4] Add Divo.Case A module for use in testing that automatically includes ExUnit.case --- lib/divo/case.ex | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 lib/divo/case.ex diff --git a/lib/divo/case.ex b/lib/divo/case.ex new file mode 100644 index 0000000..a3a9f30 --- /dev/null +++ b/lib/divo/case.ex @@ -0,0 +1,8 @@ +defmodule Divo.Case do + defmacro __using__(opts \\ []) do + quote do + use ExUnit.Case + use Divo, opts + end + end +end From 866e1672e270c67671710ba1c50d4d1bce7f3ee7 Mon Sep 17 00:00:00 2001 From: jakeprem Date: Wed, 25 Sep 2019 11:23:56 -0400 Subject: [PATCH 2/4] Unquote opts Fix a bug where opts would still be quoted --- lib/divo/case.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/divo/case.ex b/lib/divo/case.ex index a3a9f30..793c282 100644 --- a/lib/divo/case.ex +++ b/lib/divo/case.ex @@ -2,7 +2,7 @@ defmodule Divo.Case do defmacro __using__(opts \\ []) do quote do use ExUnit.Case - use Divo, opts + use Divo, unquote(opts) end end end From 52556be05cef8f0ff56794dd7ff08229d6ca660f Mon Sep 17 00:00:00 2001 From: Jake Prem Date: Wed, 25 Sep 2019 11:31:01 -0400 Subject: [PATCH 3/4] Add moduledoc to Divo.Case and add a test --- lib/divo/case.ex | 5 +++++ test/integration_test.exs | 3 +-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/divo/case.ex b/lib/divo/case.ex index 793c282..9aec283 100644 --- a/lib/divo/case.ex +++ b/lib/divo/case.ex @@ -1,4 +1,9 @@ defmodule Divo.Case do + @moduledoc """ + Can be used in place of Divo to also include ExUnit.Case. + Opts will still be passed to Divo as normal. + """ + defmacro __using__(opts \\ []) do quote do use ExUnit.Case diff --git a/test/integration_test.exs b/test/integration_test.exs index 73bf6a4..e3f2664 100644 --- a/test/integration_test.exs +++ b/test/integration_test.exs @@ -1,6 +1,5 @@ defmodule IntegrationAllTest do - use ExUnit.Case - use Divo + use Divo.Case test "the full dependency stack is stood up" do {containers, _} = System.cmd("docker", ["ps", "-a"], stderr_to_stdout: true) From c11a53ad135afc51d06094e09ad46a359cd02d97 Mon Sep 17 00:00:00 2001 From: Jake Prem Date: Wed, 25 Sep 2019 14:14:15 -0400 Subject: [PATCH 4/4] Add support for passing async flag to ExUnit.Case --- lib/divo/case.ex | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/divo/case.ex b/lib/divo/case.ex index 9aec283..11a19f2 100644 --- a/lib/divo/case.ex +++ b/lib/divo/case.ex @@ -1,12 +1,15 @@ defmodule Divo.Case do @moduledoc """ Can be used in place of Divo to also include ExUnit.Case. - Opts will still be passed to Divo as normal. + Opts will still be passed to Divo as normal, and the async + opt will be passed only to ExUnit.Case. """ defmacro __using__(opts \\ []) do + {async, opts} = Keyword.pop(opts, :async, false) + quote do - use ExUnit.Case + use ExUnit.Case, async: unquote(async) use Divo, unquote(opts) end end