Created
April 16, 2013 04:22
-
-
Save pragdave/5393324 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Mix.Tasks.Doctest do | |
use Mix.Task | |
@shortdoc "Run the doctests for one or more files" | |
# Just for testing.... | |
defmodule Wombat do | |
@moduledoc """ | |
iex> 1 | |
1 | |
iex> 2 | |
5 | |
""" | |
end | |
def run(args) do | |
# { opts, files } = OptionParser.parse(args) | |
:application.start(:elixir) | |
:application.start(:ex_unit) | |
test_methods = Enum.map ExUnit.DocTest.__doctests__(Wombat, []), fn { name, test } -> | |
{:def,[],[{name,[],[[do: [{:_,[],nil}]]]},[do: test]]} | |
end | |
body = [{:use,[],[{:__aliases__,[],[:ExUnit,:Case]},[async: true]]} | test_methods ] | |
mod = {:defmodule,[],[{:__aliases__,[],[:Mix, :Tasks, :Doctest, :InternalTests]}, | |
[do: {:__block__,[], body}]]} | |
Code.eval_quoted(mod) | |
ExUnit.configure([]) | |
ExUnit.run | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The failure you are getting is probably coming from this on line 22:
[[do: [{:_,[],nil}]]
. It basically says your function is defined like:def name(do: _), do: test
, you probably want this instead:{:def,[],[{name,[],[{:_,[],nil}]},[do: test]]}