Skip to content
This repository has been archived by the owner on Oct 7, 2020. It is now read-only.

Add package to library component in package.yaml #1237

Merged
merged 11 commits into from
May 18, 2019

Conversation

fendor
Copy link
Collaborator

@fendor fendor commented May 2, 2019

Closes #1230.

Adds some unit-tests.

Todo:

  • Code tidy up
  • More tests

@fendor fendor changed the title Add package to library component in package.yaml WIP: Add package to library component in package.yaml May 3, 2019
@fendor fendor changed the title WIP: Add package to library component in package.yaml Add package to library component in package.yaml May 6, 2019
@fendor fendor requested review from lorenzo and lukel97 May 6, 2019 19:20
@fendor fendor force-pushed the add-package-tests branch 2 times, most recently from c5cb9e0 to dcc0518 Compare May 6, 2019 20:07
test/utils/TestUtils.hs Outdated Show resolved Hide resolved
Copy link
Collaborator

@lukel97 lukel97 left a comment

Choose a reason for hiding this comment

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

Other than the hieCommand thing this LGTM!

@fendor fendor force-pushed the add-package-tests branch from d143e50 to 26c47a0 Compare May 11, 2019 19:30
@fendor fendor force-pushed the add-package-tests branch from 26c47a0 to 07d1469 Compare May 11, 2019 19:42
@fendor fendor force-pushed the add-package-tests branch from 07d1469 to aed6b42 Compare May 11, 2019 20:16
@fendor
Copy link
Collaborator Author

fendor commented May 12, 2019

It seems that the tests fail for cabal files and ghc versions below 8.4.*.
They probably have always failed, but the additional tests have shown their failure.
What is the preferred course of action? Disabling the feature altogether? I could also try to fix it for the old ghc-versions.

@lukel97
Copy link
Collaborator

lukel97 commented May 12, 2019

@fendor did the FunctionalCodeActionsSpec tests for "add package suggestions" not used to pass on 8.2.x? I presume if #1249 is happening this won't matter, too much, but out of curiosity how were they failing?

@fendor
Copy link
Collaborator Author

fendor commented May 12, 2019

The problem can acutally be shown in the Unit-tests.
Given the cabal file and task to add the package text:

Example .cabal:

name:                add-package-test
version:             0.1.0.0
license:             BSD3
author:              Luke Lau
maintainer:          luke_lau@icloud.com
build-type:          Simple
extra-source-files:  ChangeLog.md
cabal-version:       >=1.10

executable AddPackage
  exposed-modules:     ./.
  main-is:             AddPackage.hs
  build-depends:       base >=4.7 && <5
  default-language:    Haskell2010

Normally the result should be:

              List
                [ TextEdit (Range (Position 0 0) (Position 7 27)) $ T.concat
                  [ "cabal-version: >=1.10\n"
                  , "name: add-package-test\n"
                  , "version: 0.1.0.0\n"
                  , "license: BSD3\n"
                  , "maintainer: [email protected]\n"
                  , "author: Luke Lau\n"
                  , "build-type: Simple\n"
                  , "extra-source-files:\n"
                  , "    ChangeLog.md"
                  ]
                , TextEdit (Range (Position 10 0) (Position 13 34)) $ T.concat
                  [ "    main-is: AddPackage.hs\n"
                  , "    default-language: Haskell2010\n"
                  , "    build-depends:\n"
                  , "        base >=4.7 && <5,\n"
                  , "        text -any"
                  ]
                ]

But on GHC 8.2.* the output is actually:

              List -- TODO: this seems to indicate that the command does nothing
                [ TextEdit (Range (Position 0 0) (Position 7 27)) $ T.concat
                  [ "name: add-package-test\n"
                  , "version: 0.1.0.0\n"
                  , "cabal-version: >=1.10\n"
                  , "build-type: Simple\n"
                  , "license: BSD3\n"
                  , "maintainer: [email protected]\n"
                  , "author: Luke Lau\n"
                  , "extra-source-files:\n"
                  , "    ChangeLog.md"
                  ]
                , TextEdit (Range (Position 9 0) (Position 13 34)) $ T.concat
                  [ "executable  AddPackage\n"
                  , "    main-is: AddPackage.hs\n"
                  ]
                ]

It seems like the build-depends field has either been swallowed, or hadnt been updated.

@fendor
Copy link
Collaborator Author

fendor commented May 15, 2019

I think, we can actually merge this. It adds a bunch of useful tests and the problem this PR uncovered is present anyway. At least, it will be documented via tests now.

@lukel97 lukel97 merged commit 9fca31c into haskell:master May 18, 2019
alanz added a commit that referenced this pull request May 18, 2019
This reverts commit 9fca31c, reversing
changes made to a96ca84.
@alanz
Copy link
Collaborator

alanz commented May 18, 2019

@fendor Please update this branch to work with current master, and we can merge it again.

alanz added a commit to alanz/haskell-ide-engine that referenced this pull request May 23, 2019
alanz added a commit that referenced this pull request May 24, 2019
Revert "Revert "Merge pull request #1237 from fendor/add-package-tests""
@alanz alanz added this to the 2019-05 milestone Jun 1, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Package command does nothing on package.yaml for library component
3 participants