From eff647e9001b0ed76eff5a3ccf5a9099414730a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Wed, 7 Sep 2022 16:19:49 +0200 Subject: [PATCH] Do not crash when moduledoc and other functions are listed in only, closes #12120 --- lib/ex_unit/lib/ex_unit/doc_test.ex | 2 +- lib/ex_unit/test/ex_unit/doc_test_test.exs | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/ex_unit/lib/ex_unit/doc_test.ex b/lib/ex_unit/lib/ex_unit/doc_test.ex index 90d3755aaa8..83d900245da 100644 --- a/lib/ex_unit/lib/ex_unit/doc_test.ex +++ b/lib/ex_unit/lib/ex_unit/doc_test.ex @@ -264,7 +264,7 @@ defmodule ExUnit.DocTest do {tests, fun_arities} -> {[test | tests], [test.fun_arity | fun_arities]} end - case only -- fun_arities do + case only -- [:moduledoc | fun_arities] do [] -> filtered_tests diff --git a/lib/ex_unit/test/ex_unit/doc_test_test.exs b/lib/ex_unit/test/ex_unit/doc_test_test.exs index 9e7faf47483..704bca7d7b6 100644 --- a/lib/ex_unit/test/ex_unit/doc_test_test.exs +++ b/lib/ex_unit/test/ex_unit/doc_test_test.exs @@ -462,7 +462,10 @@ defmodule ExUnit.DocTestTest do # doctest ExUnit.DocTest doctest ExUnit.DocTestTest.GoodModule, import: true - doctest ExUnit.DocTestTest.SomewhatGoodModuleWithOnly, only: [one: 0], import: true + + doctest ExUnit.DocTestTest.SomewhatGoodModuleWithOnly, + only: [:moduledoc, one: 0], + import: true doctest ExUnit.DocTestTest.SomewhatGoodModuleWithExcept, except: [:moduledoc, two: 0],