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

Fix test -e with wildcard arguments. #1503

Merged
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
13 changes: 10 additions & 3 deletions tasks/e2e-installs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ function handle_exit {
exit
}

# Check for the existence of one or more files.
function exists {
for f in $*; do
test -e "$f"
done
}

function create_react_app {
node "$temp_cli_path"/node_modules/create-react-app/index.js $*
}
Expand Down Expand Up @@ -86,7 +93,7 @@ create_react_app --scripts-version=0.4.0 test-app-version-number
cd test-app-version-number

# Check corresponding scripts version is installed.
test -e node_modules/react-scripts
exists node_modules/react-scripts
grep '"version": "0.4.0"' node_modules/react-scripts/package.json

# ******************************************************************************
Expand All @@ -98,7 +105,7 @@ create_react_app --scripts-version=https://registry.npmjs.org/react-scripts/-/re
cd test-app-tarball-url

# Check corresponding scripts version is installed.
test -e node_modules/react-scripts
exists node_modules/react-scripts
grep '"version": "0.4.0"' node_modules/react-scripts/package.json

# ******************************************************************************
Expand All @@ -110,7 +117,7 @@ create_react_app --scripts-version=react-scripts-fork test-app-fork
cd test-app-fork

# Check corresponding scripts version is installed.
test -e node_modules/react-scripts-fork
exists node_modules/react-scripts-fork

# ******************************************************************************
# Test nested folder path as the project name
Expand Down
15 changes: 11 additions & 4 deletions tasks/e2e-kitchensink.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ function create_react_app {
node "$temp_cli_path"/node_modules/create-react-app/index.js $*
}

# Check for the existence of one or more files.
function exists {
for f in $*; do
test -e "$f"
done
}

# Exit the script with a helpful error message when any error is encountered
trap 'set +x; handle_error $LINENO $BASH_COMMAND' ERR

Expand Down Expand Up @@ -116,8 +123,8 @@ npm link $root_path/packages/babel-preset-react-app
# Test the build
NODE_PATH=src REACT_APP_SHELL_ENV_MESSAGE=fromtheshell npm run build
# Check for expected output
test -e build/*.html
test -e build/static/js/main.*.js
exists build/*.html
exists build/static/js/main.*.js

# Unit tests
REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \
Expand Down Expand Up @@ -168,8 +175,8 @@ rm .babelrc
# Test the build
NODE_PATH=src REACT_APP_SHELL_ENV_MESSAGE=fromtheshell npm run build
# Check for expected output
test -e build/*.html
test -e build/static/js/main.*.js
exists build/*.html
exists build/static/js/main.*.js

# Unit tests
REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \
Expand Down
43 changes: 25 additions & 18 deletions tasks/e2e-simple.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ function create_react_app {
node "$temp_cli_path"/node_modules/create-react-app/index.js $*
}

# Check for the existence of one or more files.
function exists {
for f in $*; do
test -e "$f"
done
}

# Exit the script with a helpful error message when any error is encountered
trap 'set +x; handle_error $LINENO $BASH_COMMAND' ERR

Expand Down Expand Up @@ -86,16 +93,16 @@ fi
# Test local build command
npm run build
# Check for expected output
test -e build/*.html
test -e build/static/js/*.js
test -e build/static/css/*.css
test -e build/static/media/*.svg
test -e build/favicon.ico
exists build/*.html
exists build/static/js/*.js
exists build/static/css/*.css
exists build/static/media/*.svg
exists build/favicon.ico

# Run tests with CI flag
CI=true npm test
# Uncomment when snapshot testing is enabled by default:
# test -e template/src/__snapshots__/App.test.js.snap
# exists template/src/__snapshots__/App.test.js.snap

# Test local start command
npm start -- --smoke-test
Expand Down Expand Up @@ -148,16 +155,16 @@ cd test-app
# Test the build
npm run build
# Check for expected output
test -e build/*.html
test -e build/static/js/*.js
test -e build/static/css/*.css
test -e build/static/media/*.svg
test -e build/favicon.ico
exists build/*.html
exists build/static/js/*.js
exists build/static/css/*.css
exists build/static/media/*.svg
exists build/favicon.ico

# Run tests with CI flag
CI=true npm test
# Uncomment when snapshot testing is enabled by default:
# test -e src/__snapshots__/App.test.js.snap
# exists src/__snapshots__/App.test.js.snap

# Test the server
npm start -- --smoke-test
Expand All @@ -178,19 +185,19 @@ npm link $root_path/packages/react-scripts
# Test the build
npm run build
# Check for expected output
test -e build/*.html
test -e build/static/js/*.js
test -e build/static/css/*.css
test -e build/static/media/*.svg
test -e build/favicon.ico
exists build/*.html
exists build/static/js/*.js
exists build/static/css/*.css
exists build/static/media/*.svg
exists build/favicon.ico

# Run tests, overring the watch option to disable it.
# `CI=true npm test` won't work here because `npm test` becomes just `jest`.
# We should either teach Jest to respect CI env variable, or make
# `scripts/test.js` survive ejection (right now it doesn't).
npm test -- --watch=no
# Uncomment when snapshot testing is enabled by default:
# test -e src/__snapshots__/App.test.js.snap
# exists src/__snapshots__/App.test.js.snap

# Test the server
npm start -- --smoke-test
Expand Down