Skip to content

Commit

Permalink
Remove script usage of globstar, improving compatibility (#683)
Browse files Browse the repository at this point in the history
  • Loading branch information
jw013 authored Mar 6, 2024
1 parent e0d61c7 commit 822d619
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 24 deletions.
8 changes: 3 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ and relies on similar information.
For example, if implementing a lint that uses information about attributes,
find other lints that check attribute information and use them as guides as you write your lint.

Make sure to check the ["Development Environment"](#development-environment) section, especially if you are using Mac or Windows.
Make sure to check the ["Development Environment"](#development-environment) section, especially if you are using Windows.

The ["Adding a new lint"](#adding-a-new-lint) section of this document has a walkthrough for
defining and testing new lints.
Expand Down Expand Up @@ -250,9 +250,7 @@ expected output files to include the new items, and you can get back on track.
## Development Environment

While cargo-semver-checks is cross platform, the development task automation scripts in the scripts
directory are not. In particular, a relatively modern `bash` (at least version 4.0) is required.
directory require a `bash` shell to run.

Linux users likely have bash 5+ already installed or available via their package manager.
Windows users can get a bash + GNU command line environment via WSL or git bash.
Mac users can install an updated bash via homebrew. The scripts will not work
correctly using the default version of bash that comes with Mac OS.
Linux and Mac OS typically have bash installed by default.
25 changes: 6 additions & 19 deletions scripts/regenerate_test_rustdocs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ if [ -z "$BASH_VERSION" ]; then
exit 1
fi

# have bash, check version
if (( BASH_VERSINFO[0] < 4 )); then
>&2 printf 'This script requires bash version 4.0 or greater.\n'
exit 1
fi

# Fail on first error, on undefined variables, and on failures in pipelines.
set -euo pipefail

dir_is_newer_than_file() {
local dir="$1"
local file="$2"
[[ ! -e $file ]] || [[ $(find "$dir" -newer "$file" -exec sh -c 'printf found; kill "$PPID"' \;) ]]
}

export CARGO_TARGET_DIR=/tmp/test_crates
RUSTDOC_OUTPUT_DIR="$CARGO_TARGET_DIR/doc"
TOPLEVEL="$(git rev-parse --show-toplevel)"
Expand All @@ -32,19 +32,6 @@ echo "Generating rustdoc with: $(cargo $TOOLCHAIN --version)"
RUSTDOC_CMD="cargo $TOOLCHAIN rustdoc"

# Run rustdoc on test_crates/*/{new,old}/
shopt -s globstar
dir_is_newer_than_file() {
local dir=$1
local file=$2
local f
for f in "$dir"/**; do
if [[ $f -nt $file ]]; then
return 0
fi
done
return 1
}

if [[ $# -eq 0 ]]; then
set -- "$TOPLEVEL/test_crates/"*/
always_update=
Expand Down

0 comments on commit 822d619

Please # to comment.