Debian Codegraph @

gcc/testsuite/rust/compile/nr2/compile.exp

raw
1 # Copyright (C) 2021-2024 Free Software Foundation, Inc.
2
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version.
7 #
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with GCC; see the file COPYING3. If not see
15 # <http://www.gnu.org/licenses/>.
16
17 # Run compile tests with name resolution 2.0 enabled
18
19 # Load support procs.
20 load_lib rust-dg.exp
21
22 # These tests don't run runtest_file_p consistently if it
23 # doesn't return the same values, so disable parallelization
24 # of this *.exp file. The first parallel runtest to reach
25 # this will run all the tests serially.
26 if ![gcc_parallel_test_run_p compile] {
27 return
28 }
29 gcc_parallel_test_enable 0
30
31 # Initialize `dg'.
32 dg-init
33
34 namespace eval rust-nr2-ns {
35 # Exclude tests which aren't passing yet
36 # These should be removed from the exclude file over time
37
38 set exclude_fh [open $srcdir/$subdir/exclude r]
39 set exclude_raw [lsort [split [read $exclude_fh] "\n"]]
40 close $exclude_fh
41 unset exclude_fh
42
43 set exclude ""
44 foreach ent $exclude_raw {
45 if [regexp {^[^#].*} $ent] {
46 lappend exclude $ent
47 }
48 }
49 unset exclude_raw
50
51 # Run tests in directories
52 # Manually specifying these, in case some other test file
53 # does something weird
54 set test_dirs {{} {macros builtin} {macros mbe} {macros proc} {torture}}
55
56 set tests_expect_ok ""
57 set tests_expect_err ""
58
59 set compile_dir [list {*}[file split $srcdir] {*}[file split $subdir]]
60 set compile_dir [lreplace $compile_dir end end]
61
62 foreach test_dir $test_dirs {
63 foreach test [lsort [glob -nocomplain -tails -directory [file join {*}$compile_dir {*}$test_dir] *.rs]] {
64 # use '/' as the path seperator for entries in the exclude file
65 set test_lbl [join [list {*}$test_dir $test] "/"]
66 set idx [lsearch -exact -sorted $exclude $test_lbl]
67 if {$idx == -1} {
68 if {[runtest_file_p $runtests [file join {*}$compile_dir {*}$test_dir $test]]} {
69 lappend tests_expect_ok [list {*}$test_dir $test]
70 }
71 } else {
72 if {[runtest_file_p $runtests [file join {*}$compile_dir {*}$test_dir $test]]} {
73 lappend tests_expect_err [list {*}$test_dir $test]
74 }
75 set exclude [lreplace $exclude $idx $idx]
76 }
77 }
78 }
79
80 # Generate failures for unmatched tests in the exclude list
81 foreach ent $exclude {
82 fail "$ent: could not exclude test"
83 }
84 unset exclude
85
86 # run a test while catching record_test calls
87 set record_test_out ""
88 proc try_test { test } {
89 variable record_test_out
90 rename ::record_test record_test_old
91
92 proc ::record_test { type msg args } {
93 namespace eval ::rust-nr2-ns {
94 set type [uplevel 1 {set type}]
95 set msg [uplevel 1 {set msg}]
96 variable record_test_out
97 switch $type {
98 FAIL {
99 lappend record_test_out [list $type $msg]
100 }
101 XPASS {
102 lappend record_test_out [list $type $msg]
103 }
104 }
105 }
106 }
107
108 namespace eval :: {
109 set saved-dg-do-what-default ${dg-do-what-default}
110 set dg-do-what-default "compile"
111 dg-runtest [list [uplevel 1 {set test}]] "-frust-name-resolution-2.0" ""
112 set dg-do-what-default ${saved-dg-do-what-default}
113 }
114
115 rename ::record_test ""
116 rename record_test_old ::record_test
117
118 set record_test_cache $record_test_out
119 set record_test_out ""
120 return $record_test_cache
121 }
122
123 # check for unexpected failures
124 foreach test $tests_expect_ok {
125 set fails [try_test [file join {*}$compile_dir {*}$test]]
126 if {[llength $fails] != 0} {
127 foreach ent $fails {
128 record_test [lindex $ent 0] "on nr2: [lindex $ent 1]"
129 }
130 } else {
131 record_test PASS "[file join {*}$test] on nr2"
132 }
133 }
134
135 #check for unexpected successes
136 foreach test $tests_expect_err {
137 set fails [try_test [file join {*}$compile_dir {*}$test]]
138 if {[llength $fails] == 0} {
139 record_test XPASS "[file join {*}$test] on nr2"
140 } else {
141 record_test XFAIL "[file join {*}$test] on nr2 was rightfully excluded"
142 }
143 }
144 }
145
146 # All done.
147 dg-finish
148
149 gcc_parallel_test_enable 1