Simplify running update-references.sh

This commit is contained in:
David Tolnay 2019-02-17 10:58:09 -08:00
parent 344602d27e
commit bf27b28554
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82
3 changed files with 32 additions and 25 deletions

18
test_suite/README.md Normal file
View File

@ -0,0 +1,18 @@
#### To run unit tests
```sh
cargo test
```
#### To run ui tests
```sh
(cd deps && cargo clean && cargo update && cargo build)
cargo test --features compiletest
```
#### To update goldens after running ui tests
```sh
tests/ui/update-references.sh
```

View File

@ -15,6 +15,7 @@ fn ui() {
--extern serde_derive \ --extern serde_derive \
", ",
)), )),
build_base: std::path::PathBuf::from("../target/ui"),
..Default::default() ..Default::default()
}); });
} }

View File

@ -19,32 +19,20 @@
# If you find yourself manually editing a foo.stderr file, you're # If you find yourself manually editing a foo.stderr file, you're
# doing it wrong. # doing it wrong.
if [[ "$1" == "--help" || "$1" == "-h" || "$1" == "" || "$2" == "" ]]; then cd "$(dirname "${BASH_SOURCE[0]}")"
echo "usage: $0 <build-directory> <relative-path-to-rs-files>" BUILD_DIR="../../../target/ui"
echo ""
echo "For example:"
echo " $0 ../../../build/x86_64-apple-darwin/test/ui *.rs */*.rs"
fi
MYDIR=$(dirname $0) for testcase in */*.rs; do
STDERR_NAME="${testcase/%.rs/.stderr}"
BUILD_DIR="$1" STDOUT_NAME="${testcase/%.rs/.stdout}"
shift if [ -f "$BUILD_DIR/$STDOUT_NAME" ] && \
! (diff "$BUILD_DIR/$STDOUT_NAME" "$STDOUT_NAME" >& /dev/null); then
while [[ "$1" != "" ]]; do echo "updating $STDOUT_NAME"
STDERR_NAME="${1/%.rs/.stderr}" cp "$BUILD_DIR/$STDOUT_NAME" "$STDOUT_NAME"
STDOUT_NAME="${1/%.rs/.stdout}"
shift
if [ -f $BUILD_DIR/$STDOUT_NAME ] && \
! (diff $BUILD_DIR/$STDOUT_NAME $MYDIR/$STDOUT_NAME >& /dev/null); then
echo updating $MYDIR/$STDOUT_NAME
cp $BUILD_DIR/$STDOUT_NAME $MYDIR/$STDOUT_NAME
fi fi
if [ -f $BUILD_DIR/$STDERR_NAME ] && \ if [ -f "$BUILD_DIR/$STDERR_NAME" ] && \
! (diff $BUILD_DIR/$STDERR_NAME $MYDIR/$STDERR_NAME >& /dev/null); then ! (diff "$BUILD_DIR/$STDERR_NAME" "$STDERR_NAME" >& /dev/null); then
echo updating $MYDIR/$STDERR_NAME echo "updating $STDERR_NAME"
cp $BUILD_DIR/$STDERR_NAME $MYDIR/$STDERR_NAME cp "$BUILD_DIR/$STDERR_NAME" "$STDERR_NAME"
fi fi
done done