Skip to content

Instantly share code, notes, and snippets.

@dsilen
Last active March 1, 2017 13:29
Show Gist options
  • Save dsilen/d181aa18d1a003ac1e0cd987c62d3fbb to your computer and use it in GitHub Desktop.
Save dsilen/d181aa18d1a003ac1e0cd987c62d3fbb to your computer and use it in GitHub Desktop.
Run EUnit on all Erlang files in a directory. The tasks.json file is used to build+test with VSCode using Ctrl+Shift+B (Cmd+Shift+B on Mac).
#!/usr/bin/env escript
main([]) ->
{ok, Filenames} = file:list_dir("."),
[run_eunit(File) || File <- Filenames, string:right(File,10) == "_tests.erl", File =/= "run_tests.erl" ],
erlang:halt(0).
run_eunit(File) ->
compile:file(File),
Module = list_to_atom(filename:basename(File, ".erl")),
io:format("Testing ~-12s", [Module]),
eunit:test(Module).
{
"version": "0.1.0",
"command": "escript",
"isShellCommand": false,
"args": ["run_tests.erl"],
"showOutput": "always"
}
Testing assignment1 All 5 tests passed.
Testing cut All 4 tests passed.
Testing fac 2 tests passed.
Testing fib All 3 tests passed.
Testing first Test passed.
Testing listfunc All 7 tests passed.
Testing second There were no tests to run.
Testing third All 3 tests passed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment