Commit 28bbdbb2 authored by Ian Lynagh's avatar Ian Lynagh
Browse files

Make ghci024 a lot less fragile

Now we grep for representative output, rather than trying to match all of it.
parent a80b936b
TOP=../../../.. TOP=../../../..
include $(TOP)/mk/boilerplate.mk include $(TOP)/mk/boilerplate.mk
include $(TOP)/mk/test.mk include $(TOP)/mk/test.mk
ghci024:
@echo "~~~~~~~~~~ Testing :set"
printf ":set\n" \
| $(TEST_HC) --interactive -v0 \
| grep -E "^([^ ]| -fno-print-explicit-foralls| -fno-warn-implicit-prelude)"
@echo "~~~~~~~~~~ Testing :show languages"
printf ":show languages\n" \
| $(TEST_HC) --interactive -v0 \
| grep -E "^([^ ]| -XImplicitPrelude| -XMagicHash)"
@echo "~~~~~~~~~~ Testing :show languages, with -fglasgow-exts"
printf ":set -fglasgow-exts\n:show languages\n" \
| $(TEST_HC) --interactive -v0 \
| grep -E "^([^ ]| -XImplicitPrelude| -XMagicHash)"
@echo "~~~~~~~~~~ Testing :show packages"
printf ":show packages\n" \
| $(TEST_HC) --interactive -v0 \
| grep -E "^([^ ]| -package|base|ghc-prim|integer|rts|Cabal)" \
| sed "s/Cabal-[0-9.]*/Cabal-VERSION/"
@echo "~~~~~~~~~~ Testing :show packages, including the ghc package"
printf ":set -package ghc\n:show packages\n" \
| $(TEST_HC) --interactive -v0 \
| grep -E "^([^ ]| -package|base|ghc-prim|integer|rts|Cabal)" \
| sed "s/Cabal-[0-9.]*/Cabal-VERSION/"
...@@ -32,14 +32,11 @@ test('ghci021', normal, ghci_script, ['ghci021.script']) ...@@ -32,14 +32,11 @@ test('ghci021', normal, ghci_script, ['ghci021.script'])
test('ghci022', normal, ghci_script, ['ghci022.script']) test('ghci022', normal, ghci_script, ['ghci022.script'])
test('ghci023', normal, ghci_script, ['ghci023.script']) test('ghci023', normal, ghci_script, ['ghci023.script'])
execfile(in_testdir('ghci024.py')) # load function prepare024
test('ghci024', test('ghci024',
[prepare024, [skip_if_fast,
skip_if_fast, if_platform("powerpc-apple-darwin", expect_broken(1845))],
if_platform("powerpc-apple-darwin", expect_broken(1845)), run_command,
extra_clean(['ghci024.stdout'])], ['$MAKE -s --no-print-directory ghci024'])
ghci_script,
['ghci024.script'])
test('ghci025', normal, ghci_script, ['ghci025.script']) test('ghci025', normal, ghci_script, ['ghci025.script'])
test('ghci026', normal, ghci_script, ['ghci026.script']) test('ghci026', normal, ghci_script, ['ghci026.script'])
......
import os
import re
# prepare version-/platform-specific ghci024.stdout
# - listen to ghci -package ghc, to figure out package ghc contents for :show packages
# - change flag defaults according to platform (unregistered -> -fno-asm-mangling)
# - prepare separate flag lists for 6.9 or earlier
# (please make sure to add your flags to the right section!)
#
def prepare024( opts ):
h = os.popen('echo :q | '+config.compiler+' --interactive -package ghc ')
packages = h.read()
h.close()
packagelist = []
for l in packages.splitlines():
if re.match('^Loading package',l):
packagelist += [re.sub(r'^Loading package (\S*) .*$',r'\1',l)]
packagelist += ['rts']
packagelist.sort()
if config.unregisterised :
mangling = 'no-'
else:
mangling = ''
if version_lt(config.compiler_version, '6.9') :
outtext = """\
-- ghci024.stdout is a generated file! please edit ghci024.py instead.
options currently set: none.
GHCi-specific dynamic flag settings:
-fno-print-explicit-foralls
-fprint-bind-result
-fno-break-on-exception
-fno-break-on-error
-fno-print-evld-with-show
other dynamic, non-language, flag settings:
-fno-warn-dodgy-imports
-fwarn-duplicate-exports
-fno-warn-hi-shadowing
-fno-warn-implicit-prelude
-fno-warn-incomplete-patterns
-fno-warn-incomplete-record-updates
-fwarn-missing-fields
-fwarn-missing-methods
-fno-warn-missing-signatures
-fno-warn-name-shadowing
-fwarn-overlapping-patterns
-fno-warn-simple-patterns
-fno-warn-type-defaults
-fno-warn-monomorphism-restriction
-fno-warn-unused-binds
-fno-warn-unused-imports
-fno-warn-unused-matches
-fwarn-deprecations
-fno-warn-orphans
-fno-warn-tabs
-fno-strictness
-fno-full-laziness
-fno-liberate-case
-fno-spec-constr
-fno-cse
-fignore-interface-pragmas
-fomit-interface-pragmas
-fdo-lambda-eta-expansion
-fno-ignore-asserts
-fno-ignore-breakpoints
-fno-do-eta-reduction
-fno-case-merge
-fno-unbox-strict-fields
-fno-dicts-cheap
-fno-excess-precision
-f%(mangling)sasm-mangling
-fno-force-recomp
-fno-hpc-no-auto
-fno-rewrite-rules
-fprint-bind-contents
-fno-vectorise
-fno-regs-graph
-fno-regs-iterative
-fgen-manifest
-fembed-manifest
-fimplicit-import-qualified
active language flags:
-XImplicitPrelude
-XMonomorphismRestriction
-XMonoPatBinds
-- :set -fglasgow-exts
active language flags:
-XPatternGuards
-XUnicodeSyntax
-XMagicHash
-XPolymorphicComponents
-XExistentialQuantification
-XKindSignatures
-XPatternSignatures
-XEmptyDataDecls
-XParallelListComp
-XForeignFunctionInterface
-XUnliftedFFITypes
-XLiberalTypeSynonyms
-XRankNTypes
-XTypeOperators
-XRecursiveDo
-XImplicitPrelude
-XGADTs
-XTypeFamilies
-XMonomorphismRestriction
-XMonoPatBinds
-XRelaxedPolyRec
-XImplicitParams
-XScopedTypeVariables
-XUnboxedTuples
-XStandaloneDeriving
-XDeriveDataTypeable
-XTypeSynonymInstances
-XFlexibleContexts
-XFlexibleInstances
-XConstrainedClassMethods
-XMultiParamTypeClasses
-XFunctionalDependencies
-XGeneralizedNewtypeDeriving
active package flags: none
packages currently loaded:
base
rts
-- :set -package ghc
active package flags:
-package ghc
packages currently loaded:
"""%{'mangling': mangling}
else:
outtext = """\
-- ghci024.stdout is a generated file! please edit ghci024.py instead.
options currently set: none.
GHCi-specific dynamic flag settings:
-fno-print-explicit-foralls
-fno-print-bind-result
-fno-break-on-exception
-fno-break-on-error
-fno-print-evld-with-show
other dynamic, non-language, flag settings:
-fwarn-dodgy-foreign-imports
-fno-warn-dodgy-imports
-fwarn-duplicate-exports
-fno-warn-hi-shadowing
-fno-warn-implicit-prelude
-fno-warn-incomplete-patterns
-fno-warn-incomplete-record-updates
-fwarn-missing-fields
-fwarn-missing-methods
-fno-warn-missing-signatures
-fno-warn-name-shadowing
-fwarn-overlapping-patterns
-fno-warn-simple-patterns
-fno-warn-type-defaults
-fno-warn-monomorphism-restriction
-fno-warn-unused-binds
-fno-warn-unused-imports
-fno-warn-unused-matches
-fwarn-warnings-deprecations
-fwarn-deprecations
-fwarn-deprecated-flags
-fno-warn-orphans
-fno-warn-tabs
-fwarn-unrecognised-pragmas
-fno-strictness
-fno-static-argument-transformation
-fno-full-laziness
-fno-liberate-case
-fno-spec-constr
-fno-cse
-fignore-interface-pragmas
-fomit-interface-pragmas
-fdo-lambda-eta-expansion
-fno-ignore-asserts
-fno-do-eta-reduction
-fno-case-merge
-fno-unbox-strict-fields
-fmethod-sharing
-fno-dicts-cheap
-fno-excess-precision
-f%(mangling)sasm-mangling
-fno-force-recomp
-fno-hpc-no-auto
-fno-rewrite-rules
-fno-enable-rewrite-rules
-fprint-bind-contents
-fno-run-cps
-fno-convert-to-zipper-and-back
-fno-vectorise
-fno-regs-graph
-fno-regs-iterative
-fgen-manifest
-fembed-manifest
-fimplicit-import-qualified
active language flags:
-XImplicitPrelude
-XMonomorphismRestriction
-XMonoPatBinds
-- :set -fglasgow-exts
active language flags:
-XPostfixOperators
-XPatternGuards
-XUnicodeSyntax
-XMagicHash
-XPolymorphicComponents
-XExistentialQuantification
-XKindSignatures
-XEmptyDataDecls
-XParallelListComp
-XForeignFunctionInterface
-XUnliftedFFITypes
-XLiberalTypeSynonyms
-XRankNTypes
-XImpredicativeTypes
-XTypeOperators
-XRecursiveDo
-XImplicitPrelude
-XGADTs
-XTypeFamilies
-XMonomorphismRestriction
-XMonoPatBinds
-XRelaxedPolyRec
-XImplicitParams
-XScopedTypeVariables
-XPatternSignatures
-XUnboxedTuples
-XStandaloneDeriving
-XDeriveDataTypeable
-XTypeSynonymInstances
-XFlexibleContexts
-XFlexibleInstances
-XConstrainedClassMethods
-XMultiParamTypeClasses
-XFunctionalDependencies
-XGeneralizedNewtypeDeriving
active package flags: none
packages currently loaded:
base
ghc-prim
integer
rts
-- :set -package ghc
active package flags:
-package ghc
packages currently loaded:
"""%{'mangling': mangling}
outfile = open(in_testdir('ghci024.stdout'), 'w')
outfile.write(outtext)
for l in packagelist: outfile.write(' '+l+'\n')
outfile.close()
return;
~~~~~~~~~~ Testing :set
options currently set: none.
GHCi-specific dynamic flag settings:
-fno-print-explicit-foralls
other dynamic, non-language, flag settings:
-fno-warn-implicit-prelude
~~~~~~~~~~ Testing :show languages
active language flags:
-XImplicitPrelude
~~~~~~~~~~ Testing :show languages, with -fglasgow-exts
active language flags:
-XMagicHash
-XImplicitPrelude
~~~~~~~~~~ Testing :show packages
active package flags: none
packages currently loaded:
~~~~~~~~~~ Testing :show packages, including the ghc package
active package flags:
-package ghc
packages currently loaded:
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment