git.iko.soy/typeable/elm-ui
on master help sign in
publish to netlify when tests for sauce labs are run.
commitae18607868c1efca778fc1d380389e603cef9d36 authorMatthew Griffith <mdg.griffith@gmail.com> dateSat 6 Jul 2019, 14:03 (7 years ago) parentf80c188
3 files changed+66−20
package.json+1−1 tests/automation/publish-file.sh+13−10 tests/automation/run.js+52−9
package.json+1−1
@@ -6,7 +6,7 @@
66 "scripts": {
77 "test": "elm-test",
88 "test-render": "node tests/automation/run.js --chrome",
9− "test-render-sauce": "source source.env; node tests/automation/run.js",
9+ "test-render-sauce": "source sauce.env; node tests/automation/run.js --sauce",
1010 "bench": "node benchmarks/runtime/index.js"
1111 },
1212 "repository": {
tests/automation/publish-file.sh+13−10
@@ -1,18 +1,21 @@
1+These env variables need to be set before running this script
2+# FILE="test.html"
3+# BUILD="1.1.0"
4+# NAME="development"
15DIRECTORY='./tmp/elm-ui-testing'
26
37# Check to see if the repo is already cloned locally
4−# if [ ! -d "$DIRECTORY" ]; then
5−# cd tmp
6−# git clone git@github.com:mdgriffith/elm-ui-testing.git
7−# else
8−# cd tmp
9−# git pull
10−# fi
11−
12−cp test.html elm-ui-testing/public/tests/test.html
8+cd tmp
9+if [ ! -d "$DIRECTORY" ]; then
10+ git clone git@github.com:mdgriffith/elm-ui-testing.git
11+else
12+ git pull
13+fi
14+mkdir -p "elm-ui-testing/public/tests/$BUILD/$NAME/"
15+cp "$FILE" "elm-ui-testing/public/tests/$BUILD/$NAME/index.html"
1316cd elm-ui-testing
1417git add .
15−git commit -m "Publish file from elm-ui suite"
18+git commit -m "Elm UI test for $NAME on $BUILD"
1619git push origin master
1720
1821echo "done"
tests/automation/run.js+52−9
@@ -6,14 +6,16 @@ const fs = require('fs');
66const program = require('commander');
77const path = require("path");
88const chalk = require('chalk');
9+const childProcess = require('child_process')
910
1011program.option('-s, --sauce', 'run tests on sauce labs')
1112 .option('--chrome', 'run only chrome tests')
1213 .option('--firefox', 'run only firefox tests')
13− .option('--build', 'Set build number for sauce labs')
14− .option('--name', 'Set run name for sauce labs')
14+ .option('--build [value]', 'Set build number for sauce labs')
15+ .option('--name [value]', 'Set run name for sauce labs')
1516 .parse(process.argv)
1617
18+
1719// 'Windows 10'
1820const windows = [
1921 {
@@ -58,8 +60,31 @@ const osx = {
5860}
5961
6062
61−function prepare_envs() {
62− return []
63+function prepare_all_envs(config) {
64+ var envs = []
65+
66+ for (i = 0; i < windows.length; i++) {
67+ envs.push({
68+ browser: windows[i].browser,
69+ browserVersion: windows[i].browserVersion,
70+ platform: "Windows 10",
71+ build: config.build,
72+ name: config.name
73+ })
74+ }
75+
76+ for (i = 0; i < osx.length; i++) {
77+ envs.push({
78+ browser: osx[i].browser,
79+ browserVersion: osx[i].browserVersion,
80+ platform: "macOS 10.14",
81+ build: config.build,
82+ name: config.name
83+ })
84+ }
85+
86+
87+ return envs
6388}
6489
6590async function compile_and_embed(config) {
@@ -139,11 +164,27 @@ async function run_test(driver, url) {
139164 if (program.sauce) {
140165 const build = program.build
141166 const name = program.name
167+
168+ if (build == null || name == null) {
169+ throw ("A Build and a Name must be specified.");
170+ }
171+
172+
142173 var results = []
143− console.log("TODO: PUBLISH FILE BEFORE TESTING")
144− var url = "fail"
145− // Publish to
146− const envs = prepare_envs({ build: build, name: name })
174+
175+ // Publish to netlify
176+ childProcess.execSync("sh tests/automation/publish-file.sh", {
177+ env: {
178+ FILE: "test.html",
179+ BUILD: program.build,
180+ NAME: program.name
181+ }
182+ })
183+ var url = `http://elm-ui-testing.netlify.com/tests/${program.build}/${program.name}/`
184+ console.log(`Running sauce labs test ${url}`)
185+
186+
187+ const envs = prepare_all_envs({ build: build, name: name })
147188 for (i = 0; i < envs.length; i++) {
148189 var driver = prepare_sauce_driver(envs[i])
149190 results.push(await run_test(driver, url))
@@ -151,7 +192,9 @@ async function run_test(driver, url) {
151192
152193
153194 } else {
154− if (program.chrome) {
195+
196+ // Run chrome if nothing else is selected
197+ if (program.chrome || (!program.chrome && !program.firefox)) {
155198 console.log("Running locally on Chrome...")
156199 const driver = await prepare_local_driver(osx.chrome)
157200 var results = await run_test(driver, "file://" + path.resolve('./tmp/test.html'))