Skip to content

Commit

Permalink
Skip test_dir test if atomvm:posix_opendir/1 is not available
Browse files Browse the repository at this point in the history
  • Loading branch information
pguyot committed Jan 23, 2025
1 parent 0d6a00e commit 3f5242e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
10 changes: 8 additions & 2 deletions libs/etest/src/etest.erl
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,15 @@ do_run_test(Test) ->
false ->
ok
end,
Char = case Result of
ok -> "+";
skipped -> "s"
end,
case erlang:system_info(machine) of
"BEAM" ->
io:format("+");
io:format(Char);
_ ->
console:puts("+"),
console:puts(Char),
console:flush()
end,
Result
Expand All @@ -213,5 +217,7 @@ check_results([]) ->
ok;
check_results([{_Test, ok} | T]) ->
check_results(T);
check_results([{_Test, skipped} | T]) ->
check_results(T);
check_results([Failure | _T]) ->
{fail, Failure}.
10 changes: 7 additions & 3 deletions tests/libs/eavmlib/test_dir.erl
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,13 @@
-include("etest.hrl").

test() ->
{ok, Dir} = atomvm:posix_opendir("."),
[eof | _Entries] = all_dir_entries(Dir, []),
ok = atomvm:posix_closedir(Dir).
case catch (atomvm:posix_opendir(".")) of
{ok, Dir} ->
[eof | _Entries] = all_dir_entries(Dir, []),
ok = atomvm:posix_closedir(Dir);
{'EXIT', _} ->
skipped
end.

all_dir_entries(Dir, Acc) ->
case atomvm:posix_readdir(Dir) of
Expand Down

0 comments on commit 3f5242e

Please sign in to comment.