Skip to content

Commit

Permalink
Stop using npm link in tests (#3345)
Browse files Browse the repository at this point in the history
* Try a custom function

* fix path

* install rsync

* Test with node 8

* Ensure package is removed from the tree

* Remove ours

* matching functions

* try cygwin

* try c:/

* sigh

* Try /cygdrive/

* Try /cygdrive/

* Revert "Try /cygdrive/"

This reverts commit ab1ed779456d39bedbdb128a7aec3bb88b8eeb1c.

* Use sub-optimal copy

* Remove rsync install

* Fix variable

* Continue on err

* Don't link react-scripts, lol

* run yarn after eject

* re-enable cleanup

* uninstall yarn

* try with force

* appveyor ... seriously?

* swallow bad eject

* remove eject error swallow

* Revert "run yarn after eject"

This reverts commit eebf1dbc19aeb6e1f66d5ec27bda2d076bea0956.

* Run yarn after eject

* add a comment
  • Loading branch information
Timer authored and gaearon committed Oct 30, 2017
1 parent 345f550 commit de1beec
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 21 deletions.
6 changes: 3 additions & 3 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ image: Visual Studio 2017

environment:
matrix:
- nodejs_version: 7
- nodejs_version: 8
test_suite: "simple"
- nodejs_version: 7
- nodejs_version: 8
test_suite: "installs"
- nodejs_version: 7
- nodejs_version: 8
test_suite: "kitchensink"
- nodejs_version: 6
test_suite: "simple"
Expand Down
55 changes: 41 additions & 14 deletions tasks/e2e-kitchensink.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,31 @@ function create_react_app {
node "$temp_cli_path"/node_modules/create-react-app/index.js "$@"
}

function install_package {
local pkg=$(basename $1)

# Clean target (for safety)
rm -rf node_modules/$pkg/
rm -rf node_modules/**/$pkg/

# Copy package into node_modules/ ignoring installed deps
# rsync -a ${1%/} node_modules/ --exclude node_modules
cp -R ${1%/} node_modules/
rm -rf node_modules/$pkg/node_modules/

# Install `dependencies`
cd node_modules/$pkg/
if [ "$USE_YARN" = "yes" ]
then
yarn install --production
else
npm install --only=production
fi
# Remove our packages to ensure side-by-side versions are used (which we link)
rm -rf node_modules/{babel-preset-react-app,eslint-config-react-app,react-dev-utils,react-error-overlay,react-scripts}
cd ../..
}

# Check for the existence of one or more files.
function exists {
for f in $*; do
Expand Down Expand Up @@ -162,13 +187,13 @@ npm install test-integrity@^2.0.1
cd "$temp_app_path/test-kitchensink"

# Link to our preset
npm link "$root_path"/packages/babel-preset-react-app
install_package "$root_path"/packages/babel-preset-react-app
# Link to error overlay package because now it's a dependency
# of react-dev-utils and not react-scripts
npm link "$root_path"/packages/react-error-overlay
install_package "$root_path"/packages/react-error-overlay

# Link to test module
npm link "$temp_module_path/node_modules/test-integrity"
install_package "$temp_module_path/node_modules/test-integrity"

# Test the build
REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \
Expand Down Expand Up @@ -219,23 +244,25 @@ E2E_FILE=./build/index.html \
# Finally, let's check that everything still works after ejecting.
# ******************************************************************************

# Unlink our preset
npm unlink "$root_path"/packages/babel-preset-react-app
# Unlink error overlay
npm unlink "$root_path"/packages/react-error-overlay

# Eject...
echo yes | npm run eject

# Ensure Yarn is ran after eject; at the time of this commit, we don't run Yarn
# after ejecting. Soon, we may only skip Yarn on Windows. Let's try to remove
# this in the near future.
if hash yarnpkg 2>/dev/null
then
yarn install --check-files
fi

# ...but still link to the local packages
npm link "$root_path"/packages/babel-preset-react-app
npm link "$root_path"/packages/eslint-config-react-app
npm link "$root_path"/packages/react-error-overlay
npm link "$root_path"/packages/react-dev-utils
npm link "$root_path"/packages/react-scripts
install_package "$root_path"/packages/babel-preset-react-app
install_package "$root_path"/packages/eslint-config-react-app
install_package "$root_path"/packages/react-error-overlay
install_package "$root_path"/packages/react-dev-utils

# Link to test module
npm link "$temp_module_path/node_modules/test-integrity"
install_package "$temp_module_path/node_modules/test-integrity"

# Test the build
REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \
Expand Down
40 changes: 36 additions & 4 deletions tasks/e2e-simple.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,31 @@ function create_react_app {
node "$temp_cli_path"/node_modules/create-react-app/index.js "$@"
}

function install_package {
local pkg=$(basename $1)

# Clean target (for safety)
rm -rf node_modules/$pkg/
rm -rf node_modules/**/$pkg/

# Copy package into node_modules/ ignoring installed deps
# rsync -a ${1%/} node_modules/ --exclude node_modules
cp -R ${1%/} node_modules/
rm -rf node_modules/$pkg/node_modules/

# Install `dependencies`
cd node_modules/$pkg/
if [ "$USE_YARN" = "yes" ]
then
yarn install --production
else
npm install --only=production
fi
# Remove our packages to ensure side-by-side versions are used (which we link)
rm -rf node_modules/{babel-preset-react-app,eslint-config-react-app,react-dev-utils,react-error-overlay,react-scripts}
cd ../..
}

# Check for the existence of one or more files.
function exists {
for f in $*; do
Expand Down Expand Up @@ -306,11 +331,18 @@ verify_module_scope
# Eject...
echo yes | npm run eject

# Ensure Yarn is ran after eject; at the time of this commit, we don't run Yarn
# after ejecting. Soon, we may only skip Yarn on Windows. Let's try to remove
# this in the near future.
if hash yarnpkg 2>/dev/null
then
yarnpkg install --check-files
fi

# ...but still link to the local packages
npm link "$root_path"/packages/babel-preset-react-app
npm link "$root_path"/packages/eslint-config-react-app
npm link "$root_path"/packages/react-dev-utils
npm link "$root_path"/packages/react-scripts
install_package "$root_path"/packages/babel-preset-react-app
install_package "$root_path"/packages/eslint-config-react-app
install_package "$root_path"/packages/react-dev-utils

# Test the build
npm run build
Expand Down

0 comments on commit de1beec

Please sign in to comment.