Skip to content

Commit f6093d4

Browse files
author
José Valim
committed
Tag all doctest tests
1 parent 1dd034d commit f6093d4

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
* Enhancements
66
* [ExUnit] Print process mailbox on failing `assert_receive`
7+
* [ExUnit] Tag all doctests with the `:doctest` tag
78
* [Mix] `mix deps.unlock` warns when given missing dependency
89
* [Kernel] Friendlier `unquote_splicing` error on inline quote
910

lib/ex_unit/lib/ex_unit/doc_test.ex

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ defmodule ExUnit.DocTest do
152152
tests = quote bind_quoted: binding do
153153
file = "(for doctest at) " <> Path.relative_to_cwd(mod.__info__(:compile)[:source])
154154
for {name, test} <- ExUnit.DocTest.__doctests__(mod, opts) do
155+
@tag :doctest
155156
@file file
156157
test name, do: unquote(test)
157158
end
@@ -348,9 +349,9 @@ defmodule ExUnit.DocTest do
348349

349350
moduledocs = extract_from_moduledoc(all_docs[:moduledoc])
350351

351-
docs = for doc <- all_docs[:docs] do
352-
extract_from_doc(doc)
353-
end |> Enum.concat
352+
docs = for doc <- all_docs[:docs],
353+
doc <- extract_from_doc(doc),
354+
do: doc
354355

355356
moduledocs ++ docs
356357
end

lib/ex_unit/test/ex_unit/doc_test_test.exs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,20 @@ defmodule ExUnit.DocTestTest do
264264
"""
265265
end
266266

267+
test "tags tests as doctests" do
268+
defmodule DoctestTag do
269+
use ExUnit.Case
270+
doctest ExUnit.DocTestTest.NoImport
271+
272+
setup test do
273+
assert test.doctest
274+
:ok
275+
end
276+
end
277+
278+
assert capture_io(fn -> ExUnit.run end) =~ "1 tests, 0 failures"
279+
end
280+
267281
test "multiple exceptions in one test case is not supported" do
268282
assert_raise ExUnit.DocTest.Error, ~r"multiple exceptions in one doctest case are not supported", fn ->
269283
defmodule NeverCompiled do

0 commit comments

Comments
 (0)