From f1db3b85f50af94a0731bf41f33341b21a95b1cd Mon Sep 17 00:00:00 2001 From: Joe Haddad Date: Fri, 10 Feb 2017 15:21:59 -0500 Subject: [PATCH 1/6] Add test cases to evaluate increased CI time --- tasks/e2e-simple.sh | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/tasks/e2e-simple.sh b/tasks/e2e-simple.sh index f8baf743de7..a35964bd228 100755 --- a/tasks/e2e-simple.sh +++ b/tasks/e2e-simple.sh @@ -142,6 +142,36 @@ create_react_app --scripts-version=$scripts_path test-app # let's make sure all npm scripts are in the working state. # ****************************************************************************** +function verify_env_url { + # Backup package.json because we're going to make it dirty + cp package.json package.json.orig + + # Test relative path build + awk -v n=2 -v s=" \"homepage\": \".\"," 'NR == n {print s} {print}' package.json > tmp && mv tmp package.json + + npm run build + + PUBLIC_URL="/anabsolute" npm run build + + # Test absolute path build + sed "2s/.*/ \"homepage\": \"\/testingpath\",/" package.json > tmp && mv tmp package.json + + npm run build + + PUBLIC_URL="https://www.example.net/overridetest" npm run build + + # Test absolute url build + sed "2s/.*/ \"homepage\": \"https:\/\/www.example.net\/testingpath\",/" package.json > tmp && mv tmp package.json + + npm run build + + PUBLIC_URL="https://www.example.net/overridetest" npm run build + + # Restore package.json + rm package.json + mv package.json.orig package.json +} + # Enter the app directory cd test-app @@ -162,6 +192,9 @@ CI=true npm test # Test the server npm start -- --smoke-test +# Test environment handling +verify_env_url + # ****************************************************************************** # Finally, let's check that everything still works after ejecting. # ****************************************************************************** @@ -195,6 +228,8 @@ npm test -- --watch=no # Test the server npm start -- --smoke-test +# Test environment handling +verify_env_url # Cleanup cleanup From 1ab9a7a0a3ee68c658e200ad8ebdc54503405038 Mon Sep 17 00:00:00 2001 From: Joe Haddad Date: Fri, 10 Feb 2017 15:53:24 -0500 Subject: [PATCH 2/6] Add positive test cases --- tasks/e2e-simple.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tasks/e2e-simple.sh b/tasks/e2e-simple.sh index a35964bd228..3caf9dfdd91 100755 --- a/tasks/e2e-simple.sh +++ b/tasks/e2e-simple.sh @@ -150,22 +150,28 @@ function verify_env_url { awk -v n=2 -v s=" \"homepage\": \".\"," 'NR == n {print s} {print}' package.json > tmp && mv tmp package.json npm run build + grep -F -R --exclude=*.map "../../static/" build/ -q PUBLIC_URL="/anabsolute" npm run build + grep -F -R --exclude=*.map "/anabsolute/static/" build/ -q # Test absolute path build sed "2s/.*/ \"homepage\": \"\/testingpath\",/" package.json > tmp && mv tmp package.json npm run build + grep -F -R --exclude=*.map "/testingpath/static/" build/ -q PUBLIC_URL="https://www.example.net/overridetest" npm run build + grep -F -R --exclude=*.map "https://www.example.net/overridetest/static/" build/ -q # Test absolute url build sed "2s/.*/ \"homepage\": \"https:\/\/www.example.net\/testingpath\",/" package.json > tmp && mv tmp package.json npm run build + grep -F -R --exclude=*.map "/testingpath/static/" build/ -q PUBLIC_URL="https://www.example.net/overridetest" npm run build + grep -F -R --exclude=*.map "https://www.example.net/overridetest/static/" build/ -q # Restore package.json rm package.json From f38884e33857cf14e3577b58818231c36de2b90b Mon Sep 17 00:00:00 2001 From: Joe Haddad Date: Fri, 10 Feb 2017 16:00:43 -0500 Subject: [PATCH 3/6] Add negative cases --- tasks/e2e-simple.sh | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/tasks/e2e-simple.sh b/tasks/e2e-simple.sh index 3caf9dfdd91..10d468a6357 100755 --- a/tasks/e2e-simple.sh +++ b/tasks/e2e-simple.sh @@ -150,28 +150,36 @@ function verify_env_url { awk -v n=2 -v s=" \"homepage\": \".\"," 'NR == n {print s} {print}' package.json > tmp && mv tmp package.json npm run build - grep -F -R --exclude=*.map "../../static/" build/ -q + grep -F -R --exclude=*.map "../../static/" build/ -q; test $? -eq 0 + grep -F -R --exclude=*.map "\"/static/" build/ -q; test $? -eq 1 PUBLIC_URL="/anabsolute" npm run build - grep -F -R --exclude=*.map "/anabsolute/static/" build/ -q + grep -F -R --exclude=*.map "/anabsolute/static/" build/ -q; test $? -eq 0 + grep -F -R --exclude=*.map "\"/static/" build/ -q; test $? -eq 1 # Test absolute path build sed "2s/.*/ \"homepage\": \"\/testingpath\",/" package.json > tmp && mv tmp package.json npm run build - grep -F -R --exclude=*.map "/testingpath/static/" build/ -q + grep -F -R --exclude=*.map "/testingpath/static/" build/ -q; test $? -eq 0 + grep -F -R --exclude=*.map "\"/static/" build/ -q; test $? -eq 1 PUBLIC_URL="https://www.example.net/overridetest" npm run build - grep -F -R --exclude=*.map "https://www.example.net/overridetest/static/" build/ -q + grep -F -R --exclude=*.map "https://www.example.net/overridetest/static/" build/ -q; test $? -eq 0 + grep -F -R --exclude=*.map "\"/static/" build/ -q; test $? -eq 1 + grep -F -R --exclude=*.map "testingpath/static" build/ -q; test $? -eq 1 # Test absolute url build sed "2s/.*/ \"homepage\": \"https:\/\/www.example.net\/testingpath\",/" package.json > tmp && mv tmp package.json npm run build - grep -F -R --exclude=*.map "/testingpath/static/" build/ -q + grep -F -R --exclude=*.map "/testingpath/static/" build/ -q; test $? -eq 0 + grep -F -R --exclude=*.map "\"/static/" build/ -q; test $? -eq 1 PUBLIC_URL="https://www.example.net/overridetest" npm run build - grep -F -R --exclude=*.map "https://www.example.net/overridetest/static/" build/ -q + grep -F -R --exclude=*.map "https://www.example.net/overridetest/static/" build/ -q; test $? -eq 0 + grep -F -R --exclude=*.map "\"/static/" build/ -q; test $? -eq 1 + grep -F -R --exclude=*.map "testingpath/static" build/ -q; test $? -eq 1 # Restore package.json rm package.json From c83a87b1321a5a5c7de24fa974dc1a4f62055d5b Mon Sep 17 00:00:00 2001 From: Joe Haddad Date: Fri, 10 Feb 2017 16:04:39 -0500 Subject: [PATCH 4/6] Test default behavior --- tasks/e2e-simple.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tasks/e2e-simple.sh b/tasks/e2e-simple.sh index 10d468a6357..ad305e09970 100755 --- a/tasks/e2e-simple.sh +++ b/tasks/e2e-simple.sh @@ -146,6 +146,9 @@ function verify_env_url { # Backup package.json because we're going to make it dirty cp package.json package.json.orig + # Test default behavior + grep -F -R --exclude=*.map "\"/static/" build/ -q; test $? -eq 0 + # Test relative path build awk -v n=2 -v s=" \"homepage\": \".\"," 'NR == n {print s} {print}' package.json > tmp && mv tmp package.json From f955c9f96289118d07b3afde4b418d0b4b086cb1 Mon Sep 17 00:00:00 2001 From: Joe Haddad Date: Fri, 10 Feb 2017 16:41:31 -0500 Subject: [PATCH 5/6] Exit on failure --- tasks/e2e-simple.sh | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/tasks/e2e-simple.sh b/tasks/e2e-simple.sh index ad305e09970..a4deea35dc3 100755 --- a/tasks/e2e-simple.sh +++ b/tasks/e2e-simple.sh @@ -147,42 +147,42 @@ function verify_env_url { cp package.json package.json.orig # Test default behavior - grep -F -R --exclude=*.map "\"/static/" build/ -q; test $? -eq 0 + grep -F -R --exclude=*.map "\"/static/" build/ -q; test $? -eq 0 || exit 1 # Test relative path build awk -v n=2 -v s=" \"homepage\": \".\"," 'NR == n {print s} {print}' package.json > tmp && mv tmp package.json npm run build - grep -F -R --exclude=*.map "../../static/" build/ -q; test $? -eq 0 - grep -F -R --exclude=*.map "\"/static/" build/ -q; test $? -eq 1 + grep -F -R --exclude=*.map "../../static/" build/ -q; test $? -eq 0 || exit 1 + grep -F -R --exclude=*.map "\"/static/" build/ -q; test $? -eq 1 || exit 1 PUBLIC_URL="/anabsolute" npm run build - grep -F -R --exclude=*.map "/anabsolute/static/" build/ -q; test $? -eq 0 - grep -F -R --exclude=*.map "\"/static/" build/ -q; test $? -eq 1 + grep -F -R --exclude=*.map "/anabsolute/static/" build/ -q; test $? -eq 0 || exit 1 + grep -F -R --exclude=*.map "\"/static/" build/ -q; test $? -eq 1 || exit 1 # Test absolute path build sed "2s/.*/ \"homepage\": \"\/testingpath\",/" package.json > tmp && mv tmp package.json npm run build - grep -F -R --exclude=*.map "/testingpath/static/" build/ -q; test $? -eq 0 - grep -F -R --exclude=*.map "\"/static/" build/ -q; test $? -eq 1 + grep -F -R --exclude=*.map "/testingpath/static/" build/ -q; test $? -eq 0 || exit 1 + grep -F -R --exclude=*.map "\"/static/" build/ -q; test $? -eq 1 || exit 1 PUBLIC_URL="https://www.example.net/overridetest" npm run build - grep -F -R --exclude=*.map "https://www.example.net/overridetest/static/" build/ -q; test $? -eq 0 - grep -F -R --exclude=*.map "\"/static/" build/ -q; test $? -eq 1 - grep -F -R --exclude=*.map "testingpath/static" build/ -q; test $? -eq 1 + grep -F -R --exclude=*.map "https://www.example.net/overridetest/static/" build/ -q; test $? -eq 0 || exit 1 + grep -F -R --exclude=*.map "\"/static/" build/ -q; test $? -eq 1 || exit 1 + grep -F -R --exclude=*.map "testingpath/static" build/ -q; test $? -eq 1 || exit 1 # Test absolute url build sed "2s/.*/ \"homepage\": \"https:\/\/www.example.net\/testingpath\",/" package.json > tmp && mv tmp package.json npm run build - grep -F -R --exclude=*.map "/testingpath/static/" build/ -q; test $? -eq 0 - grep -F -R --exclude=*.map "\"/static/" build/ -q; test $? -eq 1 + grep -F -R --exclude=*.map "/testingpath/static/" build/ -q; test $? -eq 0 || exit 1 + grep -F -R --exclude=*.map "\"/static/" build/ -q; test $? -eq 1 || exit 1 PUBLIC_URL="https://www.example.net/overridetest" npm run build - grep -F -R --exclude=*.map "https://www.example.net/overridetest/static/" build/ -q; test $? -eq 0 - grep -F -R --exclude=*.map "\"/static/" build/ -q; test $? -eq 1 - grep -F -R --exclude=*.map "testingpath/static" build/ -q; test $? -eq 1 + grep -F -R --exclude=*.map "https://www.example.net/overridetest/static/" build/ -q; test $? -eq 0 || exit 1 + grep -F -R --exclude=*.map "\"/static/" build/ -q; test $? -eq 1 || exit 1 + grep -F -R --exclude=*.map "testingpath/static" build/ -q; test $? -eq 1 || exit 1 # Restore package.json rm package.json From 8c2a65cd7183b3bd4f1a48302e0bafe137c72db6 Mon Sep 17 00:00:00 2001 From: Joe Haddad Date: Fri, 10 Feb 2017 16:46:20 -0500 Subject: [PATCH 6/6] Fix test --- tasks/e2e-simple.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tasks/e2e-simple.sh b/tasks/e2e-simple.sh index a4deea35dc3..d0acb16b412 100755 --- a/tasks/e2e-simple.sh +++ b/tasks/e2e-simple.sh @@ -153,7 +153,9 @@ function verify_env_url { awk -v n=2 -v s=" \"homepage\": \".\"," 'NR == n {print s} {print}' package.json > tmp && mv tmp package.json npm run build - grep -F -R --exclude=*.map "../../static/" build/ -q; test $? -eq 0 || exit 1 + # Disabled until this can be tested + # grep -F -R --exclude=*.map "../../static/" build/ -q; test $? -eq 0 || exit 1 + grep -F -R --exclude=*.map "\"./static/" build/ -q; test $? -eq 0 || exit 1 grep -F -R --exclude=*.map "\"/static/" build/ -q; test $? -eq 1 || exit 1 PUBLIC_URL="/anabsolute" npm run build