-
-
Notifications
You must be signed in to change notification settings - Fork 368
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add golden tests for public configs (#3922)
Changes to the vscode schema need to be communicated to vscode-haskell plugin maintainers, otherwise users can't make use of the new configurations. In general, changes to the schema need to be done consciously when new plugin or features are added. We add these golden tests as an additional contract to inform relevant parties whenever the configs change. To fix a failing of these tests, review the change. If it is expected, accept the change via: TASTY_PATTERN="generate schema" cabal test func-test --test-options=--accept As changes need to be applied for all GHC version specific configs, you either need to run this command for each GHC version that is affected by the config change, or manually add the change to all other golden config files. Likely, the easiest way is to run CI and apply the generated diffs manually. Co-authored-by: Michael Peyton Jones <me@michaelpj.com>
- Loading branch information
Showing
16 changed files
with
1,505 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
module ConfigSchema where | ||
|
||
|
||
import qualified Data.ByteString.Lazy.Char8 as BS | ||
import Data.Char (toLower) | ||
import System.FilePath ((</>)) | ||
import System.Process.Extra | ||
import Test.Hls | ||
import Test.Hls.Command | ||
|
||
-- | Integration test to capture changes to the generated default config and the vscode schema. | ||
-- | ||
-- Changes to the vscode schema need to be communicated to vscode-haskell plugin maintainers, | ||
-- otherwise users can't make use of the new configurations. | ||
-- | ||
-- In general, changes to the schema need to be done consciously when new plugin or features are added. | ||
-- To fix a failing of these tests, review the change. If it is expected, accept the change via: | ||
-- | ||
-- @ | ||
-- TASTY_PATTERN="generate schema" cabal test func-test --test-options=--accept | ||
-- @ | ||
-- | ||
-- As changes need to be applied for all GHC version specific configs, you either need to run this command for each | ||
-- GHC version that is affected by the config change, or manually add the change to all other golden config files. | ||
-- Likely, the easiest way is to run CI and apply the generated diffs manually. | ||
tests :: TestTree | ||
tests = testGroup "generate schema" | ||
[ goldenGitDiff "vscode-extension-schema" (vscodeSchemaFp ghcVersion) $ do | ||
stdout <- readProcess hlsExeCommand ["vscode-extension-schema"] "" | ||
pure $ BS.pack stdout | ||
, goldenGitDiff "generate-default-config" (defaultConfigFp ghcVersion) $ do | ||
stdout <- readProcess hlsExeCommand ["generate-default-config"] "" | ||
pure $ BS.pack stdout | ||
] | ||
|
||
vscodeSchemaFp :: GhcVersion -> FilePath | ||
vscodeSchemaFp ghcVer = "test" </> "testdata" </> "schema" </> prettyGhcVersion ghcVer </> vscodeSchemaJson | ||
|
||
defaultConfigFp :: GhcVersion -> FilePath | ||
defaultConfigFp ghcVer = "test" </> "testdata" </> "schema" </> prettyGhcVersion ghcVer </> generateDefaultConfigJson | ||
|
||
vscodeSchemaJson :: FilePath | ||
vscodeSchemaJson = "vscode-extension-schema.golden.json" | ||
|
||
generateDefaultConfigJson :: FilePath | ||
generateDefaultConfigJson = "default-config.golden.json" | ||
|
||
prettyGhcVersion :: GhcVersion -> String | ||
prettyGhcVersion ghcVer = map toLower (show ghcVer) |
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
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 |
---|---|---|
@@ -0,0 +1,121 @@ | ||
{ | ||
"checkParents": "CheckOnSave", | ||
"checkProject": true, | ||
"formattingProvider": "ormolu", | ||
"maxCompletions": 40, | ||
"plugin": { | ||
"alternateNumberFormat": { | ||
"globalOn": true | ||
}, | ||
"cabal": { | ||
"codeActionsOn": true, | ||
"completionOn": true | ||
}, | ||
"callHierarchy": { | ||
"globalOn": true | ||
}, | ||
"changeTypeSignature": { | ||
"globalOn": true | ||
}, | ||
"class": { | ||
"codeActionsOn": true, | ||
"codeLensOn": true | ||
}, | ||
"eval": { | ||
"config": { | ||
"diff": true, | ||
"exception": false | ||
}, | ||
"globalOn": true | ||
}, | ||
"explicit-fields": { | ||
"globalOn": true | ||
}, | ||
"explicit-fixity": { | ||
"globalOn": true | ||
}, | ||
"fourmolu": { | ||
"config": { | ||
"external": false | ||
} | ||
}, | ||
"gadt": { | ||
"globalOn": true | ||
}, | ||
"ghcide-code-actions-bindings": { | ||
"globalOn": true | ||
}, | ||
"ghcide-code-actions-fill-holes": { | ||
"globalOn": true | ||
}, | ||
"ghcide-code-actions-imports-exports": { | ||
"globalOn": true | ||
}, | ||
"ghcide-code-actions-type-signatures": { | ||
"globalOn": true | ||
}, | ||
"ghcide-completions": { | ||
"config": { | ||
"autoExtendOn": true, | ||
"snippetsOn": true | ||
}, | ||
"globalOn": true | ||
}, | ||
"ghcide-hover-and-symbols": { | ||
"hoverOn": true, | ||
"symbolsOn": true | ||
}, | ||
"ghcide-type-lenses": { | ||
"config": { | ||
"mode": "always" | ||
}, | ||
"globalOn": true | ||
}, | ||
"hlint": { | ||
"codeActionsOn": true, | ||
"config": { | ||
"flags": [] | ||
}, | ||
"diagnosticsOn": true | ||
}, | ||
"importLens": { | ||
"codeActionsOn": true, | ||
"codeLensOn": true | ||
}, | ||
"moduleName": { | ||
"globalOn": true | ||
}, | ||
"ormolu": { | ||
"config": { | ||
"external": false | ||
} | ||
}, | ||
"overloaded-record-dot": { | ||
"globalOn": true | ||
}, | ||
"pragmas-completion": { | ||
"globalOn": true | ||
}, | ||
"pragmas-disable": { | ||
"globalOn": true | ||
}, | ||
"pragmas-suggest": { | ||
"globalOn": true | ||
}, | ||
"qualifyImportedNames": { | ||
"globalOn": true | ||
}, | ||
"rename": { | ||
"config": { | ||
"crossModule": false | ||
}, | ||
"globalOn": true | ||
}, | ||
"retrie": { | ||
"globalOn": true | ||
}, | ||
"splice": { | ||
"globalOn": true | ||
} | ||
} | ||
} |
Oops, something went wrong.