Skip to content

Honour curly braces in target sections #933

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

Merged
merged 2 commits into from
Oct 25, 2015
Merged

Conversation

vlatkoB
Copy link
Contributor

@vlatkoB vlatkoB commented Oct 16, 2015

Accept target sections written with curly braces, i.e. remove them from targets listing.

Fixes #534.

@gracjan
Copy link
Contributor

gracjan commented Oct 16, 2015

Have you though about creating a couple of test cases for this functionality?

It seems way more complicated than it was expected initially.

@vlatkoB
Copy link
Contributor Author

vlatkoB commented Oct 16, 2015

Well, the change itself is actually not complicated. Split target name on space, take head and replace with "library" if head is "empty".
If haskell-cabal-section-value would return the correct value (without a brace), function could be reverted to the previous commit.
This is a just workaround.

Also, not sure if haskell-cabal-section-value should return something (like "library") for library section (which has no value), or leave it empty, as is now.
If that would be the case, even the last commit could be removed.

What say you?

@gracjan
Copy link
Contributor

gracjan commented Oct 16, 2015

Writing some unit tests for this doesn't take much time and is pretty easy task. There is no excuse to not do this.

@vlatkoB
Copy link
Contributor Author

vlatkoB commented Oct 16, 2015

I made a test-data directory with sample .cabal file, added haskell-cabal.el to ELFILES in Makefile, and made haskell-cabal-tests.el in tests with test function

(ert-deftest haskell-cabal-enum-targets-1 ()
  "Test enumerating .cabal targets."
  (with-temp-buffer
    (haskell-cabal-mode)
    (setq default-directory (expand-file-name "./test-data/"))
    (should (equal '("library" "test-1" "bench-1" "bin-1")
           (haskell-cabal-enum-targets)))))

ert in Emacs passes test, but make check from shell does not.
Little help...

vlatkoB added a commit to vlatkoB/haskell-mode that referenced this pull request Oct 16, 2015
@vlatkoB
Copy link
Contributor Author

vlatkoB commented Oct 16, 2015

Thanks.

@vlatkoB
Copy link
Contributor Author

vlatkoB commented Oct 20, 2015

Test is updated in the fix as well. Or do you mean to test the whole process, with haskell-session-change-target?

@gracjan
Copy link
Contributor

gracjan commented Oct 20, 2015

I thought about having a couple different xxx.cabal files, but now I see that you have covered all cases wit one cabal file. Seems good enough.

Can you quash all 4 commits into 2: one with functionality and one with the tests? We will merge when you do this.

@gracjan
Copy link
Contributor

gracjan commented Oct 21, 2015

Hmm, branch has conflicts, github does not allow me to merge it. Can you try to rebase again on top of master?

@gracjan gracjan changed the title Honour curly braces in target sections, fixes #534 Honour curly braces in target sections Oct 25, 2015
gracjan added a commit that referenced this pull request Oct 25, 2015
Honour curly braces in target sections
@gracjan gracjan merged commit 1f229c9 into haskell:master Oct 25, 2015
@gracjan
Copy link
Contributor

gracjan commented Oct 25, 2015

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants