From 99c14e710ffb01d1c4a1124fc3ed2172bf58afbd Mon Sep 17 00:00:00 2001
From: Dan Abramov <dan.abramov@gmail.com>
Date: Thu, 11 Jan 2018 01:55:55 +0000
Subject: [PATCH] Separate old Node E2E test (#3742)

* Separate old Node E2E test

* Try this for old node
---
 .travis.yml           |  3 ++-
 tasks/e2e-old-node.sh | 61 +++++++++++++++++++++++++++++++++++++++++++
 tasks/e2e-simple.sh   | 16 ------------
 3 files changed, 63 insertions(+), 17 deletions(-)
 create mode 100755 tasks/e2e-old-node.sh

diff --git a/.travis.yml b/.travis.yml
index e970cf01c..ef223ffd5 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -14,6 +14,7 @@ script:
  - 'if [ $TEST_SUITE = "simple" ]; then tasks/e2e-simple.sh; fi'
  - 'if [ $TEST_SUITE = "installs" ]; then tasks/e2e-installs.sh; fi'
  - 'if [ $TEST_SUITE = "kitchensink" ]; then tasks/e2e-kitchensink.sh; fi'
+ - 'if [ $TEST_SUITE = "old-node" ]; then tasks/e2e-old-node.sh; fi'
 env:
   matrix:
     - TEST_SUITE=simple
@@ -22,4 +23,4 @@ env:
 matrix:
   include:
     - node_js: 0.10
-      env: TEST_SUITE=simple
+      env: TEST_SUITE=old-node
diff --git a/tasks/e2e-old-node.sh b/tasks/e2e-old-node.sh
new file mode 100755
index 000000000..8245dd24e
--- /dev/null
+++ b/tasks/e2e-old-node.sh
@@ -0,0 +1,61 @@
+#!/bin/bash
+# Copyright (c) 2015-present, Facebook, Inc.
+#
+# This source code is licensed under the MIT license found in the
+# LICENSE file in the root directory of this source tree.
+
+# ******************************************************************************
+# This is an end-to-end test intended to run on CI.
+# You can also run it locally but it's slow.
+# ******************************************************************************
+
+# Start in tasks/ even if run from root directory
+cd "$(dirname "$0")"
+
+temp_app_path=`mktemp -d 2>/dev/null || mktemp -d -t 'temp_app_path'`
+
+function cleanup {
+  echo 'Cleaning up.'
+  cd "$root_path"
+  rm -rf $temp_app_path
+}
+
+# Error messages are redirected to stderr
+function handle_error {
+  echo "$(basename $0): ERROR! An error was encountered executing line $1." 1>&2;
+  cleanup
+  echo 'Exiting with error.' 1>&2;
+  exit 1
+}
+
+function handle_exit {
+  cleanup
+  echo 'Exiting without error.' 1>&2;
+  exit
+}
+
+# Exit the script with a helpful error message when any error is encountered
+trap 'set +x; handle_error $LINENO $BASH_COMMAND' ERR
+
+# Cleanup before exit on any termination signal
+trap 'set +x; handle_exit' SIGQUIT SIGTERM SIGINT SIGKILL SIGHUP
+
+# Echo every command being executed
+set -x
+
+# Go to root
+cd ..
+root_path=$PWD
+
+# We need to install create-react-app deps to test it
+cd "$root_path"/packages/create-react-app
+npm install
+cd "$root_path"
+
+# If the node version is < 6, the script should just give an error.
+cd $temp_app_path
+err_output=`node "$root_path"/packages/create-react-app/index.js test-node-version 2>&1 > /dev/null || echo ''`
+[[ $err_output =~ You\ are\ running\ Node ]] && exit 0 || exit 1
+
+# Cleanup
+cleanup
diff --git a/tasks/e2e-simple.sh b/tasks/e2e-simple.sh
index 449c5f3ba..72bc757d9 100755
--- a/tasks/e2e-simple.sh
+++ b/tasks/e2e-simple.sh
@@ -102,22 +102,6 @@ grep -v "postinstall" package.json > temp && mv temp package.json
 yarn
 mv package.json.bak package.json
 
-# We need to install create-react-app deps to test it
-cd "$root_path"/packages/create-react-app
-yarn
-cd "$root_path"
-
-# If the node version is < 6, the script should just give an error.
-nodeVersion=`node --version | cut -d v -f2`
-nodeMajor=`echo $nodeVersion | cut -d. -f1`
-nodeMinor=`echo $nodeVersion | cut -d. -f2`
-if [[ nodeMajor -lt 6 ]]
-then
-  cd $temp_app_path
-  err_output=`node "$root_path"/packages/create-react-app/index.js test-node-version 2>&1 > /dev/null || echo ''`
-  [[ $err_output =~ You\ are\ running\ Node ]] && exit 0 || exit 1
-fi
-
 # We removed the postinstall, so do it manually here
 node bootstrap.js
 
-- 
GitLab