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

Add case for incomplete/syntax-error when parsing conf file. #165

Merged
merged 1 commit into from
Oct 17, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 7 additions & 0 deletions src/cuttlefish_conf.erl
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ file(Filename) ->
case conf_parse:file(Filename) of
{error, Reason} ->
{error, [{error, ?FMT("Could not open file (~s) for Reason ~s", [Filename, Reason])}]};
{_Conf, Remainder, {{line, L}, {column, C}}} when is_binary(Remainder) ->
{error, [{error, ?FMT("Syntax error in ~s after line ~p column ~p, parsing incomplete", [Filename, L, C])}]};
Conf ->
%% Conf is a proplist, check if any of the values are cuttlefish_errors
{_, Values} = lists:unzip(Conf),
Expand Down Expand Up @@ -273,6 +275,11 @@ files_one_nonent_test() ->
?assertEqual({error,[{error,"Could not open file (../test/nonent.conf) for Reason enoent"}]}, Conf),
ok.

files_incomplete_parse_test() ->
Conf = file("../test/incomplete.conf"),
?assertEqual({error, [{error,"Syntax error in ../test/incomplete.conf after line 3 column 1, parsing incomplete"}]}, Conf),
ok.

generate_element_level_advanced_test() ->
cuttlefish_lager_test_backend:bounce(warning),
assert_no_output({level, advanced}),
Expand Down
3 changes: 3 additions & 0 deletions test/incomplete.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
a.b = c
c.d = e
f =