Skip to content

Commit 4086845

Browse files
Cleanup format testfiles (#765)
* Move testdata for auto-formatting tests into its own sub-folder. It's a lot of files, packing them up into their own little folder makes the testdata directory much cleaner. * Delete unused test datafiles. These look like one the files used in the formatting tests, but they aren't. These files do nothing. * Fix typo. "Haksell" |-> "Haskell". Haksell is what we do to our users. Co-authored-by: Pepe Iborra <[email protected]>
1 parent aa7e9a3 commit 4086845

26 files changed

+24
-40
lines changed

test/functional/Format.hs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ import qualified Data.Text.IO as T
1818

1919
tests :: TestTree
2020
tests = testGroup "format document" [
21-
goldenVsStringDiff "works" goldenGitDiff "test/testdata/Format.formatted_document.hs" $ runSession hlsCommand fullCaps "test/testdata" $ do
21+
goldenVsStringDiff "works" goldenGitDiff "test/testdata/format/Format.formatted_document.hs" $ runSession hlsCommand fullCaps "test/testdata/format" $ do
2222
doc <- openDoc "Format.hs" "haskell"
2323
formatDoc doc (FormattingOptions 2 True)
2424
BS.fromStrict . T.encodeUtf8 <$> documentContents doc
25-
, goldenVsStringDiff "works with custom tab size" goldenGitDiff "test/testdata/Format.formatted_document_with_tabsize.hs" $ runSession hlsCommand fullCaps "test/testdata" $ do
25+
, goldenVsStringDiff "works with custom tab size" goldenGitDiff "test/testdata/format/Format.formatted_document_with_tabsize.hs" $ runSession hlsCommand fullCaps "test/testdata/format" $ do
2626
doc <- openDoc "Format.hs" "haskell"
2727
formatDoc doc (FormattingOptions 5 True)
2828
BS.fromStrict . T.encodeUtf8 <$> documentContents doc
@@ -38,19 +38,19 @@ tests = testGroup "format document" [
3838

3939
rangeTests :: TestTree
4040
rangeTests = testGroup "format range" [
41-
goldenVsStringDiff "works" goldenGitDiff "test/testdata/Format.formatted_range.hs" $ runSession hlsCommand fullCaps "test/testdata" $ do
41+
goldenVsStringDiff "works" goldenGitDiff "test/testdata/format/Format.formatted_range.hs" $ runSession hlsCommand fullCaps "test/testdata/format" $ do
4242
doc <- openDoc "Format.hs" "haskell"
4343
formatRange doc (FormattingOptions 2 True) (Range (Position 5 0) (Position 7 10))
4444
BS.fromStrict . T.encodeUtf8 <$> documentContents doc
45-
, goldenVsStringDiff "works with custom tab size" goldenGitDiff "test/testdata/Format.formatted_range_with_tabsize.hs" $ runSession hlsCommand fullCaps "test/testdata" $ do
45+
, goldenVsStringDiff "works with custom tab size" goldenGitDiff "test/testdata/format/Format.formatted_range_with_tabsize.hs" $ runSession hlsCommand fullCaps "test/testdata/format" $ do
4646
doc <- openDoc "Format.hs" "haskell"
4747
formatRange doc (FormattingOptions 5 True) (Range (Position 8 0) (Position 11 19))
4848
BS.fromStrict . T.encodeUtf8 <$> documentContents doc
4949
]
5050

5151
providerTests :: TestTree
5252
providerTests = testGroup "formatting provider" [
53-
testCase "respects none" $ runSessionWithConfig (formatConfig "none") hlsCommand fullCaps "test/testdata" $ do
53+
testCase "respects none" $ runSessionWithConfig (formatConfig "none") hlsCommand fullCaps "test/testdata/format" $ do
5454
doc <- openDoc "Format.hs" "haskell"
5555
orig <- documentContents doc
5656

@@ -61,10 +61,10 @@ providerTests = testGroup "formatting provider" [
6161
documentContents doc >>= liftIO . (@?= orig)
6262

6363
#if AGPL
64-
, testCase "can change on the fly" $ runSession hlsCommand fullCaps "test/testdata" $ do
65-
formattedBrittany <- liftIO $ T.readFile "test/testdata/Format.brittany.formatted.hs"
66-
formattedFloskell <- liftIO $ T.readFile "test/testdata/Format.floskell.formatted.hs"
67-
formattedBrittanyPostFloskell <- liftIO $ T.readFile "test/testdata/Format.brittany_post_floskell.formatted.hs"
64+
, testCase "can change on the fly" $ runSession hlsCommand fullCaps "test/testdata/format" $ do
65+
formattedBrittany <- liftIO $ T.readFile "test/testdata/format/Format.brittany.formatted.hs"
66+
formattedFloskell <- liftIO $ T.readFile "test/testdata/format/Format.floskell.formatted.hs"
67+
formattedBrittanyPostFloskell <- liftIO $ T.readFile "test/testdata/format/Format.brittany_post_floskell.formatted.hs"
6868

6969
doc <- openDoc "Format.hs" "haskell"
7070

@@ -79,9 +79,9 @@ providerTests = testGroup "formatting provider" [
7979
sendNotification WorkspaceDidChangeConfiguration (DidChangeConfigurationParams (formatLspConfig "brittany"))
8080
formatDoc doc (FormattingOptions 2 True)
8181
documentContents doc >>= liftIO . (@?= formattedBrittanyPostFloskell)
82-
, testCase "supports both new and old configuration sections" $ runSession hlsCommand fullCaps "test/testdata" $ do
83-
formattedBrittany <- liftIO $ T.readFile "test/testdata/Format.brittany.formatted.hs"
84-
formattedFloskell <- liftIO $ T.readFile "test/testdata/Format.floskell.formatted.hs"
82+
, testCase "supports both new and old configuration sections" $ runSession hlsCommand fullCaps "test/testdata/format" $ do
83+
formattedBrittany <- liftIO $ T.readFile "test/testdata/format/Format.brittany.formatted.hs"
84+
formattedFloskell <- liftIO $ T.readFile "test/testdata/format/Format.floskell.formatted.hs"
8585

8686
doc <- openDoc "Format.hs" "haskell"
8787

@@ -97,12 +97,12 @@ providerTests = testGroup "formatting provider" [
9797

9898
stylishHaskellTests :: TestTree
9999
stylishHaskellTests = testGroup "stylish-haskell" [
100-
goldenVsStringDiff "formats a document" goldenGitDiff "test/testdata/StylishHaksell.formatted_document.hs" $ runSession hlsCommand fullCaps "test/testdata" $ do
100+
goldenVsStringDiff "formats a document" goldenGitDiff "test/testdata/format/StylishHaskell.formatted_document.hs" $ runSession hlsCommand fullCaps "test/testdata/format" $ do
101101
sendNotification WorkspaceDidChangeConfiguration (DidChangeConfigurationParams (formatLspConfig "stylish-haskell"))
102102
doc <- openDoc "StylishHaskell.hs" "haskell"
103103
formatDoc doc (FormattingOptions 2 True)
104104
BS.fromStrict . T.encodeUtf8 <$> documentContents doc
105-
, goldenVsStringDiff "formats a range" goldenGitDiff "test/testdata/StylishHaksell.formatted_range.hs" $ runSession hlsCommand fullCaps "test/testdata" $ do
105+
, goldenVsStringDiff "formats a range" goldenGitDiff "test/testdata/format/StylishHaskell.formatted_range.hs" $ runSession hlsCommand fullCaps "test/testdata/format" $ do
106106
sendNotification WorkspaceDidChangeConfiguration (DidChangeConfigurationParams (formatLspConfig "stylish-haskell"))
107107
doc <- openDoc "StylishHaskell.hs" "haskell"
108108
formatRange doc (FormattingOptions 2 True) (Range (Position 0 0) (Position 2 21))
@@ -112,26 +112,26 @@ stylishHaskellTests = testGroup "stylish-haskell" [
112112
#if AGPL
113113
brittanyTests :: TestTree
114114
brittanyTests = testGroup "brittany" [
115-
goldenVsStringDiff "formats a document with LF endings" goldenGitDiff "test/testdata/BrittanyLF.formatted_document.hs" $ runSession hlsCommand fullCaps "test/testdata" $ do
115+
goldenVsStringDiff "formats a document with LF endings" goldenGitDiff "test/testdata/format/BrittanyLF.formatted_document.hs" $ runSession hlsCommand fullCaps "test/testdata/format" $ do
116116
sendNotification WorkspaceDidChangeConfiguration (DidChangeConfigurationParams (formatLspConfig "brittany"))
117117
doc <- openDoc "BrittanyLF.hs" "haskell"
118118
formatDoc doc (FormattingOptions 4 True)
119119
BS.fromStrict . T.encodeUtf8 <$> documentContents doc
120120

121-
, goldenVsStringDiff "formats a document with CRLF endings" goldenGitDiff "test/testdata/BrittanyCRLF.formatted_document.hs" $ runSession hlsCommand fullCaps "test/testdata" $ do
121+
, goldenVsStringDiff "formats a document with CRLF endings" goldenGitDiff "test/testdata/format/BrittanyCRLF.formatted_document.hs" $ runSession hlsCommand fullCaps "test/testdata/format" $ do
122122
sendNotification WorkspaceDidChangeConfiguration (DidChangeConfigurationParams (formatLspConfig "brittany"))
123123
doc <- openDoc "BrittanyCRLF.hs" "haskell"
124124
formatDoc doc (FormattingOptions 4 True)
125125
BS.fromStrict . T.encodeUtf8 <$> documentContents doc
126126

127-
, goldenVsStringDiff "formats a range with LF endings" goldenGitDiff "test/testdata/BrittanyLF.formatted_range.hs" $ runSession hlsCommand fullCaps "test/testdata" $ do
127+
, goldenVsStringDiff "formats a range with LF endings" goldenGitDiff "test/testdata/format/BrittanyLF.formatted_range.hs" $ runSession hlsCommand fullCaps "test/testdata/format" $ do
128128
sendNotification WorkspaceDidChangeConfiguration (DidChangeConfigurationParams (formatLspConfig "brittany"))
129129
doc <- openDoc "BrittanyLF.hs" "haskell"
130130
let range = Range (Position 1 0) (Position 2 22)
131131
formatRange doc (FormattingOptions 4 True) range
132132
BS.fromStrict . T.encodeUtf8 <$> documentContents doc
133133

134-
, goldenVsStringDiff "formats a range with CRLF endings" goldenGitDiff "test/testdata/BrittanyCRLF.formatted_range.hs" $ runSession hlsCommand fullCaps "test/testdata" $ do
134+
, goldenVsStringDiff "formats a range with CRLF endings" goldenGitDiff "test/testdata/format/BrittanyCRLF.formatted_range.hs" $ runSession hlsCommand fullCaps "test/testdata/format" $ do
135135
sendNotification WorkspaceDidChangeConfiguration (DidChangeConfigurationParams (formatLspConfig "brittany"))
136136
doc <- openDoc "BrittanyCRLF.hs" "haskell"
137137
let range = Range (Position 1 0) (Position 2 22)
@@ -142,12 +142,12 @@ brittanyTests = testGroup "brittany" [
142142

143143
ormoluTests :: TestTree
144144
ormoluTests = testGroup "ormolu"
145-
[ goldenVsStringDiff "formats correctly" goldenGitDiff "test/testdata/Format.ormolu.formatted.hs" $ runSession hlsCommand fullCaps "test/testdata" $ do
145+
[ goldenVsStringDiff "formats correctly" goldenGitDiff "test/testdata/format/Format.ormolu.formatted.hs" $ runSession hlsCommand fullCaps "test/testdata/format" $ do
146146
sendNotification WorkspaceDidChangeConfiguration (DidChangeConfigurationParams (formatLspConfig "ormolu"))
147147
doc <- openDoc "Format.hs" "haskell"
148148
formatDoc doc (FormattingOptions 2 True)
149149
BS.fromStrict . T.encodeUtf8 <$> documentContents doc
150-
, goldenVsStringDiff "formats imports correctly" goldenGitDiff "test/testdata/Format2.ormolu.formatted.hs" $ runSession hlsCommand fullCaps "test/testdata" $ do
150+
, goldenVsStringDiff "formats imports correctly" goldenGitDiff "test/testdata/format/Format2.ormolu.formatted.hs" $ runSession hlsCommand fullCaps "test/testdata/format" $ do
151151
sendNotification WorkspaceDidChangeConfiguration (DidChangeConfigurationParams (formatLspConfig "ormolu"))
152152
doc <- openDoc "Format2.hs" "haskell"
153153
formatDoc doc (FormattingOptions 2 True)
@@ -156,12 +156,12 @@ ormoluTests = testGroup "ormolu"
156156

157157
fourmoluTests :: TestTree
158158
fourmoluTests = testGroup "fourmolu"
159-
[ goldenVsStringDiff "formats correctly" goldenGitDiff "test/testdata/Format.fourmolu.formatted.hs" $ runSession hlsCommand fullCaps "test/testdata" $ do
159+
[ goldenVsStringDiff "formats correctly" goldenGitDiff "test/testdata/format/Format.fourmolu.formatted.hs" $ runSession hlsCommand fullCaps "test/testdata/format" $ do
160160
sendNotification WorkspaceDidChangeConfiguration (DidChangeConfigurationParams (formatLspConfig "fourmolu"))
161161
doc <- openDoc "Format.hs" "haskell"
162162
formatDoc doc (FormattingOptions 4 True)
163163
BS.fromStrict . T.encodeUtf8 <$> documentContents doc
164-
, goldenVsStringDiff "formats imports correctly" goldenGitDiff "test/testdata/Format2.fourmolu.formatted.hs" $ runSession hlsCommand fullCaps "test/testdata" $ do
164+
, goldenVsStringDiff "formats imports correctly" goldenGitDiff "test/testdata/format/Format2.fourmolu.formatted.hs" $ runSession hlsCommand fullCaps "test/testdata/format" $ do
165165
sendNotification WorkspaceDidChangeConfiguration (DidChangeConfigurationParams (formatLspConfig "fourmolu"))
166166
doc <- openDoc "Format2.hs" "haskell"
167167
formatDoc doc (FormattingOptions 4 True)

test/functional/Progress.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@ tests =
4141
_ <- sendRequest WorkspaceExecuteCommand $ ExecuteCommandParams (cmd ^. L.command) (decode $ encode $ fromJust $ cmd ^. L.arguments) Nothing
4242
expectProgressReports ["Evaluating"]
4343
, testCase "ormolu plugin sends progress notifications" $ do
44-
runSession hlsCommand progressCaps "test/testdata" $ do
44+
runSession hlsCommand progressCaps "test/testdata/format" $ do
4545
sendNotification WorkspaceDidChangeConfiguration (DidChangeConfigurationParams (formatLspConfig "ormolu"))
4646
doc <- openDoc "Format.hs" "haskell"
4747
expectProgressReports ["Setting up testdata (for Format.hs)", "Processing"]
4848
_ <- sendRequest TextDocumentFormatting $ DocumentFormattingParams doc (FormattingOptions 2 True) Nothing
4949
expectProgressReports ["Formatting Format.hs"]
5050
, testCase "fourmolu plugin sends progress notifications" $ do
51-
runSession hlsCommand progressCaps "test/testdata" $ do
51+
runSession hlsCommand progressCaps "test/testdata/format" $ do
5252
sendNotification WorkspaceDidChangeConfiguration (DidChangeConfigurationParams (formatLspConfig "fourmolu"))
5353
doc <- openDoc "Format.hs" "haskell"
5454
expectProgressReports ["Setting up testdata (for Format.hs)", "Processing"]

test/testdata/StylishHaksell.formatted_document.hs

Lines changed: 0 additions & 8 deletions
This file was deleted.

test/testdata/StylishHaksell.formatted_range.hs

Lines changed: 0 additions & 8 deletions
This file was deleted.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)