Skip to content

Commit

Permalink
Add case for incomplete/syntax-error when parsing conf file. Addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
seancribbs committed Sep 5, 2014
1 parent b2ce0b1 commit 36d1d11
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
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 =

10 comments on commit 36d1d11

@borshop
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from zeeshanlakhani
at 36d1d11

@borshop
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging basho/cuttlefish/bugfix/sdc/incomplete-parse = 36d1d11 into borshop-integration-165-bugfix/sdc/incomplete-parse

@borshop
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

basho/cuttlefish/bugfix/sdc/incomplete-parse = 36d1d11 merged ok, testing candidate = 8165d0b

@borshop
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@seancribbs
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@borshop: retry

@borshop
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from zeeshanlakhani
at 36d1d11

@borshop
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging basho/cuttlefish/bugfix/sdc/incomplete-parse = 36d1d11 into borshop-integration-165-bugfix/sdc/incomplete-parse

@borshop
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

basho/cuttlefish/bugfix/sdc/incomplete-parse = 36d1d11 merged ok, testing candidate = ead47a0

@borshop
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@borshop
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding 2.0 to borshop-integration-165-bugfix/sdc/incomplete-parse = ead47a0

Please sign in to comment.