Skip to content

Commit f594e07

Browse files
committed
Testsuite: Support a list of possible compare files
The 'compare_file' procedure could be updated to check whether the 'expected' argument is a list, but in the meantime, this adds a new 'compare_file_list' procedure that takes a list argument and passes if any one in the list matches. This is used in one test where BSC built with GHC 9.12.1 has _tcdict defs in a different order. The test now compares against both possible outputs.
1 parent c702fa0 commit f594e07

File tree

4 files changed

+110
-11
lines changed

4 files changed

+110
-11
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
checking package dependencies
2+
compiling DummyInDeflQual.bs
3+
Warning: "DummyInDeflQual.bs", line 5, column 10: (P0223)
4+
Definition of `x' is not used.
5+
=== internal:
6+
IPackage DummyInDeflQual
7+
--linked packages
8+
9+
--pragmas
10+
11+
--idefs
12+
DummyInDeflQual.dummyInDeflQual :: Prelude.Bit 12
13+
DummyInDeflQual.dummyInDeflQual =
14+
let _tcdict1072 :: Prelude.Literal (Prelude.Bit 12)
15+
_tcdict1072 = Prelude.Prelude.Literal~Prelude.Bit~n= ·12
16+
-- IdProp: _tcdict1072[IdP_bad_name,IdPDict]
17+
in let f ::
18+
\/(_tctyvar1063 :: *) .
19+
\/(_tctyvar1064 :: *) . Prelude.Literal _tctyvar1063 -> _tctyvar1064 -> _tctyvar1063
20+
f =
21+
/\ (_tctyvar1063 :: *) .
22+
/\ (_tctyvar1064 :: *) .
23+
\ (_tcdict1050 :: Prelude.Literal _tctyvar1063) .
24+
let _tcdict1032 :: Prelude.Eq (Prelude.Bit 2)
25+
_tcdict1032 = Prelude.Prelude.Eq~Prelude.Bit~n= ·2
26+
-- IdProp: _tcdict1032[IdP_bad_name,IdPDict]
27+
in let _tcdict1042 :: Prelude.Literal (Prelude.Bit 2)
28+
_tcdict1042 = Prelude.Prelude.Literal~Prelude.Bit~n= ·2
29+
-- IdProp: _tcdict1042[IdP_bad_name,IdPDict]
30+
in \ (x :: _tctyvar1064) .
31+
PrimIf
32+
·_tctyvar1063
33+
(PrimOrd
34+
·Prelude.Bool
35+
·1
36+
(.(Prelude.==)
37+
·(Prelude.Bit 2)
38+
_tcdict1032
39+
(PrimBuildUndefined ·(Prelude.Bit 2) _ 1)
40+
(.Prelude.fromInteger ·(Prelude.Bit 2) _tcdict1042 0b11)))
41+
(.Prelude.fromInteger ·_tctyvar1063 _tcdict1050 0)
42+
(PrimBuildUndefined ·_tctyvar1063 (PrimGetEvalPosition ·_tctyvar1064 x) 2)
43+
in f ·(Prelude.Bit 12) ·Prelude.Bool _tcdict1072 (Prelude.True Prelude.PrimUnit)
44+
next def..........................................................
45+
46+
47+
-----
48+
49+
All packages are up to date.

testsuite/bsc.typechecker/dontcare/dontcare.exp

+5-1
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,12 @@ compare_file DummyInDef.bs.bsc-out
4545
compile_pass DummyInDefOp.bs "-dinternal"
4646
compare_file DummyInDefOp.bs.bsc-out
4747

48+
# The order of _tcdict<n> defs changed in GHC 9.12.1
49+
# Test that the output matches one of the possible outputs
4850
compile_pass DummyInDeflQual.bs "-dinternal"
49-
compare_file DummyInDeflQual.bs.bsc-out
51+
compare_file_list DummyInDeflQual.bs.bsc-out \
52+
{DummyInDeflQual.bs.bsc-out.0.expected \
53+
DummyInDeflQual.bs.bsc-out.1.expected}
5054

5155
if {$vtest == 1} {
5256
compile_verilog_pass DummyInRuleQual.bs sysDummyInRuleQual "-dATS"

testsuite/config/unix.exp

+56-10
Original file line numberDiff line numberDiff line change
@@ -930,8 +930,12 @@ proc make_bsc_sched_output_name { source } {
930930
return $filename
931931
}
932932

933-
proc make_diff_output_name { source } {
934-
set filename "$source.diff-out"
933+
proc make_diff_output_name { source {tag ""} } {
934+
if {[string compare $tag ""] == 0} {
935+
set filename "$source.diff-out"
936+
} else {
937+
set filename "$source.$tag.diff-out"
938+
}
935939
return $filename
936940
}
937941

@@ -2124,14 +2128,7 @@ proc compare_file { filename {expected ""} {stat "compare_file"}} {
21242128
}
21252129
set output [make_diff_output_name $filename]
21262130

2127-
set diff_flags "-u"
2128-
2129-
set ignore_pattern [format "-I \"SystemC\" -I \"dumpfile parameter\"" ]
2130-
2131-
set cmd "diff $diff_flags -b $ignore_pattern $expected $filename >& $output"
2132-
verbose "Diffing: $cmd" 2
2133-
2134-
set diff_status [catch "exec $cmd"]
2131+
set diff_status [compare_file_core $filename $expected $output]
21352132

21362133
if { $diff_status == 0 } {
21372134
set status 0
@@ -2146,6 +2143,55 @@ proc compare_file { filename {expected ""} {stat "compare_file"}} {
21462143
return $status
21472144
}
21482145

2146+
proc compare_file_list { filename expected_list {stat "compare_file_list"}} {
2147+
global srcdir
2148+
global subdir
2149+
2150+
incr_stat $stat
2151+
2152+
set here [absolute $srcdir]
2153+
cd [file join $here $subdir]
2154+
2155+
set status 1
2156+
set n 0
2157+
foreach expected $expected_list {
2158+
2159+
set output [make_diff_output_name $filename "option$n"]
2160+
2161+
set diff_status [compare_file_core $filename $expected $output]
2162+
2163+
if { $diff_status == 0 } {
2164+
set status 0
2165+
pass "`$filename' identical to `$expected'"
2166+
file delete -force $output
2167+
# Exit the foreach loop
2168+
break
2169+
}
2170+
2171+
incr n
2172+
}
2173+
2174+
if { $status == 1 } {
2175+
fail "`$filename' differs from list of possible expected files"
2176+
set output_pat [make_diff_output_name $filename {*}]
2177+
verbose -log "(Differences written to `[file join $subdir $output_pat]')" 1
2178+
}
2179+
2180+
cd $here
2181+
return $status
2182+
}
2183+
2184+
proc compare_file_core { filename expected output } {
2185+
2186+
set diff_flags "-u"
2187+
set ignore_pattern [format "-I \"SystemC\" -I \"dumpfile parameter\"" ]
2188+
2189+
set cmd "diff $diff_flags -b $ignore_pattern $expected $filename >& $output"
2190+
verbose "Diffing: $cmd" 2
2191+
2192+
return [catch "exec $cmd"]
2193+
}
2194+
21492195
# compare 2 files, first filtering through a sed script
21502196
proc compare_file_filtered { output {expected ""} {bre_options ""} {ere_options ""} } {
21512197

0 commit comments

Comments
 (0)