Hannes Siebenhandl pushed to branch wip/fendor/hpc-bc-support at Glasgow Haskell Compiler / GHC Commits: 7f2d3236 by fendor at 2026-04-10T14:24:13+02:00 Add more tests for ghci and -fhpc - - - - - 23 changed files: - testsuite/tests/hpc/Makefile - testsuite/tests/hpc/T17073.stdout → testsuite/tests/hpc/T17073a.stdout - + testsuite/tests/hpc/T17073b.stdout - testsuite/tests/hpc/T20568.stdout → testsuite/tests/hpc/T20568a.stdout - + testsuite/tests/hpc/T20568b.stdout - testsuite/tests/hpc/all.T - testsuite/tests/hpc/fork/Makefile - testsuite/tests/hpc/function/Makefile - testsuite/tests/hpc/function/test.T - + testsuite/tests/hpc/function/tough1.stderr - + testsuite/tests/hpc/function/tough1.stdout - testsuite/tests/hpc/function2/test.T - + testsuite/tests/hpc/function2/tough3.script - testsuite/tests/hpc/ghc_ghci/Makefile - testsuite/tests/hpc/hpcrun.pl - testsuite/tests/hpc/simple/Makefile - + testsuite/tests/hpc/simple/hpc002.hs - + testsuite/tests/hpc/simple/hpc002.stdout - + testsuite/tests/hpc/simple/hpc003.hs - + testsuite/tests/hpc/simple/hpc003.script - + testsuite/tests/hpc/simple/hpc003.stderr - + testsuite/tests/hpc/simple/hpc003.stdout - testsuite/tests/hpc/simple/test.T Changes: ===================================== testsuite/tests/hpc/Makefile ===================================== @@ -1,4 +1,4 @@ -TOP=../.. +TOP=/home/hugin/Documents/haskell/ghc-hpc-bc/testsuite include $(TOP)/mk/boilerplate.mk include $(TOP)/mk/test.mk @@ -8,13 +8,22 @@ T11798: "$(TEST_HC)" $(TEST_HC_ARGS) T11798 -fhpc test -e .hpc/T11798.mix -T17073: +T17073a: LANG=ASCII "$(TEST_HC)" $(TEST_HC_ARGS) T17073.hs -fhpc -v0 ./T17073 "$(HPC)" report T17073 "$(HPC)" version LANG=ASCII "$(HPC)" markup T17073 -T20568: +T17073b: + HPCTIXFILE=ghc.tix "$(TEST_HC)" $(TEST_HC_OPTS_INTERACTIVE) $(TEST_HC_ARGS) T17073.hs -fhpc -v0 -e ":main" + "$(HPC)" report ghc + "$(HPC)" version + LANG=ASCII "$(HPC)" markup ghc + +T20568a: "$(TEST_HC)" $(TEST_HC_ARGS) T20568.hs -fhpc -v0 ./T20568 + +T20568b: + HPCTIXFILE=ghc.tix "$(TEST_HC)" $(TEST_HC_OPTS_INTERACTIVE) $(TEST_HC_ARGS) T20568.hs -fhpc -v0 -e ":main" ===================================== testsuite/tests/hpc/T17073.stdout → testsuite/tests/hpc/T17073a.stdout ===================================== @@ -12,4 +12,4 @@ Writing: Main.hs.html Writing: hpc_index.html Writing: hpc_index_fun.html Writing: hpc_index_alt.html -Writing: hpc_index_exp.html \ No newline at end of file +Writing: hpc_index_exp.html ===================================== testsuite/tests/hpc/T17073b.stdout ===================================== @@ -0,0 +1,15 @@ +Добрый день +100% expressions used (2/2) +100% boolean coverage (0/0) + 100% guards (0/0) + 100% 'if' conditions (0/0) + 100% qualifiers (0/0) +100% alternatives used (0/0) +100% local declarations used (0/0) +100% top-level declarations used (1/1) +hpc tools, version 0.69 +Writing: Main.hs.html +Writing: hpc_index.html +Writing: hpc_index_fun.html +Writing: hpc_index_alt.html +Writing: hpc_index_exp.html ===================================== testsuite/tests/hpc/T20568.stdout → testsuite/tests/hpc/T20568a.stdout ===================================== ===================================== testsuite/tests/hpc/T20568b.stdout ===================================== @@ -0,0 +1 @@ +IfThenElse (AstBool True) (AstInt 1) (AstInt 2) ===================================== testsuite/tests/hpc/all.T ===================================== @@ -23,7 +23,10 @@ test('T2991', [cmd_wrapper(T2991)], # Run with 'ghc --main'. Do not list other modules explicitly. multimod_compile_and_run, ['T2991', '']) -test('T17073', when(opsys('mingw32'), expect_broken(17607)), - makefile_test, ['T17073 HPC={hpc}']) +test('T17073a', [when(opsys('mingw32'), expect_broken(17607)), extra_files(['T17073.hs'])], + makefile_test, ['T17073a HPC={hpc}']) +test('T17073b', [when(opsys('mingw32'), expect_broken(17607)), extra_files(['T17073.hs'])], + makefile_test, ['T17073b HPC={hpc}']) -test('T20568', normal, makefile_test, []) +test('T20568a', [extra_files(['T20568.hs'])], makefile_test, []) +test('T20568b', [extra_files(['T20568.hs'])], makefile_test, []) ===================================== testsuite/tests/hpc/fork/Makefile ===================================== @@ -1,4 +1,3 @@ TOP=../../.. include $(TOP)/mk/boilerplate.mk include $(TOP)/mk/test.mk - ===================================== testsuite/tests/hpc/function/Makefile ===================================== @@ -2,3 +2,8 @@ TOP=../../.. include $(TOP)/mk/boilerplate.mk include $(TOP)/mk/test.mk +tough1: + HPCTIXFILE=ghc.tix "$(TEST_HC)" $(TEST_HC_OPTS_INTERACTICE) -v0 -fhpc tough.hs -e "main" + "$(HPC)" report ghc.tix + "$(HPC)" report ghc.tix --per-module + "$(HPC)" markup ghc.tix ===================================== testsuite/tests/hpc/function/test.T ===================================== @@ -1,4 +1,4 @@ -setTestOpts([omit_ghci, when(fast(), skip), js_skip]) +setTestOpts([when(fast(), skip), js_skip]) hpc_prefix = "perl hpcrun.pl --clear --exeext={exeext} --hpc={hpc}" @@ -8,3 +8,9 @@ test('tough', ignore_extension, when(arch('wasm32'), fragile(23243))], compile_and_run, ['-fhpc']) + +test('tough1', + [extra_files(['tough.hs']), + ignore_extension, + when(arch('wasm32'), fragile(23243))], + makefile_test, []) ===================================== testsuite/tests/hpc/function/tough1.stderr ===================================== @@ -0,0 +1,7 @@ +tough.hs:22:5: warning: [GHC-53633] [-Woverlapping-patterns] + Pattern match is redundant + In a case alternative: _ -> ... + | +22 | _ -> error "Bad Thing Happened" + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + ===================================== testsuite/tests/hpc/function/tough1.stdout ===================================== @@ -0,0 +1,29 @@ +"Hello" +"Hello" +badCase +badCase +"Bark" +"Hello" +(1,2,3) + 73% expressions used (73/100) + 14% boolean coverage (1/7) + 0% guards (0/4), 3 always True, 1 always False + 33% 'if' conditions (1/3), 1 always True, 1 always False + 100% qualifiers (0/0) + 58% alternatives used (7/12) +100% local declarations used (0/0) + 83% top-level declarations used (5/6) +-----<module Main>----- + 73% expressions used (73/100) + 14% boolean coverage (1/7) + 0% guards (0/4), 3 always True, 1 always False + 33% 'if' conditions (1/3), 1 always True, 1 always False + 100% qualifiers (0/0) + 58% alternatives used (7/12) +100% local declarations used (0/0) + 83% top-level declarations used (5/6) +Writing: Main.hs.html +Writing: hpc_index.html +Writing: hpc_index_fun.html +Writing: hpc_index_alt.html +Writing: hpc_index_exp.html ===================================== testsuite/tests/hpc/function2/test.T ===================================== @@ -14,3 +14,14 @@ test('tough2', omit_ways(ghci_ways + prof_ways), # profile goes in the wrong place when(arch('wasm32'), fragile(23243)) ], multimod_compile_and_run, ['subdir/tough2.lhs', '-fhpc']) + +# Same as tough2, but for ghci +test('tough3', + [extra_files(['../hpcrun.pl', 'subdir/']), + literate, + cmd_prefix(hpc_prefix), + ignore_extension, + extra_hc_opts('-fhpc subdir/tough2.lhs'), + omit_ways(ghci_ways + prof_ways), # profile goes in the wrong place + when(arch('wasm32'), fragile(23243)) ], + ghci_script, ['tough3.script']) ===================================== testsuite/tests/hpc/function2/tough3.script ===================================== @@ -0,0 +1,2 @@ +:main +:quit ===================================== testsuite/tests/hpc/ghc_ghci/Makefile ===================================== @@ -9,7 +9,7 @@ hpc_ghc_ghci: hpc_ghc_ghci_bytecode: rm -f ./*.tix - printf "main\n:quit\n" | '$(TEST_HC)' $(TEST_HC_OPTS_INTERACTIVE) -fhpc -fbyte-code-and-object-code -fprefer-byte-code BytecodeMain.hs + '$(TEST_HC)' $(TEST_HC_OPTS_INTERACTIVE) -fhpc -fbyte-code-and-object-code -fprefer-byte-code BytecodeMain.hs -e "main" -e ":quit" @[ -f .hpc/Main.mix ] || (echo "ERROR: Expected .hpc/Main.mix file not found"; exit 1) @set -- ./*.tix; [ -f "$$1" ] || (echo "ERROR: Expected .tix file not found"; exit 1); '$(HPC)' report "$$1" Main > hpc-report.txt @grep -F "100% expressions used" hpc-report.txt >/dev/null || (echo "ERROR: Expected full expression coverage in hpc report"; cat hpc-report.txt; exit 1) ===================================== testsuite/tests/hpc/hpcrun.pl ===================================== @@ -4,11 +4,12 @@ while($ARGV[0] =~ /^--/) { $arg = shift @ARGV; + last if ($arg eq '--'); if ($arg =~ /--hpc=(.*)/) { $HPC = $1; - } + } elsif ($arg =~ /--clear/) { - $CLEAR = 1; + $CLEAR = 1; } elsif ($arg =~ /--exeext=(.*)/) { $exeext = $1; @@ -19,8 +20,10 @@ while($ARGV[0] =~ /^--/) { } die "no option --hpc=* provided\n" if (!defined($HPC)); - -$binary = $ARGV[0] . $exeext; + +# Skip over any KEY=VALUE env assignments to find the real executable +my $exe = (grep { !/^\w+=/ } @ARGV)[0]; +$binary = $exe . $exeext; # get the basename: needed for the test function/subdir/tough2 $binary =~ s/^.*\/([^\/]*)$/$1/; @@ -38,7 +41,7 @@ while(<MARKUP>) { my $line = $_; print $line; if (/Writing: (\S+.html)/) { - system("cat $1"); + system("cat $1"); } } print "\n\n"; ===================================== testsuite/tests/hpc/simple/Makefile ===================================== @@ -2,3 +2,12 @@ TOP=../../.. include $(TOP)/mk/boilerplate.mk include $(TOP)/mk/test.mk +hpc002: + HPCTIXFILE=ghc.tix "$(TEST_HC)" $(TEST_HC_OPTS_INTERACTIVE) $(TEST_HC_ARGS) hpc002.hs -fhpc -v0 -e ":main" + "$(HPC)" report ghc + "$(HPC)" report ghc --per-module + LANG=ASCII "$(HPC)" markup ghc + +hpc003: + HPCTIXFILE=ghc.tix "$(TEST_HC)" $(TEST_HC_OPTS_INTERACTIVE) $(TEST_HC_ARGS) -fhpc -v0 < hpc003.script + "$(HPC)" report ghc || echo "Can't summarise file that is ':load'ed" ===================================== testsuite/tests/hpc/simple/hpc002.hs ===================================== @@ -0,0 +1 @@ +main = print (const "Hello" "World") ===================================== testsuite/tests/hpc/simple/hpc002.stdout ===================================== @@ -0,0 +1,23 @@ +"Hello" + 75% expressions used (3/4) +100% boolean coverage (0/0) + 100% guards (0/0) + 100% 'if' conditions (0/0) + 100% qualifiers (0/0) +100% alternatives used (0/0) +100% local declarations used (0/0) +100% top-level declarations used (1/1) +-----<module Main>----- + 75% expressions used (3/4) +100% boolean coverage (0/0) + 100% guards (0/0) + 100% 'if' conditions (0/0) + 100% qualifiers (0/0) +100% alternatives used (0/0) +100% local declarations used (0/0) +100% top-level declarations used (1/1) +Writing: Main.hs.html +Writing: hpc_index.html +Writing: hpc_index_fun.html +Writing: hpc_index_alt.html +Writing: hpc_index_exp.html ===================================== testsuite/tests/hpc/simple/hpc003.hs ===================================== @@ -0,0 +1 @@ +main = print (const "Hello" "World") ===================================== testsuite/tests/hpc/simple/hpc003.script ===================================== @@ -0,0 +1,2 @@ +:load hpc003.hs +:main ===================================== testsuite/tests/hpc/simple/hpc003.stderr ===================================== @@ -0,0 +1,7 @@ +hpc: Uncaught exception ghc-internal:GHC.Internal.Exception.ErrorCall: + +can not find interactivezmsession_Main in ./.hpc + +HasCallStack backtrace: + error, called at libraries/hpc/Trace/Hpc/Mix.hs:110:15 in hpc-0.7.0.2-inplace:Trace.Hpc.Mix + ===================================== testsuite/tests/hpc/simple/hpc003.stdout ===================================== @@ -0,0 +1,2 @@ +"Hello" +Can't summarise file that is ':load'ed ===================================== testsuite/tests/hpc/simple/test.T ===================================== @@ -1,4 +1,4 @@ -setTestOpts([omit_ghci, when(fast(), skip), js_skip]) +setTestOpts([when(fast(), skip), js_skip]) hpc_prefix = "perl hpcrun.pl --clear --exeext={exeext} --hpc={hpc}" @@ -7,3 +7,16 @@ test('hpc001', [extra_files(['../hpcrun.pl']), cmd_prefix(hpc_prefix), ignore_extension ], compile_and_run, ['-fhpc']) + +test('hpc002', + [ when(arch('wasm32'), fragile(23243)) + , ignore_extension + ], + makefile_test, []) + +test('hpc003', + [ when(arch('wasm32'), fragile(23243)) + , ignore_extension + , extra_files(['hpc003.script']) + ], + makefile_test, []) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7f2d3236253adbaa7239832b6ff25f8c... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7f2d3236253adbaa7239832b6ff25f8c... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Hannes Siebenhandl (@fendor)