Merge branch 'wood1986-features/no-ruby'

- Merges #1658 from @wood1986
- Fixes #883
This commit is contained in:
Gregg Van Hove
2019-03-25 17:56:19 -07:00
12 changed files with 332 additions and 35 deletions

View File

@@ -1,12 +1,7 @@
language: ruby
cache: bundler
sudo: false
language: node_js
node_js:
- "11"
rvm: 2.5
before_install:
- gem update --system
- gem install bundler
script: $TEST_COMMAND
env:

View File

@@ -6,15 +6,16 @@ module.exports = function(grunt) {
pkg: pkg,
jshint: require('./grunt/config/jshint.js'),
concat: require('./grunt/config/concat.js'),
compass: require('./grunt/config/compass.js'),
compress: require('./grunt/config/compress.js')
sass: require('./grunt/config/sass.js'),
compress: require('./grunt/config/compress.js'),
imageEmbed: require('./grunt/config/imageEmbed.js')
});
require('load-grunt-tasks')(grunt);
grunt.loadTasks('grunt/tasks');
grunt.registerTask('default', ['jshint:all']);
grunt.registerTask('default', ['jshint:all', 'sass:dist', "imageEmbed:dist"]);
var version = require('./grunt/tasks/version.js');
@@ -25,11 +26,11 @@ module.exports = function(grunt) {
grunt.registerTask('buildDistribution',
'Builds and lints jasmine.js, jasmine-html.js, jasmine.css',
[
'compass',
'sass:dist',
"imageEmbed:dist",
'jshint:beforeConcat',
'concat',
'jshint:afterConcat',
'build:copyVersionToGem'
'jshint:afterConcat'
]
);

205
ci.js Normal file
View File

@@ -0,0 +1,205 @@
const path = require("path"),
fs = require('fs'),
port = 5555,
colors = {
"passed" : "\x1B[32m",
"failed": "\x1B[31m",
"pending": "\x1B[33m",
"none": "\x1B[0m"
},
symbols = {
"passed" : ".",
"failed": "F",
"pending": "*",
"none": ""
},
host = `http://localhost:${port}`,
useSauce = process.env.USE_SAUCE === 'true';
let driver, server;
function pageGenerator() {
const ejs = require("ejs"),
fg = require("fast-glob"),
templatePath = path.resolve(__dirname, 'spec/support/index.html.ejs'),
template = ejs.compile(fs.readFileSync(templatePath).toString()),
patterns = [
"lib/jasmine-core/jasmine.js",
"lib/jasmine-core/json2.js",
"lib/jasmine-core/jasmine-html.js",
"lib/jasmine-core/boot.js",
"src/core/requireCore.js",
"src/core/base.js",
"src/core/util.js",
"src/core/Spec.js",
"src/core/Env.js",
"src/**/*.js",
"spec/helpers/*.js",
"spec/**/*[Ss]pec.js"
],
ignore = [
"spec/helpers/nodeDefineJasmineUnderTest.js",
"spec/npmPackage/**/*",
"lib/jasmine-core/node_boot.js"
];
return function toHtml() {
const files = fg.sync(patterns, {ignore});
return template({files});
}
}
function buildWebdriver() {
const webdriver = require("selenium-webdriver"),
Capability = webdriver.Capability;
if (useSauce) {
const username = process.env['SAUCE_USERNAME'],
accessKey = process.env['SAUCE_ACCESS_KEY'];
return new webdriver.Builder()
.withCapabilities({
name: `jasmine-core ${new Date().toISOString()}`,
[Capability.PLATFORM]: process.env['SAUCE_OS'],
[Capability.BROWSER_NAME]: process.env['JASMINE_BROWSER'],
[Capability.VERSION]: process.env['SAUCE_BROWSER_VERSION'],
build: `Core ${process.env['TRAVIS_BUILD_NUMBER'] || 'Ran locally'}`,
tags: ['Jasmine-Core'],
"tunnel-identifier": process.env['TRAVIS_JOB_NUMBER'] ? process.env['TRAVIS_BUILD_NUMBER'].toString() : null
})
.usingServer(`http://${username}:${accessKey}@localhost:4445/wd/hub`)
.build();
} else {
return new webdriver.Builder()
.forBrowser(process.env["JASMINE_BROWSER"] || "firefox")
.build();
}
}
async function resultsWithoutCircularReferences(driver, resultType, index, batchSize) {
return await driver.executeScript(
`var results = jsApiReporter.${resultType}Results(${index}, ${batchSize});\n` +
'for (var i = 0; i < results.length; i++) {\n' +
'var expectations = results[i].failedExpectations;\n' +
'if (results[i].passedExpectations) {\n' +
'expectations = expectations.concat(results[i].passedExpectations);\n' +
'}\n' +
'for (var j = 0; j < expectations.length; j++) {\n' +
'var expectation = expectations[j];\n' +
"try { JSON.stringify(expectation.expected); } catch (e) { expectation.expected = '<circular expected>'; }\n" +
"try { JSON.stringify(expectation.actual); } catch (e) { expectation.actual = '<circular actual>'; }\n" +
'}\n' +
'}\n' +
'return results;'
);
}
function flatten(arr) {
return Array.prototype.concat.apply([], arr);
}
async function getResults(driver) {
const batchSize = 50,
specResults = [],
failedSuiteResults = [];
let index = 0,
slice = [];
do {
slice = await resultsWithoutCircularReferences(driver, 'spec', index, batchSize);
specResults.push(slice);
index += batchSize;
} while (slice.length === batchSize);
index = 0;
do {
slice = await resultsWithoutCircularReferences(driver, 'suite', index, batchSize);
failedSuiteResults.push(slice.filter(function(suite) { return suite.status === 'failed' }));
index += batchSize;
} while (slice.length === batchSize);
return {specResults: flatten(specResults), failedSuiteResults: flatten(failedSuiteResults)};
}
(async function () {
await new Promise(resolve => {
console.log("Creating an express app for browers to run the tests...")
const express = require("express"),
app = express(),
html = pageGenerator();
app.use(express.static(__dirname));
app.get("/", (req, res) => res.send(html()));
server = app.listen(port, resolve);
});
console.log("Running the tests in browser...")
driver = buildWebdriver();
await driver.get(`${host}/?throwFailures=false&failFast=false&random=true`)
await new Promise(resolve => {
const intervalId = setInterval(async () => {
const isFinished = await driver.executeScript("return jsApiReporter && jsApiReporter.finished")
if (isFinished) {
clearInterval(intervalId)
resolve();
}
}, 500)
});
const {specResults, failedSuiteResults} = await getResults(driver);
console.log(specResults.map(spec => `${colors[spec.status]}${symbols[spec.status]}`).join("") + colors["none"]);
const result = specResults.reduce((result, spec) => {
result[spec.status] = [...result[spec.status], spec];
return result;
}, {pending: [], failed: [], passed: []});
if (result.pending.length) {
console.log(`${colors["pending"]}Pending:`);
result.pending.forEach((spec, index) => {
console.log(`${colors["none"]}${index}) ${spec.fullName}`)
console.group();
console.log(`${colors["pending"]}${spec.pendingReason || "no reason given"}`);
console.groupEnd();
console.log();
});
}
if (result.failed.length) {
process.exitCode = 1
console.log(`${colors["failed"]}Failed:`);
result["failed"].forEach((spec, index) => {
console.log(`${colors["none"]}${index}) ${spec.fullName}`)
console.group();
spec.failedExpectations.forEach((expect) => {
console.log(`${colors["none"]}Message:`);
console.group();
console.log(`${colors["failed"]}${expect.message}`);
console.groupEnd();
console.log(`${colors["none"]}Stack:`);
console.group();
console.log(`${colors["failed"]}${expect.stack}`);
console.groupEnd();
console.groupEnd();
})
console.groupEnd();
console.log();
});
}
const details = await driver.executeScript(`
return {
executionTime: jsApiReporter.executionTime(),
random: jsApiReporter.runDetails.order.random,
seed: jsApiReporter.runDetails.order.seed
}`);
console.log(`${colors["none"]}${specResults.length} spec(s), ${result.failed.length} failure(s), ${result.pending.length} pending spec(s)`);
console.log(`Finished in ${details.executionTime / 1000} second(s)`);
console.log(`Randomized with seed ${details.seed} ( ${host}/?random=${details.random}&seed=${details.seed} )`);
if (useSauce) {
driver.executeScript(`sauce:job-result=${exitCode === 0}`);
}
})().finally(() => {
return Promise.all([driver.close(), new Promise(resolve => server.close(resolve))]);
});

View File

@@ -1,11 +0,0 @@
module.exports = {
jasmine: {
options: {
cssDir: 'lib/jasmine-core/',
sassDir: 'src/html',
outputStyle: 'compact',
noLineComments: true,
bundleExec: true
}
}
};

View File

@@ -0,0 +1,7 @@
module.exports = {
dist: {
src: [ "lib/jasmine-core/jasmine.css" ],
dest: "lib/jasmine-core/jasmine.css",
baseDir: "images"
}
};

14
grunt/config/sass.js Normal file
View File

@@ -0,0 +1,14 @@
const sass = require('node-sass');
module.exports = {
options: {
implementation: sass,
outputStyle: 'compact',
sourceComments: false
},
dist: {
files: {
"lib/jasmine-core/jasmine.css": "src/html/jasmine.scss"
}
}
};

File diff suppressed because one or more lines are too long

View File

@@ -19,16 +19,22 @@
"homepage": "https://jasmine.github.io",
"main": "./lib/jasmine-core.js",
"devDependencies": {
"ejs": "^1.0.0",
"express": "^4.16.4",
"fast-glob": "^2.2.6",
"glob": "^7.1.3",
"grunt": "^1.0.3",
"grunt-cli": "^1.3.2",
"grunt-contrib-compass": "^1.1.1",
"grunt-contrib-compress": "^1.3.0",
"grunt-contrib-concat": "^1.0.1",
"grunt-contrib-jshint": "^2.0.0",
"grunt-image-embed": "^0.3.3",
"grunt-sass": "^3.0.2",
"jasmine": "^3.3.1",
"jsdom": "^13.1.0",
"load-grunt-tasks": "^4.0.0",
"node-sass": "^4.11.0",
"selenium-webdriver": "^3.6.0",
"shelljs": "^0.8.3",
"temp": "^0.9.0"
}

View File

@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html>
<head>
<title>Jasmine suite</title>
<link rel="shortcut icon" href="images/jasmine_favicon.png" type="image/png" />
<link rel="stylesheet" href="lib/jasmine-core/jasmine.css" type="text/css" media="screen" />
<% files.forEach(function(file) { %>
<script src="<%= file %>" type="text/javascript"></script>
<% }) %>
<body>
</body>
</html>

View File

@@ -1,5 +1,3 @@
@import "compass";
$line-height: 14px;
$margin-unit: 14px;
@@ -68,9 +66,12 @@ body {
}
.jasmine-banner .jasmine-title {
background: inline-image('jasmine-horizontal.png') no-repeat;
background: inline-image('jasmine-horizontal.svg') no-repeat, none;
@include background-size(100%);
background: url('../../images/jasmine-horizontal.png') no-repeat;
background: url('../../images/jasmine-horizontal.svg') no-repeat, none;
-moz-background-size: 100%;
-o-background-size: 100%;
-webkit-background-size: 100%;
background-size: 100%;
display: block;
float: left;
width: 90px;
@@ -110,7 +111,7 @@ body {
//--- Symbol summary ---//
.jasmine-symbol-summary {
@include clearfix;
overflow: hidden;
margin: $line-height 0;
li {

View File

@@ -9,4 +9,4 @@ then
fi
fi
bundle exec rake jasmine:ci
node ci.js

View File

@@ -11,4 +11,9 @@ if [ "$1" = "v4" ]; then
fi
npm install
if [ "$1" = "v8" ] || [ "$1" = "v9" ]; then
npm rebuild node-sass --force
fi
npm test