From: Owen Avery <powerboat9.ga...@gmail.com> This runs the standard compile/**.rs tests with name resolution 2.0 enabled. The exclude file can be used to exclude tests which are not yet working with name resolution 2.0.
gcc/testsuite/ChangeLog: * rust/compile/nr2/compile.exp: New test. * rust/compile/nr2/exclude: New. Signed-off-by: Owen Avery <powerboat9.ga...@gmail.com> --- gcc/testsuite/rust/compile/nr2/compile.exp | 136 ++++++++++ gcc/testsuite/rust/compile/nr2/exclude | 293 +++++++++++++++++++++ 2 files changed, 429 insertions(+) create mode 100644 gcc/testsuite/rust/compile/nr2/compile.exp create mode 100644 gcc/testsuite/rust/compile/nr2/exclude diff --git a/gcc/testsuite/rust/compile/nr2/compile.exp b/gcc/testsuite/rust/compile/nr2/compile.exp new file mode 100644 index 00000000000..0afe36c3c40 --- /dev/null +++ b/gcc/testsuite/rust/compile/nr2/compile.exp @@ -0,0 +1,136 @@ +# Copyright (C) 2021-2024 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GCC; see the file COPYING3. If not see +# <http://www.gnu.org/licenses/>. + +# Compile tests, no torture testing, for name resolution 2.0 +# +# These tests raise errors in the front end; torture testing doesn't apply. + +# Load support procs. +load_lib rust-dg.exp + +# Initialize `dg'. +dg-init + +namespace eval rust-nr2-ns { + # Exclude tests which aren't passing yet + # These should be removed from the exclude file over time + + set exclude_fh [open $srcdir/$subdir/exclude r] + set exclude_raw [lsort [split [read $exclude_fh] "\n"]] + close $exclude_fh + unset exclude_fh + + set exclude "" + foreach ent $exclude_raw { + if [regexp {^[^#].*} $ent] { + lappend exclude $ent + } + } + unset exclude_raw + + # Run tests in directories + # Manually specifying these, in case some other test file + # does something weird + set test_dirs {. compile macros/builtin macros/mbe macros/proc} + + set tests_expect_ok "" + set tests_expect_err "" + + foreach test_dir $test_dirs { + foreach test [lsort [glob -nocomplain -tails -directory $srcdir/$subdir/../$test_dir *.rs]] { + if {$test_dir == "."} { + set test_lbl $test + } else { + set test_lbl "$test_dir/$test" + } + set idx [lsearch -exact -sorted $exclude $test_lbl] + if {$idx == -1} { + lappend tests_expect_ok $srcdir/$subdir/../$test_dir/$test + } else { + lappend tests_expect_err $srcdir/$subdir/../$test_dir/$test + set exclude [lreplace $exclude $idx $idx] + } + } + } + + # Generate failures for unmatched tests in the exclude list + foreach ent $exclude { + fail "$ent: could not exclude test" + } + unset exclude + + # run a test while catching record_test calls + set record_test_out "" + proc try_test { test } { + variable record_test_out + rename ::record_test record_test_old + + proc ::record_test { type msg args } { + namespace eval ::rust-nr2-ns { + set type [uplevel 1 {set type}] + set msg [uplevel 1 {set msg}] + variable record_test_out + switch $type { + FAIL { + lappend record_test_out "$type: $msg" + } + XPASS { + lappend record_test_out "$type: $msg" + } + } + } + } + + namespace eval :: { + set saved-dg-do-what-default ${dg-do-what-default} + set dg-do-what-default "compile" + dg-runtest [list [uplevel 1 {set test}]] "-frust-name-resolution-2.0" "" + set dg-do-what-default ${saved-dg-do-what-default} + } + + rename ::record_test "" + rename record_test_old ::record_test + + set record_test_cache $record_test_out + set record_test_out "" + return $record_test_cache + } + + # check for unexpected failures + foreach test $tests_expect_ok { + set fails [try_test $test] + if {[llength $fails] != 0} { + foreach ent $fails { + record_test FAIL "$test: nr2 failure: $ent" + } + } else { + record_test PASS "$test: nr2 success" + } + } + + #check for unexpected successes + foreach test $tests_expect_err { + set fails [try_test $test] + if {[llength $fails] == 0} { + record_test XPASS "$test: nr2 unexpectedly passed" + } else { + record_test XFAIL "$test: nr2 was rightfully excluded" + } + } +} + +# All done. +dg-finish diff --git a/gcc/testsuite/rust/compile/nr2/exclude b/gcc/testsuite/rust/compile/nr2/exclude new file mode 100644 index 00000000000..ca07ed6ecd2 --- /dev/null +++ b/gcc/testsuite/rust/compile/nr2/exclude @@ -0,0 +1,293 @@ +# relies on exact source file path match +# TODO: patch this file or nr2/compile.exp to handle this +debug-diagnostics-on.rs + +# main list +all-cast.rs +array3.rs +arrays1.rs +arrays2.rs +attr-mismatch-crate-name.rs +attr_deprecated.rs +attr_deprecated_2.rs +auto_trait_super_trait.rs +auto_trait_valid.rs +auto_trait_invalid.rs +bad=file-name.rs +bad_type2.rs +bounds1.rs +break-rust1.rs +break-rust2.rs +break-rust3.rs +break2.rs +break_with_value_inside_loop.rs +macros/builtin/eager1.rs +macros/builtin/eager2.rs +macros/builtin/recurse2.rs +macros/builtin/include3.rs +macros/builtin/include4.rs +canonical_paths1.rs +cast_generics.rs +cfg1.rs +cfg3.rs +cfg4.rs +cfg5.rs +closure_no_type_anno.rs +complex-path1.rs +complex_qualified_path_in_expr.rs +const-issue1440.rs +const1.rs +const10.rs +const3.rs +const4.rs +const5.rs +const6.rs +const8.rs +const9.rs +const_generics_1.rs +const_generics_3.rs +const_generics_4.rs +const_generics_5.rs +const_generics_6.rs +const_generics_7.rs +const_generics_8.rs +derive_empty.rs +derive_macro1.rs +derive_macro3.rs +derive_macro4.rs +derive_macro6.rs +diagnostic_underline.rs +expand_macro_qual_path_in_type.rs +expected_type_args2.rs +expected_type_args3.rs +feature_rust_attri0.rs +feature_rust_attri1.rs +for_lifetimes.rs +format_args_basic_expansion.rs +found_struct.rs +func1.rs +generic-default1.rs +generics1.rs +generics10.rs +generics11.rs +generics2.rs +generics3.rs +generics4.rs +generics5.rs +generics6.rs +generics7.rs +generics8.rs +generics9.rs +if_let_expr.rs +implicit_returns_err4.rs +infer-crate-name.rs +issue-1005.rs +issue-1006.rs +issue-1019.rs +issue-1023.rs +issue-1031.rs +issue-1034.rs +issue-1073.rs +issue-1089.rs +issue-1128.rs +issue-1129-1.rs +issue-1129-2.rs +issue-1130.rs +issue-1131.rs +issue-1152.rs +issue-1165.rs +issue-1173.rs +issue-1235.rs +issue-1237.rs +issue-1271.rs +issue-1272.rs +issue-1289.rs +issue-1383.rs +issue-1447.rs +issue-1483.rs +issue-1524.rs +issue-1589.rs +issue-1725-1.rs +issue-1725-2.rs +issue-1786.rs +issue-1813.rs +issue-1893.rs +issue-1901.rs +issue-1930.rs +issue-1981.rs +issue-2019-1.rs +issue-2019-2.rs +issue-2019-3.rs +issue-2029.rs +issue-2036.rs +issue-2037.rs +issue-2039.rs +issue-2043.rs +issue-2070.rs +issue-2105.rs +issue-2106.rs +issue-2135.rs +issue-2136-1.rs +issue-2136-2.rs +issue-2139.rs +issue-2142.rs +issue-2165.rs +issue-2166.rs +issue-2178.rs +issue-2188.rs +issue-2190-1.rs +issue-2190-2.rs +issue-2195.rs +issue-2238.rs +issue-2304.rs +issue-2330.rs +issue-2375.rs +issue-2478.rs +issue-2479.rs +issue-2514.rs +issue-2723-1.rs +issue-2723-2.rs +issue-2772-1.rs +issue-2772-2.rs +issue-2775.rs +issue-2747.rs +issue-2782.rs +issue-2788.rs +issue-2812.rs +issue-2847-b.rs +issue-850.rs +issue-852.rs +issue-855.rs +issue-925.rs +iterators1.rs +lookup_err1.rs +macros/mbe/macro-issue1233.rs +macros/mbe/macro-issue1400.rs +macros/mbe/macro13.rs +macros/mbe/macro15.rs +macros/mbe/macro20.rs +macros/mbe/macro23.rs +macros/mbe/macro40.rs +macros/mbe/macro42.rs +macros/mbe/macro43.rs +macros/mbe/macro44.rs +macros/mbe/macro50.rs +macros/mbe/macro54.rs +macros/mbe/macro55.rs +macros/mbe/macro6.rs +macros/mbe/macro9.rs +macros/mbe/macro_rules_macro_rules.rs +macros/mbe/macro_use1.rs +match-never-ltype.rs +match-never-rtype.rs +match1.rs +match2.rs +match3.rs +match4.rs +match5.rs +match8.rs +match9.rs +method1.rs +method2.rs +missing_constructor_fields.rs +multi_reference_type.rs +multiple_bindings1.rs +multiple_bindings2.rs +name_resolution2.rs +name_resolution4.rs +nested_generic.rs +nested_macro_use1.rs +nested_macro_use2.rs +nested_macro_use3.rs +non_member_const.rs +not_find_value_in_scope.rs +parse_associated_type_as_generic_arg.rs +parse_associated_type_as_generic_arg2.rs +parse_associated_type_as_generic_arg3.rs +parse_complex_generic_application.rs +parse_complex_generic_application2.rs +path_as_generic_arg.rs +pattern-struct.rs +privacy1.rs +privacy3.rs +privacy4.rs +privacy5.rs +privacy6.rs +privacy8.rs +privacy9.rs +macros/proc/attribute_non_function.rs +macros/proc/attribute_non_root_method.rs +macros/proc/derive_non_function.rs +macros/proc/non_root_method.rs +macros/proc/non_root_trait_method.rs +macros/proc/non_function.rs +pub_restricted_1.rs +pub_restricted_2.rs +pub_restricted_3.rs +redef_error2.rs +redef_error4.rs +redef_error5.rs +redef_error6.rs +ref_pattern_fn_param2.rs +reference1.rs +rustc_attr1.rs +self-path1.rs +self-path2.rs +shadow1.rs +sizeof-stray-infer-var-bug.rs +specify-crate-name.rs +stmt_with_block_dot.rs +struct-expr-parse.rs +trait-cycle.rs +traits1.rs +traits10.rs +traits11.rs +traits12.rs +traits2.rs +traits3.rs +traits4.rs +traits5.rs +traits6.rs +traits7.rs +traits8.rs +traits9.rs +tuple1.rs +tuple_mismatch.rs +tuple_struct1.rs +type-alias1.rs +type-bindings1.rs +unconstrained_type_param.rs +undeclared_label.rs +unsafe1.rs +unsafe10.rs +unsafe11.rs +unsafe2.rs +unsafe3.rs +unsafe6.rs +unsafe7.rs +unsafe8.rs +unsafe9.rs +use_1.rs +use_2.rs +v0-mangle1.rs +v0-mangle2.rs +while_break_expr.rs +rust-const-blog-issue.rs +negative_impls.rs +auto_trait.rs +exhaustiveness1.rs +exhaustiveness2.rs +exhaustiveness3.rs +trait13.rs +trait14.rs +issue-2324-1.rs +issue-2324-2.rs +issue-2725.rs +issue-2987.rs +issue-3045-1.rs +issue-3045-2.rs +issue-3046.rs +unknown-associated-item.rs +box_syntax_feature_gate.rs +dropck_eyepatch_feature_gate.rs +inline_asm_parse_output_operand.rs -- 2.45.2