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(cabal.project parser): parse the packages ending with eof #222

Merged
merged 5 commits into from
Feb 6, 2024
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- #210: Add `extraLibraries` to `settings` module.
- #215: Improved debug logging.
- #216: Remove `debug` option (pass `--trace-verbose` to nix instead)
- #222: Improve `cabal.project` parser by handling files not ending with newline
- Breaking changes
- #221: Switch to `buildFromSdist`, to allow using non-standard package sets (wherein `cabal-install` is otherwise built without using user's overrides)

Expand Down
6 changes: 5 additions & 1 deletion nix/haskell-parsers/parser.nix
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ in
key = parsec.string "packages:\n";
val =
parsec.many1
(parsec.between spaces1 newline path);
(parsec.choice
[
(parsec.between spaces1 newline path)
(parsec.between spaces1 parsec.eof path)
]);
parser = parsec.skipThen
key
val;
Expand Down
9 changes: 9 additions & 0 deletions nix/haskell-parsers/parser_tests.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ let
'';
expected = [ "foo" "bar" ];
};

# Handles cases where cabal.project does not end with newline
testEOF = {
expr = eval ''
packages:
foo
bar'';
expected = [ "foo" "bar" ];
};
};
cabalExecutableTests =
let
Expand Down
2 changes: 1 addition & 1 deletion test/with-subdir/cabal.project
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
packages:
./haskell-flake-test
./haskell-flake-test