-
-
Notifications
You must be signed in to change notification settings - Fork 370
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use relative file paths for HIE files and Stan's config maps (#4023)
* Use relative file paths for HIE files and Stan's config maps Stan expects relative paths. Without this change, file names won't map correctly to their associated language extension data, which means no enabled extensions will be detected. This causes annoying false positives with, e.g., the `StrictData` extension. (See issue #3174.) * Un-exclude Stan diagnostics related to `StrictData` We specifically want to test this diagnostic, so we need it to fire. * Add tests to ensure the Stan plugin detects a module's language extensions Includes test cases for both `LANGUAGE` pragmas and extensions enabled in a project's `.cabal` file. * Tighten up Stan plugin language extension test cases These changes ensure that the tests will fail given bad mappings in either the `cabalExtensionsMap` OR the `checksMap`. Either of these could cause bad behavior as seen in issue #3174. * Use correct extension/file mappings even in the case of a config fiasco The Stan plugin will still operate as expected even if we can't load a config -- it will simply default to showing all inspections. * Remove a slew of unused imports * Use OS-agnostic path separators in tests * Run `stylish-haskell` * Ensure `hs-source-dirs` in test cabal files don't contain path separators Related to (what I assume is) a bug in Stan, or its `extensions` library. Regardless of OS, the `hs-source-dirs` field is prepended as-is to the module name to create the file paths used in the cabal extensions map. This means the maps won't work in Windows if your cabal file contains `/` path separators. Working around the limitation here to ensure tests work on all platforms. --------- Co-authored-by: Michael Peyton Jones <[email protected]> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
- Loading branch information
1 parent
4b95e55
commit 5c11636
Showing
8 changed files
with
111 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
data A = A Int Int | ||
|
||
a = length [1..] | ||
|
||
b = undefined |
7 changes: 7 additions & 0 deletions
7
plugins/hls-stan-plugin/test/testdata/extensions-cabal-file/CabalFileTest.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module CabalFileTest () where | ||
|
||
-- With `StrictData` enabled in the `.cabal` file, Stan shouldn't complain here: | ||
data A = A Int Int | ||
|
||
-- ...but it should still complain here! | ||
kewlFunc = undefined |
9 changes: 9 additions & 0 deletions
9
plugins/hls-stan-plugin/test/testdata/extensions-cabal-file/cabal-file-test.cabal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
cabal-version: 3.0 | ||
name: cabal-file-test | ||
version: 0.0.0.0 | ||
|
||
library | ||
exposed-modules: CabalFileTest | ||
hs-source-dirs: extensions-cabal-file | ||
-- Specifically, we're testing that Stan respects the following extension definition: | ||
default-extensions: StrictData |
9 changes: 9 additions & 0 deletions
9
plugins/hls-stan-plugin/test/testdata/extensions-language-pragma/LanguagePragmaTest.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{-# LANGUAGE StrictData #-} | ||
|
||
module LanguagePragmaTest () where | ||
|
||
-- With the above `StrictData` language pragma, Stan shouldn't complain here: | ||
data A = A Int Int | ||
|
||
-- ...but it should still complain here! | ||
kewlFunc = undefined |
11 changes: 11 additions & 0 deletions
11
plugins/hls-stan-plugin/test/testdata/extensions-language-pragma/language-pragma-test.cabal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
cabal-version: 3.0 | ||
name: language-pragma-test | ||
version: 0.0.0.0 | ||
|
||
-- Without at least a minimal valid `.cabal` file, Stan won't bother building its | ||
-- map of language extensions. This means it also won't detect LANGUAGE pragmas | ||
-- without this file. | ||
|
||
library | ||
exposed-modules: LanguagePragmaTest | ||
hs-source-dirs: extensions-language-pragma |