Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the generated files by update-references.sh if they are empty #6158

Merged
merged 1 commit into from
Oct 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion doc/adding_lints.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ every time before running `tests/ui/update-all-references.sh`.
Running `TESTNAME=foo_functions cargo uitest` should pass then. When we commit
our lint, we need to commit the generated `.stderr` files, too. In general, you
should only commit files changed by `tests/ui/update-all-references.sh` for the
specific lint you are creating/editing.
specific lint you are creating/editing. Note that if the generated files are
empty, they should be removed.

### Cargo lints

Expand Down
8 changes: 8 additions & 0 deletions tests/ui-cargo/update-references.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,18 @@ while [[ "$1" != "" ]]; do
! (cmp -s -- "$BUILD_DIR"/"$STDOUT_NAME" "$MYDIR"/"$STDOUT_NAME"); then
echo updating "$MYDIR"/"$STDOUT_NAME"
cp "$BUILD_DIR"/"$STDOUT_NAME" "$MYDIR"/"$STDOUT_NAME"
if [[ ! -s "$MYDIR"/"$STDOUT_NAME" ]]; then
echo removing "$MYDIR"/"$STDOUT_NAME"
rm "$MYDIR"/"$STDOUT_NAME"
fi
fi
if [[ -f "$BUILD_DIR"/"$STDERR_NAME" ]] && \
! (cmp -s -- "$BUILD_DIR"/"$STDERR_NAME" "$MYDIR"/"$STDERR_NAME"); then
echo updating "$MYDIR"/"$STDERR_NAME"
cp "$BUILD_DIR"/"$STDERR_NAME" "$MYDIR"/"$STDERR_NAME"
if [[ ! -s "$MYDIR"/"$STDERR_NAME" ]]; then
echo removing "$MYDIR"/"$STDERR_NAME"
rm "$MYDIR"/"$STDERR_NAME"
fi
fi
done
8 changes: 8 additions & 0 deletions tests/ui-toml/update-references.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,18 @@ while [[ "$1" != "" ]]; do
! (cmp -s -- "$BUILD_DIR"/"$STDOUT_NAME" "$MYDIR"/"$STDOUT_NAME"); then
echo updating "$MYDIR"/"$STDOUT_NAME"
cp "$BUILD_DIR"/"$STDOUT_NAME" "$MYDIR"/"$STDOUT_NAME"
if [[ ! -s "$MYDIR"/"$STDOUT_NAME" ]]; then
echo removing "$MYDIR"/"$STDOUT_NAME"
rm "$MYDIR"/"$STDOUT_NAME"
fi
fi
if [[ -f "$BUILD_DIR"/"$STDERR_NAME" ]] && \
! (cmp -s -- "$BUILD_DIR"/"$STDERR_NAME" "$MYDIR"/"$STDERR_NAME"); then
echo updating "$MYDIR"/"$STDERR_NAME"
cp "$BUILD_DIR"/"$STDERR_NAME" "$MYDIR"/"$STDERR_NAME"
if [[ ! -s "$MYDIR"/"$STDERR_NAME" ]]; then
echo removing "$MYDIR"/"$STDERR_NAME"
rm "$MYDIR"/"$STDERR_NAME"
fi
fi
done
12 changes: 12 additions & 0 deletions tests/ui/update-references.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,27 @@ while [[ "$1" != "" ]]; do
! (cmp -s -- "$BUILD_DIR"/"$STDOUT_NAME" "$MYDIR"/"$STDOUT_NAME"); then
echo updating "$MYDIR"/"$STDOUT_NAME"
cp "$BUILD_DIR"/"$STDOUT_NAME" "$MYDIR"/"$STDOUT_NAME"
if [[ ! -s "$MYDIR"/"$STDOUT_NAME" ]]; then
echo removing "$MYDIR"/"$STDOUT_NAME"
rm "$MYDIR"/"$STDOUT_NAME"
fi
fi
if [[ -f "$BUILD_DIR"/"$STDERR_NAME" ]] && \
! (cmp -s -- "$BUILD_DIR"/"$STDERR_NAME" "$MYDIR"/"$STDERR_NAME"); then
echo updating "$MYDIR"/"$STDERR_NAME"
cp "$BUILD_DIR"/"$STDERR_NAME" "$MYDIR"/"$STDERR_NAME"
if [[ ! -s "$MYDIR"/"$STDERR_NAME" ]]; then
echo removing "$MYDIR"/"$STDERR_NAME"
rm "$MYDIR"/"$STDERR_NAME"
fi
fi
if [[ -f "$BUILD_DIR"/"$FIXED_NAME" ]] && \
! (cmp -s -- "$BUILD_DIR"/"$FIXED_NAME" "$MYDIR"/"$FIXED_NAME"); then
echo updating "$MYDIR"/"$FIXED_NAME"
cp "$BUILD_DIR"/"$FIXED_NAME" "$MYDIR"/"$FIXED_NAME"
if [[ ! -s "$MYDIR"/"$FIXED_NAME" ]]; then
echo removing "$MYDIR"/"$FIXED_NAME"
rm "$MYDIR"/"$FIXED_NAME"
fi
fi
done