-
Notifications
You must be signed in to change notification settings - Fork 27
/
check-progress
executable file
·48 lines (41 loc) · 1.61 KB
/
check-progress
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/env escript
%% -*- erlang -*-
%%! -smp enable -sname factorial -mnesia debug verbose
main(_) ->
Folders = exercise_folders(),
run_tests(Folders, 1, length(Folders)).
run_tests([], _, _) ->
io:format("All tests completed."),
true;
run_tests([Folder | MoreFolders], CurrentCount, TotalCount) ->
case run_make_on_folder(Folder) of
true ->
io:format("~p.......ok~n", [Folder]),
run_tests(MoreFolders, CurrentCount + 1, TotalCount);
false ->
print_failure(Folder, CurrentCount, TotalCount)
end.
print_failure(Folder, CurrentCount, TotalCount) ->
io:format("Exercise `~s` failed.~n", [Folder]),
io:format("Review it, you may be closer than you think.~n",[]),
io:format("Progress: ~p/~p.~n", [CurrentCount-1, TotalCount]).
run_make_on_folder(Folder) ->
Output = cmd(Folder, "make"),
string:str(Output, "tests passed.") > 0.
cmd(Folder, Command) ->
Cmd = io_lib:format("~s ~s", [Command, Folder]),
CmdString = binary_to_list(iolist_to_binary(Cmd)),
os:cmd(CmdString).
exercise_folders() ->
lists:append(
[
in_folder("sequential", ["installing", "hello", "hello_pattern",
"lists", "bank_accounts", "calculate_bmi", "insert_element_at",
"filter_fibonacci_numbers", "maps", "regex"]),
in_folder("concurrent", ["calculator", "parallel_map", "priority", "ring_benchmark"]),
in_folder("otp", ["shopping_cart", "pool"])
%in_folder("distributed", ["remote_fun"])
%in_folder("libraries", ["shortly"])
]).
in_folder(Folder, SubFolders) ->
[Folder ++ "/" ++ SubFolder || SubFolder <- SubFolders].