@@ -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'))