Skip to content

Commit fbca72c

Browse files
committed
test: run integration scripts in tmp/ work directory
Previously the scripts dirtied the project's Gemfile/Gemfile.lock by running bundle remove/add against them, and created "My Workspace" in the repo root. They now resolve the project root from $0, work inside tmp/integration-user-{install,upgrade}/, write a fresh minimal Gemfile there, and use an absolute --path="$ROOT" reference back to the gem.
1 parent 5583237 commit fbca72c

2 files changed

Lines changed: 26 additions & 16 deletions

File tree

test/integration/user_install_test.sh

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,23 @@
55
set -o pipefail
66
set -eux
77

8-
# set up dependencies
8+
ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
9+
WORKDIR="$ROOT/tmp/integration-user-install"
10+
11+
rm -rf "$WORKDIR"
12+
mkdir -p "$WORKDIR"
13+
pushd "$WORKDIR"
14+
15+
# set up dependencies in a fresh Gemfile
916
gem install bcrypt # it's complicated, see Rails 7549ba77. can probably be removed once Rails 8.0 is EOL.
10-
rm -f Gemfile.lock
11-
bundle remove actionmailer || true
12-
bundle remove rails || true
13-
rm -f Gemfile.lock
17+
cat > Gemfile <<EOF
18+
source "https://rubygems.org"
19+
EOF
1420
bundle add rails --skip-install ${RAILSOPTS:-}
1521
bundle install --prefer-local
1622
bundle exec rails -v
1723

18-
# do our work a directory with spaces in the name (#176, #184)
19-
rm -rf "My Workspace"
24+
# do our work in a directory with spaces in the name (#176, #184)
2025
mkdir "My Workspace"
2126
pushd "My Workspace"
2227

@@ -27,7 +32,7 @@ function prepare_deps {
2732
bundle add rails --skip-install ${RAILSOPTS:-}
2833

2934
# use the tailwindcss-rails under test
30-
bundle add tailwindcss-rails --skip-install --path="../.."
35+
bundle add tailwindcss-rails --skip-install --path="$ROOT"
3136
bundle add tailwindcss-ruby --skip-install ${TAILWINDCSSOPTS:-}
3237
bundle install --prefer-local
3338
bundle show --paths | fgrep tailwind

test/integration/user_upgrade_test.sh

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,22 @@
55
set -o pipefail
66
set -eux
77

8-
# set up dependencies
8+
ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
9+
WORKDIR="$ROOT/tmp/integration-user-upgrade"
10+
11+
rm -rf "$WORKDIR"
12+
mkdir -p "$WORKDIR"
13+
pushd "$WORKDIR"
14+
15+
# set up dependencies in a fresh Gemfile
916
gem install bcrypt # it's complicated, see Rails 7549ba77. can probably be removed once Rails 8.0 is EOL.
10-
rm -f Gemfile.lock
11-
bundle remove actionmailer || true
12-
bundle remove rails || true
13-
rm -f Gemfile.lock
17+
cat > Gemfile <<EOF
18+
source "https://rubygems.org"
19+
EOF
1420
bundle add rails --skip-install ${RAILSOPTS:-}
1521
bundle install --prefer-local
1622

17-
# do our work a directory with spaces in the name (#176, #184)
18-
rm -rf "My Workspace"
23+
# do our work in a directory with spaces in the name (#176, #184)
1924
mkdir "My Workspace"
2025
pushd "My Workspace"
2126

@@ -54,7 +59,7 @@ grep -q "Show this post" app/views/posts/index.html.erb
5459
bundle remove tailwindcss-rails --skip-install
5560
bundle remove tailwindcss-ruby --skip-install
5661

57-
bundle add tailwindcss-rails --skip-install --path="../.."
62+
bundle add tailwindcss-rails --skip-install --path="$ROOT"
5863
bundle add tailwindcss-ruby --skip-install ${TAILWINDCSSOPTS:---version 4.0.0}
5964

6065
bundle install --prefer-local

0 commit comments

Comments
 (0)