Skip to content

Commit da337bc

Browse files
authored
Set test options via cabal.project (#4039)
* Set test options via cabal.project This means we can set the default properly for people using the project, and also set things more simply in the test workflow. * Set options after testing hls-graph * Revert "Set options after testing hls-graph" This reverts commit 73fa801. * Quote filters * Use cabal configure instead * Try better
1 parent 71bd04b commit da337bc

File tree

3 files changed

+39
-39
lines changed

3 files changed

+39
-39
lines changed

.github/workflows/test.yml

+33-37
Original file line numberDiff line numberDiff line change
@@ -104,151 +104,147 @@ jobs:
104104
run: cabal build
105105

106106
- name: Set test options
107-
# run the tests without parallelism, otherwise tasty will attempt to run
108-
# all functional test cases simultaneously which causes way too many hls
109-
# instances to be spun up for the poor github actions runner to handle
110-
#
111107
# See https://github.com/ocharles/tasty-rerun/issues/22 for why we need
112108
# to include 'new' in the filters, since many of our test suites are in the
113109
# same package.
114110
run: |
115-
echo "TEST_OPTS=-j1 --rerun-update --rerun-filter failures,exceptions,new" >> $GITHUB_ENV
111+
cabal configure --test-options="--rerun-update --rerun-filter failures,exceptions,new"
116112
117113
- if: matrix.test
118114
name: Test hls-graph
119-
run: cabal test hls-graph --test-options="$TEST_OPTS"
115+
run: cabal test hls-graph
120116

121117
- if: needs.pre_job.outputs.should_skip_ghcide != 'true' && matrix.test
122118
name: Test ghcide
123119
# run the tests without parallelism to avoid running out of memory
124-
run: cabal test ghcide --test-options="$TEST_OPTS" || cabal test ghcide --test-options="$TEST_OPTS"
120+
run: cabal test ghcide || cabal test ghcide
125121

126122
- if: matrix.test
127123
name: Test hls-plugin-api
128-
run: cabal test hls-plugin-api --test-options="$TEST_OPTS" || cabal test hls-plugin-api --test-options="$TEST_OPTS"
124+
run: cabal test hls-plugin-api || cabal test hls-plugin-api
129125

130126
- if: matrix.test
131127
name: Test func-test suite
132128
env:
133129
HLS_TEST_EXE: hls
134130
HLS_WRAPPER_TEST_EXE: hls-wrapper
135-
run: cabal test func-test --test-options="$TEST_OPTS" || cabal test func-test --test-options="$TEST_OPTS"
131+
run: cabal test func-test || cabal test func-test
136132

137133
- if: matrix.test
138134
name: Test wrapper-test suite
139135
env:
140136
HLS_TEST_EXE: hls
141137
HLS_WRAPPER_TEST_EXE: hls-wrapper
142-
run: cabal test wrapper-test --test-options="$TEST_OPTS --rerun-log-file .tasty-rerun-log-wrapper"
138+
run: cabal test wrapper-test
143139

144140
- if: matrix.test
145141
name: Test hls-refactor-plugin
146-
run: cabal test hls-refactor-plugin-tests --test-options="$TEST_OPTS" || cabal test hls-refactor-plugin-tests --test-options="$TEST_OPTS"
142+
run: cabal test hls-refactor-plugin-tests || cabal test hls-refactor-plugin-tests
147143

148144
- if: matrix.test
149145
name: Test hls-floskell-plugin
150-
run: cabal test hls-floskell-plugin-tests --test-options="$TEST_OPTS" || cabal test hls-floskell-plugin-tests --test-options="$TEST_OPTS"
146+
run: cabal test hls-floskell-plugin-tests || cabal test hls-floskell-plugin-tests
151147

152148
- if: matrix.test
153149
name: Test hls-class-plugin
154-
run: cabal test hls-class-plugin-tests --test-options="$TEST_OPTS" || cabal test hls-class-plugin-tests --test-options="$TEST_OPTS"
150+
run: cabal test hls-class-plugin-tests || cabal test hls-class-plugin-tests
155151

156152
- if: matrix.test
157153
name: Test hls-pragmas-plugin
158-
run: cabal test hls-pragmas-plugin-tests --test-options="$TEST_OPTS" || cabal test hls-pragmas-plugin-tests --test-options="$TEST_OPTS"
154+
run: cabal test hls-pragmas-plugin-tests || cabal test hls-pragmas-plugin-tests
159155

160156
- if: matrix.test
161157
name: Test hls-eval-plugin
162-
run: cabal test hls-eval-plugin-tests --test-options="$TEST_OPTS" || cabal test hls-eval-plugin-tests --test-options="$TEST_OPTS"
158+
run: cabal test hls-eval-plugin-tests || cabal test hls-eval-plugin-tests
163159

164160
- if: matrix.test
165161
name: Test hls-splice-plugin
166-
run: cabal test hls-splice-plugin-tests --test-options="$TEST_OPTS" || cabal test hls-splice-plugin-tests --test-options="$TEST_OPTS"
162+
run: cabal test hls-splice-plugin-tests || cabal test hls-splice-plugin-tests
167163

168164
- if: matrix.test && matrix.ghc != '9.2'
169165
name: Test hls-stan-plugin
170-
run: cabal test hls-stan-plugin-tests --test-options="$TEST_OPTS" || cabal test hls-stan-plugin-tests --test-options="$TEST_OPTS"
166+
run: cabal test hls-stan-plugin-tests || cabal test hls-stan-plugin-tests
171167

172168
- if: matrix.test
173169
name: Test hls-stylish-haskell-plugin
174-
run: cabal test hls-stylish-haskell-plugin-tests --test-options="$TEST_OPTS" || cabal test hls-stylish-haskell-plugin-tests --test-options="$TEST_OPTS"
170+
run: cabal test hls-stylish-haskell-plugin-tests || cabal test hls-stylish-haskell-plugin-tests
175171

176172
- if: matrix.test
177173
name: Test hls-ormolu-plugin
178-
run: cabal test hls-ormolu-plugin-tests --test-options="$TEST_OPTS" || cabal test hls-ormolu-plugin-tests --test-options="$TEST_OPTS"
174+
run: cabal test hls-ormolu-plugin-tests || cabal test hls-ormolu-plugin-tests
179175

180176
- if: matrix.test
181177
name: Test hls-fourmolu-plugin
182-
run: cabal test hls-fourmolu-plugin-tests --test-options="$TEST_OPTS" || cabal test hls-fourmolu-plugin-tests --test-options="$TEST_OPTS"
178+
run: cabal test hls-fourmolu-plugin-tests || cabal test hls-fourmolu-plugin-tests
183179

184180
- if: matrix.test
185181
name: Test hls-explicit-imports-plugin test suite
186-
run: cabal test hls-explicit-imports-plugin-tests --test-options="$TEST_OPTS" || cabal test hls-explicit-imports-plugin-tests --test-options="$TEST_OPTS"
182+
run: cabal test hls-explicit-imports-plugin-tests || cabal test hls-explicit-imports-plugin-tests
187183

188184
- if: matrix.test
189185
name: Test hls-call-hierarchy-plugin test suite
190-
run: cabal test hls-call-hierarchy-plugin-tests --test-options="$TEST_OPTS" || cabal test hls-call-hierarchy-plugin-tests --test-options="$TEST_OPTS"
186+
run: cabal test hls-call-hierarchy-plugin-tests || cabal test hls-call-hierarchy-plugin-tests
191187

192188
- if: matrix.test && matrix.os != 'windows-latest'
193189
name: Test hls-rename-plugin test suite
194-
run: cabal test hls-rename-plugin-tests --test-options="$TEST_OPTS" || cabal test hls-rename-plugin-tests --test-options="$TEST_OPTS"
190+
run: cabal test hls-rename-plugin-tests || cabal test hls-rename-plugin-tests
195191

196192
- if: matrix.test
197193
name: Test hls-hlint-plugin test suite
198-
run: cabal test hls-hlint-plugin-tests --test-options="$TEST_OPTS" || cabal test hls-hlint-plugin-tests --test-options="$TEST_OPTS"
194+
run: cabal test hls-hlint-plugin-tests || cabal test hls-hlint-plugin-tests
199195

200196
- if: matrix.test
201197
name: Test hls-module-name-plugin test suite
202-
run: cabal test hls-module-name-plugin-tests --test-options="$TEST_OPTS" || cabal test hls-module-name-plugin-tests --test-options="$TEST_OPTS"
198+
run: cabal test hls-module-name-plugin-tests || cabal test hls-module-name-plugin-tests
203199

204200
- if: matrix.test
205201
name: Test hls-alternate-number-format-plugin test suite
206-
run: cabal test hls-alternate-number-format-plugin-tests --test-options="$TEST_OPTS" || cabal test hls-alternate-number-format-plugin-tests --test-options="$TEST_OPTS"
202+
run: cabal test hls-alternate-number-format-plugin-tests || cabal test hls-alternate-number-format-plugin-tests
207203

208204
- if: matrix.test
209205
name: Test hls-qualify-imported-names-plugin test suite
210-
run: cabal test hls-qualify-imported-names-plugin-tests --test-options="$TEST_OPTS" || cabal test hls-qualify-imported-names-plugin-tests --test-options="$TEST_OPTS"
206+
run: cabal test hls-qualify-imported-names-plugin-tests || cabal test hls-qualify-imported-names-plugin-tests
211207

212208
- if: matrix.test
213209
name: Test hls-code-range-plugin test suite
214-
run: cabal test hls-code-range-plugin-tests --test-options="$TEST_OPTS" || cabal test hls-code-range-plugin-tests --test-options="$TEST_OPTS"
210+
run: cabal test hls-code-range-plugin-tests || cabal test hls-code-range-plugin-tests
215211

216212
- if: matrix.test
217213
name: Test hls-change-type-signature test suite
218-
run: cabal test hls-change-type-signature-plugin-tests --test-options="$TEST_OPTS" || cabal test hls-change-type-signature-plugin-tests --test-options="$TEST_OPTS"
214+
run: cabal test hls-change-type-signature-plugin-tests || cabal test hls-change-type-signature-plugin-tests
219215

220216
- if: matrix.test
221217
name: Test hls-gadt-plugin test suit
222-
run: cabal test hls-gadt-plugin-tests --test-options="$TEST_OPTS" || cabal test hls-gadt-plugin-tests --test-options="$TEST_OPTS"
218+
run: cabal test hls-gadt-plugin-tests || cabal test hls-gadt-plugin-tests
223219

224220
- if: matrix.test
225221
name: Test hls-explicit-fixity-plugin test suite
226-
run: cabal test hls-explicit-fixity-plugin-tests --test-options="$TEST_OPTS" || cabal test hls-explicit-fixity-plugin-tests --test-options="$TEST_OPTS"
222+
run: cabal test hls-explicit-fixity-plugin-tests || cabal test hls-explicit-fixity-plugin-tests
227223

228224
- if: matrix.test
229225
name: Test hls-explicit-record-fields-plugin test suite
230-
run: cabal test hls-explicit-record-fields-plugin-tests --test-options="$TEST_OPTS" || cabal test hls-explicit-record-fields-plugin-tests --test-options="$TEST_OPTS"
226+
run: cabal test hls-explicit-record-fields-plugin-tests || cabal test hls-explicit-record-fields-plugin-tests
231227

232228
## version needs to be limited since the tests depend on cabal-fmt which only builds using specific ghc versions
233229
- if: matrix.test && matrix.ghc == '9.2'
234230
name: Test hls-cabal-fmt-plugin test suite
235-
run: cabal test hls-cabal-fmt-plugin-tests --flag=isolateCabalfmtTests --test-options="$TEST_OPTS" || cabal test hls-cabal-fmt-plugin-tests --flag=isolateCabalfmtTests --test-options="$TEST_OPTS"
231+
run: cabal test hls-cabal-fmt-plugin-tests --flag=isolateCabalfmtTests || cabal test hls-cabal-fmt-plugin-tests --flag=isolateCabalfmtTests
236232

237233
- if: matrix.test
238234
name: Test hls-cabal-plugin test suite
239-
run: cabal test hls-cabal-plugin-tests --test-options="$TEST_OPTS" || cabal test hls-cabal-plugin-tests --test-options="$TEST_OPTS"
235+
run: cabal test hls-cabal-plugin-tests || cabal test hls-cabal-plugin-tests
240236

241237
- if: matrix.test
242238
name: Test hls-retrie-plugin test suite
243-
run: cabal test hls-retrie-plugin-tests --test-options="$TEST_OPTS" || cabal test hls-retrie-plugin-tests --test-options="$TEST_OPTS"
239+
run: cabal test hls-retrie-plugin-tests || cabal test hls-retrie-plugin-tests
244240

245241
- if: matrix.test
246242
name: Test hls-overloaded-record-dot-plugin test suite
247-
run: cabal test hls-overloaded-record-dot-plugin-tests --test-options="$TEST_OPTS" || LSP_TEST_LOG_COLOR=0 LSP_TEST_LOG_MESSAGES=true LSP_TEST_LOG_STDERR=true cabal test hls-overloaded-record-dot-plugin-tests --test-options="$TEST_OPTS"
243+
run: cabal test hls-overloaded-record-dot-plugin-tests || cabal test hls-overloaded-record-dot-plugin-tests
248244

249245
- if: matrix.test
250246
name: Test hls-semantic-tokens-plugin test suite
251-
run: cabal test hls-semantic-tokens-plugin-tests --test-options="$TEST_OPTS" || cabal test hls-semantic-tokens-plugin-tests --test-options="$TEST_OPTS"
247+
run: cabal test hls-semantic-tokens-plugin-tests || cabal test hls-semantic-tokens-plugin-tests
252248

253249

254250
test_post_job:

cabal.project

+5
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ benchmarks: True
1818

1919
write-ghc-environment-files: never
2020

21+
-- Many of our tests only work single-threaded, and the only way to
22+
-- ensure tasty runs everything purely single-threaded is to pass
23+
-- this at the top-level
24+
test-options: -j1
25+
2126
-- Make sure dependencies are build with haddock so we get
2227
-- haddock shown on hover
2328
package *

hls-test-utils/src/Test/Hls.hs

+1-2
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ import Test.Tasty.ExpectedFailure
122122
import Test.Tasty.Golden
123123
import Test.Tasty.HUnit
124124
import Test.Tasty.Ingredients.Rerun
125-
import Test.Tasty.Runners (NumThreads (..))
126125

127126
data Log
128127
= LogIDEMain IDEMain.Log
@@ -147,7 +146,7 @@ instance Pretty LogTestHarness where
147146

148147
-- | Run 'defaultMainWithRerun', limiting each single test case running at most 10 minutes
149148
defaultTestRunner :: TestTree -> IO ()
150-
defaultTestRunner = defaultMainWithRerun . adjustOption (const $ NumThreads 1) . adjustOption (const $ mkTimeout 600000000)
149+
defaultTestRunner = defaultMainWithRerun . adjustOption (const $ mkTimeout 600000000)
151150

152151
gitDiff :: FilePath -> FilePath -> [String]
153152
gitDiff fRef fNew = ["git", "-c", "core.fileMode=false", "diff", "--no-index", "--text", "--exit-code", fRef, fNew]

0 commit comments

Comments
 (0)