This commit is contained in:
Mislav Marohnić 2018-05-24 00:06:02 +02:00
Родитель 4f097017ca
Коммит a55b7d71ce
11 изменённых файлов: 1 добавлений и 296 удалений

Просмотреть файл

@ -10,7 +10,7 @@ before_script:
- sh -e /etc/init.d/xvfb start
cache:
directories:
- phantomjs
- node_modules
deploy:
provider: npm
email: mislav.marohnic@gmail.com

Просмотреть файл

@ -12,20 +12,4 @@ node_modules/:
clean:
rm -rf ./bower_components ./node_modules
ifeq ($(shell uname -s),Darwin)
sauce_connect/bin/sc:
wget https://saucelabs.com/downloads/sc-4.3.16-osx.zip
unzip sc-4.3.16-osx.zip
mv sc-4.3.16-osx sauce_connect
rm sc-4.3.16-osx.zip
else
sauce_connect/bin/sc:
mkdir -p sauce_connect
curl -fsSL http://saucelabs.com/downloads/sc-4.3.16-linux.tar.gz | tar xz -C sauce_connect --strip-components 1
endif
phantomjs/bin/phantomjs:
mkdir -p phantomjs
wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2 -O- | tar xj -C phantomjs --strip-components 1
.PHONY: clean lint test

Просмотреть файл

@ -1,36 +0,0 @@
#!/bin/bash
set -e
port=3900
# Find next available port
while lsof -i :$((++port)) >/dev/null; do true; done
# Spin a test server in the background
node ./script/server $port &>/dev/null &
server_pid=$!
trap "kill $server_pid" INT EXIT
STATUS=0
reporter=dot
[ -z "$CI" ] || reporter=spec
if [ -n "$TRAVIS" ]; then
make phantomjs/bin/phantomjs
export PATH="$PWD/phantomjs/bin:$PATH"
fi
run() {
phantomjs ./node_modules/mocha-phantomjs-core/mocha-phantomjs-core.js \
"$1" $reporter "{\"useColors\":true, \"hooks\":\"$PWD/test/mocha-phantomjs-hooks.js\"}" \
|| STATUS=$?
}
[ -z "$CI" ] || echo "phantomjs $(phantomjs -v)"
run "http://localhost:$port/"
run "http://localhost:$port/test/test-worker.html"
exit $STATUS

Просмотреть файл

@ -1,66 +0,0 @@
#!/bin/bash
set -e
port=8080
# Spin a test server in the background
node ./script/server $port &>/dev/null &
server_pid=$!
trap "kill $server_pid" INT EXIT
make sauce_connect/bin/sc
sauce_ready="${TMPDIR:-/tmp}/sauce-ready.$$"
sauce_connect/bin/sc -u "$SAUCE_USERNAME" -k "$SAUCE_ACCESS_KEY" \
-i "$TRAVIS_JOB_NUMBER" -l sauce_connect.log -f "$sauce_ready" &>/dev/null &
sauce_pid=$!
trap "kill $sauce_pid" INT EXIT
sauce_waited=0
while [ ! -f "$sauce_ready" ]; do
if [ "$sauce_waited" -gt 60000 ]; then
echo "sauce_connect failed to start within 60 seconds" >&2
exit 1
fi
sleep .01
sauce_waited=$((sauce_waited + 10))
done
echo "sauce_connect started within $sauce_waited ms"
rm -f "$sauce_ready"
job="$(./script/saucelabs-api --raw "js-tests" <<JSON
{ "public": "public",
"build": "$TRAVIS_BUILD_NUMBER",
"tags": ["$TRAVIS_PULL_REQUEST", "$TRAVIS_BRANCH"],
"tunnel-identifier": "$TRAVIS_JOB_NUMBER",
"platforms": [["$SAUCE_PLATFORM", "$SAUCE_BROWSER", "$SAUCE_VERSION"]],
"url": "http://localhost:$port/",
"framework": "mocha"
}
JSON
)"
while sleep 5; do
result=$(./script/saucelabs-api "js-tests/status" <<<"$job")
if grep -q '.status: test error' <<<"$result"; then
echo
echo "$result" >&2
exit 1
fi
grep -q "^completed: true" <<<"$result" && break
echo -n "."
done
echo
awk '
/result\.tests:/ { tests+=$(NF) }
/result\.passes:/ { passes+=$(NF) }
/result\.pending:/ { pending+=$(NF) }
/result\.failures:/ { failures+=$(NF) }
/\.url:/ { print $(NF) }
END {
printf "%d passed, %d pending, %d failures\n", passes, pending, failures
if (failures > 0 || tests != passes + pending || tests == 0) exit 1
}
' <<<"$result"

Просмотреть файл

@ -1,31 +0,0 @@
#!/bin/bash
set -e
set -o pipefail
raw=""
if [ "$1" = "--raw" ]; then
raw="1"
shift 1
fi
endpoint="$1"
curl -fsS -X POST "https://saucelabs.com/rest/v1/$SAUCE_USERNAME/${endpoint}" \
-u "$SAUCE_USERNAME:$SAUCE_ACCESS_KEY" \
-H "Content-Type: application/json" -d "@-" | \
{
if [ -n "$raw" ]; then
cat
else
ruby -rjson -e '
dump = lambda do |obj, ns|
case obj
when Array then obj.each_with_index { |v, i| dump.call(v, [ns, i]) }
when Hash then obj.each { |k, v| dump.call(v, [ns, k]) }
else puts "%s: %s" % [ ns.flatten.compact.join("."), obj.to_s ]
end
end
dump.call JSON.parse(STDIN.read), nil
'
fi
}

Просмотреть файл

@ -1,9 +0,0 @@
#!/bin/bash
set -e
if [ -n "$SAUCE_BROWSER" ]; then
./script/saucelabs
else
./script/phantomjs
fi

1
test/.gitignore поставляемый
Просмотреть файл

@ -1 +0,0 @@
server.pid

Просмотреть файл

@ -1,19 +0,0 @@
{
"extends": "../.jshintrc",
"es3": false,
"strict": false,
"sub": true,
"globals": {
"fetch": false,
"Headers": false,
"Request": false,
"Response": false,
"mocha": false,
"chai": false,
"suite": false,
"setup": false,
"suiteSetup": false,
"test": false,
"assert": false
}
}

Просмотреть файл

@ -1,8 +0,0 @@
exports.beforeStart = function(context) {
var originalResourceError = context.page.onResourceError
context.page.onResourceError = function(resErr) {
if (!/\/boom$/.test(resErr.url)) {
originalResourceError(resErr)
}
}
}

Просмотреть файл

@ -1,45 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Fetch Worker Tests</title>
<link rel="stylesheet" href="/node_modules/mocha/mocha.css" />
</head>
<body>
<div id="mocha"></div>
<script src="/node_modules/url-search-params/build/url-search-params.js"></script>
<script src="/node_modules/mocha/mocha.js"></script>
<script>
if (self.initMochaPhantomJS) {
self.initMochaPhantomJS()
}
mocha.setup('tdd')
mocha.suite.suites.unshift(Mocha.Suite.create(mocha.suite, "worker"))
var worker = new Worker('/test/worker.js')
worker.addEventListener('message', function(e) {
switch (e.data.name) {
case 'pass':
test(e.data.title, function() {})
break
case 'pending':
test(e.data.title)
break
case 'fail':
test(e.data.title, function() {
var err = new Error(e.data.message)
err.stack = e.data.stack
throw err
})
break
case 'end':
mocha.run()
break
}
})
</script>
</body>
</html>

Просмотреть файл

@ -1,64 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Fetch Tests</title>
<link rel="stylesheet" href="/node_modules/mocha/mocha.css" />
</head>
<body>
<div id="mocha"></div>
<script>
window.onerror = function(err) {
var container = document.getElementById('mocha')
var el = document.createElement('p')
el.textContent = err.toString()
el.style = 'color:#c00'
container.insertBefore(el, container.firstChild)
}
</script>
<script src="/node_modules/url-search-params/build/url-search-params.js"></script>
<script src="/node_modules/chai/chai.js"></script>
<script src="/node_modules/mocha/mocha.js"></script>
<script>
if (self.initMochaPhantomJS) {
self.initMochaPhantomJS()
}
if (self.mocha && mocha.setup) {
mocha.setup('tdd')
self.assert = chai.assert
} else {
document.write('<p>Error: please run <code>make</code> to install dependencies and try again.</p>')
}
</script>
<script src="/node_modules/promise-polyfill/promise.js"></script>
<script src="/node_modules/abortcontroller-polyfill/dist/abortcontroller-polyfill-only.js"></script>
<script src="/dist/fetch.umd.js"></script>
<script src="/test/test.js"></script>
<script>
var runner = mocha.run();
var failedTests = [];
runner.on('end', function(){
window.mochaResults = runner.stats;
window.mochaResults.reports = failedTests;
});
runner.on('fail', function(test, err){
function flattenTitles(test){
var titles = [];
while (test.parent.title){
titles.push(test.parent.title);
test = test.parent;
}
return titles.reverse();
};
failedTests.push({name: test.title, result: false, message: err.message, stack: err.stack, titles: flattenTitles(test) });
});
</script>
</body>
</html>