From d029f1700effa626ff622700b198ed49ee8b6c19 Mon Sep 17 00:00:00 2001 From: Ben Gamari <ben@smart-cactus.org> Date: Thu, 3 Oct 2024 17:31:55 -0400 Subject: [PATCH] testsuite: Normalise trailing digits from hole fits output The type variables in the holes fit output from `abstract_refinement_hole_fits` is quite sensitive to compiler configuration. Specifically, a slight change in the inlining behavior of `throw` changes type variable naming in `(>>=)` and a few others. Ideally we would make hole fits output more deterministic but in the meantime we simply normalise this difference away as it not relevant to the test's goal. --- testsuite/tests/typecheck/should_compile/all.T | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/testsuite/tests/typecheck/should_compile/all.T b/testsuite/tests/typecheck/should_compile/all.T index 5c3e1878a36..5057c4d7e4d 100644 --- a/testsuite/tests/typecheck/should_compile/all.T +++ b/testsuite/tests/typecheck/should_compile/all.T @@ -1,8 +1,17 @@ +import re + # Args to vtc are: extra compile flags def f( name, opts ): opts.extra_hc_opts = '-fno-warn-incomplete-patterns' +def normalise_type_vars(s): + """ + Normalise away the trailing digits from type variable OccNames + in hole fits error messages as these tend to be non-deterministic. + """ + return re.sub(r'([a-z])[0-9]+', r'\1', s) + setTestOpts(f) test('tc001', normal, compile, ['']) @@ -392,7 +401,7 @@ test('local_hole_fits', normal, compile, ['-fdefer-type-errors -fno-max-valid-ho test('subsumption_sort_hole_fits', normalise_version('ghc-internal', 'base'), compile, ['-fdefer-type-errors -fno-max-valid-hole-fits -fsort-by-subsumption-hole-fits']) test('valid_hole_fits_interactions', normal, compile, ['-fdefer-type-errors -fno-max-valid-hole-fits']) test('refinement_hole_fits', normal, compile, ['-fdefer-type-errors -fno-max-valid-hole-fits -fno-max-refinement-hole-fits -frefinement-level-hole-fits=2']) -test('abstract_refinement_hole_fits', normal, compile, ['-fdefer-type-errors -fno-max-valid-hole-fits -fno-max-refinement-hole-fits -frefinement-level-hole-fits=2 -fabstract-refinement-hole-fits -funclutter-valid-hole-fits']) +test('abstract_refinement_hole_fits', normalise_errmsg_fun(normalise_type_vars), compile, ['-fdefer-type-errors -fno-max-valid-hole-fits -fno-max-refinement-hole-fits -frefinement-level-hole-fits=2 -fabstract-refinement-hole-fits -funclutter-valid-hole-fits']) test('free_monad_hole_fits', normal, compile, ['-fdefer-type-errors -fno-max-valid-hole-fits -fno-max-refinement-hole-fits -frefinement-level-hole-fits=2 -funclutter-valid-hole-fits']) test('constraint_hole_fits', normal, compile, ['-fdefer-type-errors -fno-max-valid-hole-fits -fno-max-refinement-hole-fits -frefinement-level-hole-fits=2 -funclutter-valid-hole-fits']) test('type_in_type_hole_fits', normal, compile, ['-fdefer-type-errors -fno-max-valid-hole-fits']) -- GitLab