Skip to content

Commit

Permalink
Cleanup output-file tests (rust-lang#1381)
Browse files Browse the repository at this point in the history
  • Loading branch information
fzaiser authored Jul 15, 2022
1 parent 46952c8 commit 913e273
Showing 1 changed file with 17 additions and 34 deletions.
51 changes: 17 additions & 34 deletions tests/output-files/check-output.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,41 +43,24 @@ then
exit 1
fi

if ! grep -Fq "struct PrettyStruct pretty_function(struct PrettyStruct" singlefile.out.demangled.c;
then
echo "Error: demangled file singlefile.out.demangled.c did not contain expected demangled struct and function name."
exit 1
fi

if ! grep -Fq "monomorphize::<usize>(" singlefile.out.demangled.c;
then
echo "Error: demangled file singlefile.out.demangled.c did not contain monomorphized function name."
exit 1
fi

if ! grep -Fq "struct ()" singlefile.out.demangled.c;
then
echo "Error: demangled file singlefile.out.demangled.c did not contain pretty-printed unit struct."
exit 1
fi

if ! grep -Fq "init_array_repeat<[bool; 2]>" singlefile.out.demangled.c;
then
echo "Error: demangled file singlefile.out.demangled.c did not contain pretty-printed array initializer."
exit 1
fi

if ! grep -Fq "struct &str" singlefile.out.demangled.c;
then
echo "Error: demangled file singlefile.out.demangled.c did not contain pretty-printed reference type."
exit 1
fi
echo "Checking that demangling works as expected..."

declare -a PATTERNS=(
'struct PrettyStruct pretty_function(struct PrettyStruct' # expected demangled struct and function name
'monomorphize::<usize>(' # monomorphized function name
'struct ()' # pretty-printed unit struct
'init_array_repeat<[bool; 2]>' # pretty-printed array initializer
'struct &str' # pretty-printed reference type
'TestEnum::Variant1' # pretty-printed variant
)

if ! grep -Fq "TestEnum::Variant1" singlefile.out.demangled.c;
then
echo "Error: demangled file singlefile.out.demangled.c did not contain pretty-printed variant."
exit 1
fi
for val in "${PATTERNS[@]}"; do
if ! grep -Fq "$val" singlefile.out.demangled.c;
then
echo "Error: demangled file singlefile.out.demangled.c did not contain expected pattern '$val'."
exit 1
fi
done

echo "Finished single-file check successfully..."
echo
Expand Down

0 comments on commit 913e273

Please sign in to comment.