Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix runner crash on some exercises #20

Merged
merged 33 commits into from
Oct 30, 2021
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
61db99f
add rudimentary flake to use for dev env
NobbZ Nov 22, 2020
5d0b3bb
Adjust Dockerfile base image
NobbZ Feb 20, 2021
d9ba1cf
rough first edge
NobbZ Feb 21, 2021
741e1d9
cleaning main
NobbZ Feb 21, 2021
3b6f047
try some testbaked changes
NobbZ Feb 21, 2021
425112f
add all the test data
NobbZ Feb 21, 2021
6e28528
know that all current practice exercises could be run through the tes…
NobbZ Feb 21, 2021
300bc1b
prepare for individually running cases
NobbZ Feb 22, 2021
1d63563
Merge branch 'main' of github.com:NobbZ/erlang-test-runner
NobbZ Feb 22, 2021
79ee26b
make sure captions are returned as binary
NobbZ Feb 22, 2021
269c892
add a failure in two-fer
NobbZ Feb 22, 2021
7f03720
run the test and grade it
NobbZ Feb 22, 2021
bf0f4a7
adjust tests
NobbZ Feb 22, 2021
b8da8cf
Shuffle tests during run
NobbZ Feb 23, 2021
af3c3d7
add an assertion for number of failures
NobbZ Feb 28, 2021
c43ab6e
fallback assertion
NobbZ Mar 27, 2021
a0d34ed
prepare runner for third argument
NobbZ Mar 27, 2021
857563a
finish dockerfile
NobbZ Mar 27, 2021
1dab6a8
fix entrypoint script
NobbZ Mar 27, 2021
49856b8
add config logging during tests
NobbZ Mar 27, 2021
413c50b
add JSX
NobbZ Mar 27, 2021
1e9f64f
write JSON to disk
NobbZ Mar 27, 2021
9b16256
install erl_exercism
NobbZ Mar 28, 2021
9f87bd7
run tests in docker
NobbZ Mar 28, 2021
56bd4e5
extract some common testing helpers
NobbZ Mar 28, 2021
e05a804
use erlsh to run docker
NobbZ Mar 28, 2021
0924f9a
use undefined function to reduce code
NobbZ Mar 29, 2021
07d97bb
fix casing for docker target names
NobbZ Apr 11, 2021
897c2ba
Merge branch 'main' of github.com:exercism/erlang-test-runner
NobbZ Sep 4, 2021
c7a8fdf
make it accept a list of generators
NobbZ Oct 30, 2021
42e31c2
grade lists as well
NobbZ Oct 30, 2021
e34cc3d
flatten list of tests after run
NobbZ Oct 30, 2021
091171c
Update Dockerfile
NobbZ Oct 30, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
FROM hexpm/erlang:22.3.4.12-ubuntu-focal-20200703 as erlang
FROM hexpm/erlang:22.3.4.12-ubuntu-focal-20200703 AS erlang

WORKDIR /app

FROM erlang as downloader
FROM erlang AS downloader

RUN apt update; apt install --yes curl; \
mkdir -p /tmp/tools; \
Expand All @@ -18,9 +18,9 @@ RUN ./rebar3 get-deps
COPY src/ src/
RUN ./rebar3 escriptize; find . -type f -executable

FROM erlang as runner
FROM erlang AS runner

COPY --from=builder /app/_build/default/lib/erl_exercism /opt/erl_exercism
copy --from=builder /app/_build/default/lib/erl_exercism /opt/erl_exercism
NobbZ marked this conversation as resolved.
Show resolved Hide resolved
COPY --from=builder /app/_build/default/bin/erlang_test_runner /opt/test-runner/bin/
COPY run.sh /opt/test-runner/bin/run.sh

Expand Down
10 changes: 7 additions & 3 deletions src/etr_runner.erl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ run(Module) ->
match == re:run(atom_to_binary(Fun, utf8), "_test_?$", [{capture, none}])
],
Results = [run_case(TestModule, Fun, Gen) || {Fun, Gen} <- TestFuns],
Tests = [grade_test(Result) || Result <- Results],
Tests = lists:flatten([grade_test(Result) || Result <- Results]),
#{
version => 2,
status => get_status(Tests),
Expand All @@ -30,8 +30,11 @@ get_test_module_from(Module) ->
run_case(Module, Fun, false) ->
{atom_to_binary(Fun, utf8), run_case(erlang:make_fun(Module, Fun, 0))};
run_case(Module, Gen, true) ->
{Description, {_, Fun}} = Module:Gen(),
{list_to_binary(Description), run_case(Fun)}.
Runner = fun({Description, {_, Fun}}) -> {list_to_binary(Description), run_case(Fun)} end,
case Module:Gen() of
{_, {_, _}} = Case -> Runner(Case);
L when is_list(L) -> lists:map(Runner, L)
end.

run_case(Fun) ->
{Self, Ref} = {self(), make_ref()},
Expand All @@ -50,6 +53,7 @@ sweep_inbox(Ref, MRef, Result) ->
after 0 -> Result
end.

grade_test(L) when is_list(L) -> lists:map(fun grade_test/1, L);
grade_test({Name, {pass, ok}}) ->
#{
name => Name,
Expand Down