@@ -13,213 +13,32 @@ main = hspec spec
13
13
14
14
spec :: Spec
15
15
spec = do
16
- describe " Should Succeed" $
17
- it " successfully parses executable section" $
18
- exeSection ~> parseExe 0
19
- `shouldParse` [Comp Exe " gen-hie" " app/Main.hs" ]
20
- describe " Should Succeed" $
21
- it " successfully parses test section" $
22
- testSection ~> parseTestSuite 0
23
- `shouldParse` [Comp Test " implicit-hie-test" " test" ]
24
- describe " Should Succeed" $
25
- it " successfully parses library section" $
26
- libSection ~> parseLib 0
27
- `shouldParse` [Comp Lib " " " src" ]
28
- describe " Should Succeed" $
29
- it " successfully parses library section with 2 hs-source-dirs" $
30
- libSection2 ~> parseLib 0
31
- `shouldParse` [Comp Lib " " " src" , Comp Lib " " " src2" ]
32
- describe " Should Succeed" $
33
- it " successfully parses library section with 2 paths under hs-source-dirs" $
34
- libSection3 ~> parseLib 0
35
- `shouldParse` [Comp Lib " " " src" , Comp Lib " " " src2" ]
36
- describe " Should Succeed" $
37
- it " successfully parses bench section" $
38
- do
39
- bs <- T. readFile " test/benchSection"
40
- bs ~> parseBench 0
41
- `shouldParse` [Comp Bench " folds" " benchmarks/folds.hs" ]
42
16
describe " Should Succeed" $
43
17
it " successfully parses package" $
44
18
do
45
19
cf <- T. readFile " implicit-hie.cabal"
46
- cf ~> parsePackage
20
+ parsePackage' cf
47
21
`shouldParse` Package
48
22
" implicit-hie"
49
- [ Comp Lib " " " src " ,
23
+ [ Comp Test " implicit-hie-test " " test/Spec.hs " ,
50
24
Comp Exe " gen-hie" " app/Main.hs" ,
51
- Comp Test " implicit-hie-test" " test"
25
+ Comp Lib " " " src/Hie/Cabal/Parser.hs" ,
26
+ Comp Lib " " " src/Hie/Locate.hs" ,
27
+ Comp Lib " " " src/Hie/Yaml.hs"
52
28
]
53
- describe " Should Succeed" $
54
- it
55
- " skips to end of block section"
56
- $ let r = " test\n "
57
- in (libSection <> r) ~?> parseLib 0
58
- `leavesUnconsumed` r
29
+
59
30
describe " Should Succeed" $
60
31
it " successfully generates stack hie.yaml" $
61
32
do
62
33
sf <- readFile " test/stackHie.yaml"
63
34
cf <- T. readFile " implicit-hie.cabal"
64
- (hieYaml " stack" . fmtPkgs " stack" . (: [] ) <$> parseOnly parsePackage cf)
35
+ (hieYaml " stack" . fmtPkgs " stack" . (: [] ) <$> parsePackage' cf)
65
36
`shouldBe` Right sf
37
+
66
38
describe " Should Succeed" $
67
39
it " successfully generates cabal hie.yaml for haskell-language-server" $
68
40
do
69
41
f <- T. readFile " test/haskell-language-server-cabal"
70
42
o <- readFile " test/hie.yaml.cbl"
71
- (hieYaml " cabal" . fmtPkgs " cabal" . (: [] ) <$> parseOnly parsePackage f)
43
+ (hieYaml " cabal" . fmtPkgs " cabal" . (: [] ) <$> parsePackage' f)
72
44
`shouldBe` Right o
73
- describe " Should Succeed" $
74
- it " successfully parses comma list" $
75
- (" one, two" :: Text ) ~> parseList 1 `shouldParse` [" one" , " two" ]
76
- describe " Should Succeed" $
77
- it " successfully parses newline list" $
78
- (" one\n two \n three3" :: Text ) ~> parseList 1
79
- `shouldParse` [" one" , " two" , " three3" ]
80
- describe " Should Succeed" $
81
- it " successfully parses newline comma list" $
82
- (" one\n two, three3" :: Text ) ~> parseList 1
83
- `shouldParse` [" one" , " two" , " three3" ]
84
- describe " Should Succeed" $
85
- it " quoted list" $
86
- (" \" one\"\n two\n three3" :: Text ) ~> parseList 1
87
- `shouldParse` [" one" , " two" , " three3" ]
88
- describe " Should Succeed" $
89
- it " list with leading commas" $
90
- (" one\n , two\n , three3" :: Text ) ~> parseList 1
91
- `shouldParse` [" one" , " two" , " three3" ]
92
- describe " Should Succeed" $
93
- it " list with a comment" $
94
- (" foo\n -- need to include this too\n bar\n " :: Text ) ~> parseList 1
95
- `shouldParse` [" foo" , " bar" ]
96
- describe " Should Succeed" $
97
- it " list2 with a comment" $
98
- (" foo -- need to include this too\n bar\n " :: Text ) ~> parseList 1
99
- `shouldParse` [" foo" , " bar" ]
100
- describe " Should Succeed" $
101
- it " list3 with a comment" $
102
- (" foo -- need to include this too\n bar" :: Text ) ~> parseList 1
103
- `shouldParse` [" foo" , " bar" ]
104
- describe " Should Succeed" $
105
- it " list4 with a comment" $
106
- (" foo\n bar\n -- need to include this too" :: Text ) ~> parseList 1
107
- `shouldParse` [" foo" , " bar" ]
108
- describe " Should Succeed" $
109
- it " list5 with a comment" $
110
- (" foo\n bar -- need to include this too" :: Text ) ~> parseList 1
111
- `shouldParse` [" foo" , " bar" ]
112
- describe " Should Succeed" $
113
- it " succesfully parses exe component with other-modules containing dots" $
114
- exeSection2 ~> parseExe 0
115
- `shouldParse` [ Comp Exe " gen-hie" " app/Main.hs" ,
116
- Comp Exe " gen-hie" " app/Hie/Executable/Helper.hs" ,
117
- Comp Exe " gen-hie" " app/Hie/Executable/Utils.hs"
118
- ]
119
- describe " Should Succeed" $
120
- it " succesfully parses single other-modules" $
121
- (" other-modules: test\n default-language: Haskell2011" :: Text ) ~?> field 0 " other-modules" parseList
122
- `leavesUnconsumed` " default-language: Haskell2011"
123
- describe " Should Succeed" $
124
- it " succesfully parses empty other-modules1" $
125
- (" other-modules: test\n default-language: Haskell2011" :: Text ) ~?> field 0 " other-modules" parseList
126
- `leavesUnconsumed` " default-language: Haskell2011"
127
- describe " Should Succeed" $
128
- it " succesfully parses empty other-modules2" $
129
- (" other-modules: \n build-depends:\n base >=4.9 && <5" :: Text ) ~> field 0 " other-modules" parseList
130
- `shouldParse` []
131
-
132
- exeSection :: Text
133
- exeSection =
134
- " executable gen-hie\n \
135
- \ other-modules:\n \
136
- \ Paths_implicit_hie\n \
137
- \ autogen-modules:\n \
138
- \ Paths_implicit_hie\n \
139
- \ hs-source-dirs:\n \
140
- \ app\n \
141
- \ ghc-options: -O2\n \
142
- \ main-is: Main.hs \n "
143
-
144
- testSection :: Text
145
- testSection =
146
- " test-suite implicit-hie-test\n \
147
- \ type: exitcode-stdio-1.0\n \
148
- \ other-modules:\n \
149
- \ Paths_implicit_hie\n \
150
- \ hs-source-dirs:\n \
151
- \ test\n \
152
- \ ghc-options: -fspecialize-aggressively -Wall -Wincomplete-record-updates -Wincomplete-uni-patterns -fno-warn-unused-imports -fno-warn-unused-binds -fno-warn-name-shadowing -fwarn-redundant-constraints -threaded -rtsopts -with-rtsopts=-N\n \
153
- \ main-is: Spec.hs\n \
154
- \ build-depends:\n \
155
- \ attoparsec\n \
156
- \ , base >=4.7 && <5\n \
157
- \ , hspec\n \
158
- \ , hspec-attoparsec\n \
159
- \ , implicit-hie\n \
160
- \ , text\n \
161
- \ default-language: Haskell2010\n "
162
-
163
- libSection :: Text
164
- libSection =
165
- " library\n \
166
- \ exposed-modules:\n \
167
- \ Lib\n \
168
- \ other-modules:\n \
169
- \ Paths_implicit_hie\n \
170
- \ hs-source-dirs:\n \
171
- \ src\n \
172
- \ ghc-options: -fspecialize-aggressively -Wall -Wincomplete-record-updates -Wincomplete-uni-patterns -fno-warn-unused-imports -fno-warn-unused-binds -fno-warn-name-shadowing -fwarn-redundant-constraints\n \
173
- \ build-depends:\n \
174
- \ attoparsec\n \
175
- \ , base >=4.7 && <5\n \
176
- \ , text\n \
177
- \ default-language: Haskell2010\n \
178
- \"
179
-
180
- libSection2 :: Text
181
- libSection2 =
182
- " library\n \
183
- \ exposed-modules:\n \
184
- \ Lib\n \
185
- \ other-modules:\n \
186
- \ Paths_implicit_hie\n \
187
- \ hs-source-dirs:\n \
188
- \ src\n \
189
- \ hs-source-dirs:\n \
190
- \ src2\n \
191
- \ ghc-options: -fspecialize-aggressively -Wall -Wincomplete-record-updates -Wincomplete-uni-patterns -fno-warn-unused-imports -fno-warn-unused-binds -fno-warn-name-shadowing -fwarn-redundant-constraints\n \
192
- \ build-depends:\n \
193
- \ attoparsec\n \
194
- \ , base >=4.7 && <5\n \
195
- \ , text\n \
196
- \ default-language: Haskell2010\n \
197
- \"
198
-
199
- libSection3 :: Text
200
- libSection3 =
201
- " library\n \
202
- \ exposed-modules:\n \
203
- \ Lib\n \
204
- \ other-modules:\n \
205
- \ Paths_implicit_hie\n \
206
- \ hs-source-dirs:\n \
207
- \ src,\n \
208
- \ src2\n \
209
- \ ghc-options: -fspecialize-aggressively -Wall -Wincomplete-record-updates -Wincomplete-uni-patterns -fno-warn-unused-imports -fno-warn-unused-binds -fno-warn-name-shadowing -fwarn-redundant-constraints\n \
210
- \ build-depends:\n \
211
- \ attoparsec\n \
212
- \ , base >=4.7 && <5\n \
213
- \ , text\n \
214
- \ default-language: Haskell2010\n \
215
- \"
216
-
217
- exeSection2 :: Text
218
- exeSection2 =
219
- " executable gen-hie\n \
220
- \ other-modules:\n \
221
- \ Hie.Executable.Helper\n \
222
- \ Hie.Executable.Utils\n \
223
- \ hs-source-dirs:\n \
224
- \ app\n \
225
- \ main-is: Main.hs \n "
0 commit comments