Merge branch 'degrunt'
This commit is contained in:
@@ -61,7 +61,7 @@ jobs:
|
|||||||
at: .
|
at: .
|
||||||
- run:
|
- run:
|
||||||
name: Run tests in parallel
|
name: Run tests in parallel
|
||||||
command: npx grunt execSpecsInParallel
|
command: npm run test:parallel
|
||||||
|
|
||||||
test_browsers: &test_browsers
|
test_browsers: &test_browsers
|
||||||
executor: node18
|
executor: node18
|
||||||
|
|||||||
@@ -3,6 +3,6 @@ charset = utf-8
|
|||||||
end_of_line = lf
|
end_of_line = lf
|
||||||
insert_final_newline = true
|
insert_final_newline = true
|
||||||
|
|
||||||
[*.{js, mjs, json, sh, yml}]
|
[*.{js,mjs,json,sh,yml}]
|
||||||
indent_style = space
|
indent_style = space
|
||||||
indent_size = 2
|
indent_size = 2
|
||||||
|
|||||||
47
.eslintrc
47
.eslintrc
@@ -1,47 +0,0 @@
|
|||||||
{
|
|
||||||
"extends": [
|
|
||||||
"plugin:compat/recommended"
|
|
||||||
],
|
|
||||||
"env": {
|
|
||||||
"browser": true,
|
|
||||||
"node": true,
|
|
||||||
"es2017": true
|
|
||||||
},
|
|
||||||
"parserOptions": {
|
|
||||||
"ecmaVersion": 2018
|
|
||||||
},
|
|
||||||
"rules": {
|
|
||||||
"curly": "error",
|
|
||||||
"quotes": [
|
|
||||||
"error",
|
|
||||||
"single",
|
|
||||||
{
|
|
||||||
"avoidEscape": true
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"no-unused-vars": [
|
|
||||||
"error",
|
|
||||||
{
|
|
||||||
"args": "none"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"no-implicit-globals": "error",
|
|
||||||
"block-spacing": "error",
|
|
||||||
"func-call-spacing": [
|
|
||||||
"error",
|
|
||||||
"never"
|
|
||||||
],
|
|
||||||
"key-spacing": "error",
|
|
||||||
"no-tabs": "error",
|
|
||||||
"no-trailing-spaces": "error",
|
|
||||||
"no-whitespace-before-property": "error",
|
|
||||||
"semi": [
|
|
||||||
"error",
|
|
||||||
"always"
|
|
||||||
],
|
|
||||||
"space-before-blocks": "error",
|
|
||||||
"no-eval": "error",
|
|
||||||
"no-var": "error",
|
|
||||||
"no-debugger": "error"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
104
Gruntfile.js
104
Gruntfile.js
@@ -1,104 +0,0 @@
|
|||||||
module.exports = function(grunt) {
|
|
||||||
var pkg = require("./package.json");
|
|
||||||
global.jasmineVersion = pkg.version;
|
|
||||||
|
|
||||||
grunt.initConfig({
|
|
||||||
pkg: pkg,
|
|
||||||
concat: require('./grunt/config/concat.js'),
|
|
||||||
sass: require('./grunt/config/sass.js'),
|
|
||||||
compress: require('./grunt/config/compress.js'),
|
|
||||||
cssUrlEmbed: require('./grunt/config/cssUrlEmbed.js')
|
|
||||||
});
|
|
||||||
|
|
||||||
require('load-grunt-tasks')(grunt);
|
|
||||||
|
|
||||||
grunt.loadTasks('grunt/tasks');
|
|
||||||
|
|
||||||
grunt.registerTask('default', ['sass:dist', "cssUrlEmbed"]);
|
|
||||||
|
|
||||||
grunt.registerTask('buildDistribution',
|
|
||||||
'Builds and lints jasmine.js, jasmine-html.js, jasmine.css',
|
|
||||||
[
|
|
||||||
'sass:dist',
|
|
||||||
"cssUrlEmbed",
|
|
||||||
'concat'
|
|
||||||
]
|
|
||||||
);
|
|
||||||
|
|
||||||
grunt.registerTask("execSpecsInNode",
|
|
||||||
"Run Jasmine core specs in Node.js",
|
|
||||||
function() {
|
|
||||||
verifyNoGlobals(() => require('./lib/jasmine-core.js').noGlobals());
|
|
||||||
const done = this.async(),
|
|
||||||
Jasmine = require('jasmine'),
|
|
||||||
jasmineCore = require('./lib/jasmine-core.js'),
|
|
||||||
jasmine = new Jasmine({jasmineCore: jasmineCore});
|
|
||||||
|
|
||||||
jasmine.loadConfigFile('./spec/support/jasmine.json');
|
|
||||||
jasmine.exitOnCompletion = false;
|
|
||||||
jasmine.execute().then(
|
|
||||||
result => done(result.overallStatus === 'passed'),
|
|
||||||
err => {
|
|
||||||
console.error(err);
|
|
||||||
done(false);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
grunt.registerTask("execSpecsInParallel",
|
|
||||||
"Run Jasmine core specs in parallel in Node.js",
|
|
||||||
function() {
|
|
||||||
// Need to require this here rather than at the top of the file
|
|
||||||
// so that we don't break verifyNoGlobals above by loading jasmine-core
|
|
||||||
// too early
|
|
||||||
const ParallelRunner = require('jasmine/parallel');
|
|
||||||
let numWorkers = require('os').cpus().length;
|
|
||||||
|
|
||||||
if (process.env['CIRCLECI']) {
|
|
||||||
// On Circle CI, the above gives the number of CPU cores on the host
|
|
||||||
// computer, which is unrelated to the resources actually available
|
|
||||||
// to the container. 2 workers gives peak performance with our current
|
|
||||||
// configuration, but 4 might increase the odds of discovering any
|
|
||||||
// parallel-specific bugs.
|
|
||||||
numWorkers = 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
const done = this.async();
|
|
||||||
const runner = new ParallelRunner({
|
|
||||||
jasmineCore: require('./lib/jasmine-core.js'),
|
|
||||||
numWorkers
|
|
||||||
});
|
|
||||||
|
|
||||||
runner.loadConfigFile('./spec/support/jasmine.json')
|
|
||||||
.then(() => {
|
|
||||||
runner.exitOnCompletion = false;
|
|
||||||
return runner.execute();
|
|
||||||
}).then(
|
|
||||||
jasmineDoneInfo => done(jasmineDoneInfo.overallStatus === 'passed'),
|
|
||||||
err => {
|
|
||||||
console.error(err);
|
|
||||||
done(false);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
grunt.registerTask("execSpecsInNode:performance",
|
|
||||||
"Run Jasmine performance specs in Node.js",
|
|
||||||
function() {
|
|
||||||
require("shelljs").exec("node_modules/.bin/jasmine JASMINE_CONFIG_PATH=spec/support/jasmine-performance.json");
|
|
||||||
}
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
function verifyNoGlobals(fn) {
|
|
||||||
const initialGlobals = Object.keys(global);
|
|
||||||
fn();
|
|
||||||
|
|
||||||
const extras = Object.keys(global).filter(k => !initialGlobals.includes(k));
|
|
||||||
|
|
||||||
if (extras.length !== 0) {
|
|
||||||
throw new Error('Globals were unexpectedly created: ' + extras.join(', '));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -41,7 +41,7 @@ When ready to release - specs are all green and the stories are done:
|
|||||||
|
|
||||||
### Build standalone distribution
|
### Build standalone distribution
|
||||||
|
|
||||||
1. Build the standalone distribution with `grunt buildStandaloneDist`
|
1. Build the standalone distribution with `npm run buildStandaloneDist`
|
||||||
1. This will generate `dist/jasmine-standalone-<version>.zip`, which you will upload later (see "Finally" below).
|
1. This will generate `dist/jasmine-standalone-<version>.zip`, which you will upload later (see "Finally" below).
|
||||||
|
|
||||||
### Release the core NPM module
|
### Release the core NPM module
|
||||||
|
|||||||
@@ -1,57 +0,0 @@
|
|||||||
var standaloneLibDir = "lib/jasmine-" + jasmineVersion;
|
|
||||||
|
|
||||||
function root(path) { return "./" + path; }
|
|
||||||
function libJasmineCore(path) { return root("lib/jasmine-core/" + path); }
|
|
||||||
function dist(path) { return root("dist/" + path); }
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
standalone: {
|
|
||||||
options: {
|
|
||||||
archive: root("dist/jasmine-standalone-" + global.jasmineVersion + ".zip")
|
|
||||||
},
|
|
||||||
|
|
||||||
files: [
|
|
||||||
{ src: [ root("LICENSE") ] },
|
|
||||||
{
|
|
||||||
src: [ "jasmine_favicon.png"],
|
|
||||||
dest: standaloneLibDir,
|
|
||||||
expand: true,
|
|
||||||
cwd: root("images")
|
|
||||||
},
|
|
||||||
{
|
|
||||||
src: [
|
|
||||||
"jasmine.js",
|
|
||||||
"jasmine-html.js",
|
|
||||||
"jasmine.css"
|
|
||||||
],
|
|
||||||
dest: standaloneLibDir,
|
|
||||||
expand: true,
|
|
||||||
cwd: libJasmineCore("")
|
|
||||||
},
|
|
||||||
{
|
|
||||||
src: [ "boot0.js", "boot1.js" ],
|
|
||||||
dest: standaloneLibDir,
|
|
||||||
expand: true,
|
|
||||||
cwd: libJasmineCore("")
|
|
||||||
},
|
|
||||||
{
|
|
||||||
src: [ "SpecRunner.html" ],
|
|
||||||
dest: root(""),
|
|
||||||
expand: true,
|
|
||||||
cwd: dist("tmp")
|
|
||||||
},
|
|
||||||
{
|
|
||||||
src: [ "*.js" ],
|
|
||||||
dest: "src",
|
|
||||||
expand: true,
|
|
||||||
cwd: libJasmineCore("example/src/")
|
|
||||||
},
|
|
||||||
{
|
|
||||||
src: [ "*.js" ],
|
|
||||||
dest: "spec",
|
|
||||||
expand: true,
|
|
||||||
cwd: libJasmineCore("example/spec/")
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@@ -1,56 +0,0 @@
|
|||||||
var grunt = require('grunt');
|
|
||||||
|
|
||||||
function license() {
|
|
||||||
var currentYear = "" + new Date(Date.now()).getFullYear();
|
|
||||||
|
|
||||||
return grunt.template.process(
|
|
||||||
grunt.file.read("grunt/templates/licenseBanner.js.jst"),
|
|
||||||
{ data: { currentYear: currentYear}});
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
'jasmine-html': {
|
|
||||||
src: [
|
|
||||||
'src/html/requireHtml.js',
|
|
||||||
'src/html/HtmlReporter.js',
|
|
||||||
'src/html/HtmlSpecFilter.js',
|
|
||||||
'src/html/ResultsNode.js',
|
|
||||||
'src/html/QueryString.js',
|
|
||||||
'src/html/**/*.js'
|
|
||||||
],
|
|
||||||
dest: 'lib/jasmine-core/jasmine-html.js'
|
|
||||||
},
|
|
||||||
jasmine: {
|
|
||||||
src: [
|
|
||||||
'src/core/requireCore.js',
|
|
||||||
'src/core/matchers/requireMatchers.js',
|
|
||||||
'src/core/base.js',
|
|
||||||
'src/core/util.js',
|
|
||||||
'src/core/Spec.js',
|
|
||||||
'src/core/Order.js',
|
|
||||||
'src/core/Env.js',
|
|
||||||
'src/core/JsApiReporter.js',
|
|
||||||
'src/core/PrettyPrinter',
|
|
||||||
'src/core/Suite',
|
|
||||||
'src/core/**/*.js',
|
|
||||||
'src/version.js'
|
|
||||||
],
|
|
||||||
dest: 'lib/jasmine-core/jasmine.js'
|
|
||||||
},
|
|
||||||
boot0: {
|
|
||||||
src: ['src/boot/boot0.js'],
|
|
||||||
dest: 'lib/jasmine-core/boot0.js'
|
|
||||||
},
|
|
||||||
boot1: {
|
|
||||||
src: ['src/boot/boot1.js'],
|
|
||||||
dest: 'lib/jasmine-core/boot1.js'
|
|
||||||
},
|
|
||||||
options: {
|
|
||||||
banner: license(),
|
|
||||||
process: {
|
|
||||||
data: {
|
|
||||||
version: global.jasmineVersion
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
module.exports = {
|
|
||||||
encodeWithBaseDir: {
|
|
||||||
files: {
|
|
||||||
"lib/jasmine-core/jasmine.css": ["lib/jasmine-core/jasmine.css"]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
const sass = require('sass');
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
options: {
|
|
||||||
implementation: sass,
|
|
||||||
sourceComments: false
|
|
||||||
},
|
|
||||||
dist: {
|
|
||||||
files: {
|
|
||||||
"lib/jasmine-core/jasmine.css": "src/html/jasmine.scss"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
var grunt = require("grunt");
|
|
||||||
|
|
||||||
function standaloneTmpDir(path) { return "dist/tmp/" + path; }
|
|
||||||
|
|
||||||
grunt.registerTask("build:compileSpecRunner",
|
|
||||||
"Processes the spec runner template and writes to a tmp file",
|
|
||||||
function() {
|
|
||||||
var runnerHtml = grunt.template.process(
|
|
||||||
grunt.file.read("grunt/templates/SpecRunner.html.jst"),
|
|
||||||
{ data: { jasmineVersion: global.jasmineVersion }});
|
|
||||||
|
|
||||||
grunt.file.write(standaloneTmpDir("SpecRunner.html"), runnerHtml);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
grunt.registerTask("build:cleanSpecRunner",
|
|
||||||
"Deletes the tmp spec runner file",
|
|
||||||
function() {
|
|
||||||
grunt.file.delete(standaloneTmpDir(""));
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
grunt.registerTask("buildStandaloneDist",
|
|
||||||
"Builds a standalone distribution",
|
|
||||||
[
|
|
||||||
"buildDistribution",
|
|
||||||
"build:compileSpecRunner",
|
|
||||||
"compress:standalone",
|
|
||||||
"build:cleanSpecRunner"
|
|
||||||
]
|
|
||||||
);
|
|
||||||
@@ -21,6 +21,7 @@ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|||||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This file starts the process of "booting" Jasmine. It initializes Jasmine,
|
This file starts the process of "booting" Jasmine. It initializes Jasmine,
|
||||||
makes its globals available, and creates the env. This file should be loaded
|
makes its globals available, and creates the env. This file should be loaded
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|||||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This file finishes 'booting' Jasmine, performing all of the necessary
|
This file finishes 'booting' Jasmine, performing all of the necessary
|
||||||
initialization before executing the loaded environment and all of a project's
|
initialization before executing the loaded environment and all of a project's
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|||||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// eslint-disable-next-line no-var
|
// eslint-disable-next-line no-var
|
||||||
var jasmineRequire = window.jasmineRequire || require('./jasmine.js');
|
var jasmineRequire = window.jasmineRequire || require('./jasmine.js');
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|||||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// eslint-disable-next-line no-unused-vars,no-var
|
// eslint-disable-next-line no-unused-vars,no-var
|
||||||
var getJasmineRequireObj = (function(jasmineGlobal) {
|
var getJasmineRequireObj = (function(jasmineGlobal) {
|
||||||
let jasmineRequire;
|
let jasmineRequire;
|
||||||
|
|||||||
16
package.json
16
package.json
@@ -15,9 +15,11 @@
|
|||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"posttest": "eslint \"src/**/*.js\" \"spec/**/*.js\" && prettier --check \"src/**/*.js\" \"spec/**/*.js\"",
|
"posttest": "eslint \"src/**/*.js\" \"spec/**/*.js\" && prettier --check \"src/**/*.js\" \"spec/**/*.js\"",
|
||||||
"test": "grunt --stack execSpecsInNode",
|
"test": "node scripts/runSpecsInNode.js",
|
||||||
|
"test:parallel": "node scripts/runSpecsInParallel.js",
|
||||||
"cleanup": "prettier --write \"src/**/*.js\" \"spec/**/*.js\"",
|
"cleanup": "prettier --write \"src/**/*.js\" \"spec/**/*.js\"",
|
||||||
"build": "grunt buildDistribution",
|
"build": "node scripts/buildDistribution.js",
|
||||||
|
"buildStandaloneDist": "node scripts/buildStandaloneDist.js",
|
||||||
"serve": "node spec/support/localJasmineBrowser.js",
|
"serve": "node spec/support/localJasmineBrowser.js",
|
||||||
"serve:performance": "node spec/support/localJasmineBrowser.js jasmine-browser-performance.json",
|
"serve:performance": "node spec/support/localJasmineBrowser.js jasmine-browser-performance.json",
|
||||||
"ci": "node spec/support/ci.js",
|
"ci": "node spec/support/ci.js",
|
||||||
@@ -36,20 +38,16 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@eslint/eslintrc": "^3.3.1",
|
"@eslint/eslintrc": "^3.3.1",
|
||||||
"@eslint/js": "^9.24.0",
|
"@eslint/js": "^9.24.0",
|
||||||
|
"archiver": "^7.0.1",
|
||||||
|
"css-url-embed": "^0.1.0",
|
||||||
|
"ejs": "^3.1.10",
|
||||||
"eslint": "^9.24.0",
|
"eslint": "^9.24.0",
|
||||||
"eslint-plugin-compat": "^6.0.2",
|
"eslint-plugin-compat": "^6.0.2",
|
||||||
"glob": "^10.2.3",
|
"glob": "^10.2.3",
|
||||||
"globals": "^16.0.0",
|
"globals": "^16.0.0",
|
||||||
"grunt": "^1.0.4",
|
|
||||||
"grunt-cli": "^1.3.2",
|
|
||||||
"grunt-contrib-compress": "^2.0.0",
|
|
||||||
"grunt-contrib-concat": "^2.0.0",
|
|
||||||
"grunt-css-url-embed": "^1.11.1",
|
|
||||||
"grunt-sass": "^4.0.0",
|
|
||||||
"jasmine": "^5.0.0",
|
"jasmine": "^5.0.0",
|
||||||
"jasmine-browser-runner": "github:jasmine/jasmine-browser-runner",
|
"jasmine-browser-runner": "github:jasmine/jasmine-browser-runner",
|
||||||
"jsdom": "^26.0.0",
|
"jsdom": "^26.0.0",
|
||||||
"load-grunt-tasks": "^5.1.0",
|
|
||||||
"prettier": "1.17.1",
|
"prettier": "1.17.1",
|
||||||
"rimraf": "^5.0.10",
|
"rimraf": "^5.0.10",
|
||||||
"sass": "^1.58.3",
|
"sass": "^1.58.3",
|
||||||
|
|||||||
3
scripts/buildDistribution.js
Normal file
3
scripts/buildDistribution.js
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
const buildDistribution = require('./lib/buildDistribution');
|
||||||
|
|
||||||
|
buildDistribution();
|
||||||
92
scripts/buildStandaloneDist.js
Normal file
92
scripts/buildStandaloneDist.js
Normal file
@@ -0,0 +1,92 @@
|
|||||||
|
const fs = require('fs');
|
||||||
|
const path = require('path');
|
||||||
|
const glob = require('glob');
|
||||||
|
const ejs = require('ejs');
|
||||||
|
const archiver = require('archiver');
|
||||||
|
const { rimrafSync } = require('rimraf');
|
||||||
|
const buildDistribution = require('./lib/buildDistribution');
|
||||||
|
|
||||||
|
const tmpDir = 'dist/tmp'
|
||||||
|
|
||||||
|
if (!fs.existsSync(tmpDir)) {
|
||||||
|
if (!fs.existsSync(path.dirname(tmpDir))) {
|
||||||
|
fs.mkdirSync(path.dirname(tmpDir));
|
||||||
|
}
|
||||||
|
fs.mkdirSync(tmpDir);
|
||||||
|
}
|
||||||
|
|
||||||
|
buildStandaloneDist().finally(function() {
|
||||||
|
rimrafSync(tmpDir);
|
||||||
|
});
|
||||||
|
|
||||||
|
async function buildStandaloneDist() {
|
||||||
|
buildDistribution();
|
||||||
|
const pkg = JSON.parse(fs.readFileSync('package.json'));
|
||||||
|
compileSpecRunner(pkg.version);
|
||||||
|
await zipStandaloneDist(pkg.version);
|
||||||
|
}
|
||||||
|
|
||||||
|
function compileSpecRunner(jasmineVersion) {
|
||||||
|
const template = fs.readFileSync('src/SpecRunner.html.ejs',
|
||||||
|
{encoding: 'utf8'});
|
||||||
|
const runnerHtml = ejs.render(template, { jasmineVersion });
|
||||||
|
fs.writeFileSync('dist/tmp/SpecRunner.html', runnerHtml,
|
||||||
|
{encoding: 'utf8'});
|
||||||
|
}
|
||||||
|
|
||||||
|
async function zipStandaloneDist(jasmineVersion) {
|
||||||
|
const fileGroups = [
|
||||||
|
{
|
||||||
|
src: [
|
||||||
|
'LICENSE',
|
||||||
|
'dist/tmp/SpecRunner.html',
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
src: [
|
||||||
|
'images/jasmine_favicon.png',
|
||||||
|
'lib/jasmine-core/jasmine.js',
|
||||||
|
'lib/jasmine-core/jasmine-html.js',
|
||||||
|
'lib/jasmine-core/jasmine.css',
|
||||||
|
'lib/jasmine-core/boot0.js',
|
||||||
|
'lib/jasmine-core/boot1.js',
|
||||||
|
],
|
||||||
|
destDir: 'lib/jasmine-' + jasmineVersion
|
||||||
|
},
|
||||||
|
{
|
||||||
|
src: glob.sync('lib/jasmine-core/example/src/*.js'),
|
||||||
|
destDir: 'src'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
src: glob.sync('lib/jasmine-core/example/spec/*.js'),
|
||||||
|
destDir: 'spec'
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
const destPath = `./dist/jasmine-standalone-${jasmineVersion}.zip`;
|
||||||
|
const output = fs.createWriteStream(destPath);
|
||||||
|
const archive = archiver('zip');
|
||||||
|
|
||||||
|
const done = new Promise(function(resolve, reject) {
|
||||||
|
output.on('close', resolve);
|
||||||
|
archive.on('warning', reject);
|
||||||
|
archive.on('error', reject);
|
||||||
|
});
|
||||||
|
|
||||||
|
archive.pipe(output);
|
||||||
|
|
||||||
|
for (const group of fileGroups) {
|
||||||
|
for (const srcPath of group.src) {
|
||||||
|
let destPath = path.basename(srcPath);
|
||||||
|
|
||||||
|
if (group.destDir) {
|
||||||
|
destPath = `${group.destDir}/${destPath}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
archive.file(srcPath, {name: destPath});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
archive.finalize();
|
||||||
|
await done;
|
||||||
|
}
|
||||||
129
scripts/lib/buildDistribution.js
Normal file
129
scripts/lib/buildDistribution.js
Normal file
@@ -0,0 +1,129 @@
|
|||||||
|
const fs = require('fs');
|
||||||
|
const sass = require('sass');
|
||||||
|
const glob = require('glob');
|
||||||
|
const ejs = require('ejs');
|
||||||
|
const cssUrlEmbed = require('css-url-embed');
|
||||||
|
|
||||||
|
function buildDistribution() {
|
||||||
|
compileSass();
|
||||||
|
embedCssAssets();
|
||||||
|
concatFiles();
|
||||||
|
}
|
||||||
|
|
||||||
|
function embedCssAssets() {
|
||||||
|
const cssPath = 'lib/jasmine-core/jasmine.css';
|
||||||
|
cssUrlEmbed.processFile(cssPath, cssPath, function(filePath) {
|
||||||
|
if (filePath.endsWith('.png')) {
|
||||||
|
return 'image/png';
|
||||||
|
} else if (filePath.endsWith('.svg')) {
|
||||||
|
return 'image/svg+xml';
|
||||||
|
} else {
|
||||||
|
throw new Error(`Don't know MIME type for file: ${filePath}`);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function compileSass() {
|
||||||
|
const output = sass.compile('src/html/jasmine.scss');
|
||||||
|
fs.writeFileSync('lib/jasmine-core/jasmine.css', output.css,
|
||||||
|
{encoding: 'utf8'});
|
||||||
|
}
|
||||||
|
|
||||||
|
function concatFiles() {
|
||||||
|
const pkg = JSON.parse(fs.readFileSync('package.json'));
|
||||||
|
const configs = [
|
||||||
|
{
|
||||||
|
src: [
|
||||||
|
'src/html/requireHtml.js',
|
||||||
|
'src/html/HtmlReporter.js',
|
||||||
|
'src/html/HtmlSpecFilter.js',
|
||||||
|
'src/html/ResultsNode.js',
|
||||||
|
'src/html/QueryString.js',
|
||||||
|
'src/html/**/*.js'
|
||||||
|
],
|
||||||
|
dest: 'lib/jasmine-core/jasmine-html.js',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
dest: 'lib/jasmine-core/jasmine.js',
|
||||||
|
src: [
|
||||||
|
'src/core/requireCore.js',
|
||||||
|
'src/core/matchers/requireMatchers.js',
|
||||||
|
'src/core/base.js',
|
||||||
|
'src/core/util.js',
|
||||||
|
'src/core/Spec.js',
|
||||||
|
'src/core/Order.js',
|
||||||
|
'src/core/Env.js',
|
||||||
|
'src/core/JsApiReporter.js',
|
||||||
|
'src/core/PrettyPrinter',
|
||||||
|
'src/core/Suite',
|
||||||
|
'src/core/**/*.js',
|
||||||
|
{
|
||||||
|
template: 'src/version.js',
|
||||||
|
data: {version: pkg.version}
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
dest: 'lib/jasmine-core/boot0.js',
|
||||||
|
src: ['src/boot/boot0.js'],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
dest: 'lib/jasmine-core/boot1.js',
|
||||||
|
src: ['src/boot/boot1.js'],
|
||||||
|
}
|
||||||
|
];
|
||||||
|
const licenseBanner = {
|
||||||
|
template: 'src/licenseBanner.js.ejs',
|
||||||
|
data: {currentYear: new Date(Date.now()).getFullYear()}
|
||||||
|
};
|
||||||
|
|
||||||
|
for (const {src, dest} of configs) {
|
||||||
|
src.unshift(licenseBanner);
|
||||||
|
|
||||||
|
function expand(srcListEntry) {
|
||||||
|
if (typeof srcListEntry === 'object') {
|
||||||
|
return srcListEntry;
|
||||||
|
}
|
||||||
|
|
||||||
|
return glob.sync(srcListEntry)
|
||||||
|
.sort(function (a, b) {
|
||||||
|
// Match the sort order of previous build tools, so that the
|
||||||
|
// output is the same.
|
||||||
|
a = a.toLowerCase();
|
||||||
|
b = b.toLowerCase();
|
||||||
|
|
||||||
|
if (a < b) {
|
||||||
|
return -1;
|
||||||
|
} else if (a === b) {
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const srcs = src.flatMap(expand);
|
||||||
|
const seen = new Set();
|
||||||
|
const chunks = [];
|
||||||
|
|
||||||
|
for (const s of srcs) {
|
||||||
|
let content;
|
||||||
|
|
||||||
|
if (!seen.has(s)) {
|
||||||
|
if (s.template) {
|
||||||
|
const template = fs.readFileSync(s.template, {encoding: 'utf8'});
|
||||||
|
content = ejs.render(template, s.data);
|
||||||
|
} else {
|
||||||
|
content = fs.readFileSync(s, {encoding: 'utf8'});
|
||||||
|
}
|
||||||
|
|
||||||
|
chunks.push(content);
|
||||||
|
seen.add(s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fs.writeFileSync(dest, chunks.join('\n'), {encoding: 'utf8'});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = buildDistribution;
|
||||||
28
scripts/runSpecsInNode.js
Normal file
28
scripts/runSpecsInNode.js
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
verifyNoGlobals(() => require('../lib/jasmine-core.js').noGlobals());
|
||||||
|
|
||||||
|
const Jasmine = require('jasmine');
|
||||||
|
const jasmineCore = require('../lib/jasmine-core.js');
|
||||||
|
const runner = new Jasmine({jasmineCore: jasmineCore});
|
||||||
|
|
||||||
|
runner.loadConfigFile('./spec/support/jasmine.json');
|
||||||
|
runner.exitOnCompletion = false;
|
||||||
|
runner.execute()
|
||||||
|
.then(
|
||||||
|
result => result.overallStatus === 'passed',
|
||||||
|
err => {
|
||||||
|
console.error(err);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.then(ok => process.exit(ok ? 0 : 1));
|
||||||
|
|
||||||
|
function verifyNoGlobals(fn) {
|
||||||
|
const initialGlobals = Object.keys(global);
|
||||||
|
fn();
|
||||||
|
|
||||||
|
const extras = Object.keys(global).filter(k => !initialGlobals.includes(k));
|
||||||
|
|
||||||
|
if (extras.length !== 0) {
|
||||||
|
throw new Error('Globals were unexpectedly created: ' + extras.join(', '));
|
||||||
|
}
|
||||||
|
}
|
||||||
28
scripts/runSpecsInParallel.js
Normal file
28
scripts/runSpecsInParallel.js
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
const ParallelRunner = require('jasmine/parallel');
|
||||||
|
const jasmineCore = require('../lib/jasmine-core.js');
|
||||||
|
let numWorkers = require('os').cpus().length;
|
||||||
|
|
||||||
|
if (process.env['CIRCLECI']) {
|
||||||
|
// On Circle CI, the above gives the number of CPU cores on the host
|
||||||
|
// computer, which is unrelated to the resources actually available
|
||||||
|
// to the container. 2 workers gives peak performance with our current
|
||||||
|
// configuration, but 4 might increase the odds of discovering any
|
||||||
|
// parallel-specific bugs.
|
||||||
|
numWorkers = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
const runner = new ParallelRunner({jasmineCore, numWorkers});
|
||||||
|
|
||||||
|
runner.loadConfigFile('./spec/support/jasmine.json')
|
||||||
|
.then(() => {
|
||||||
|
runner.exitOnCompletion = false;
|
||||||
|
return runner.execute();
|
||||||
|
})
|
||||||
|
.then(
|
||||||
|
jasmineDoneInfo => jasmineDoneInfo.overallStatus === 'passed',
|
||||||
|
err => {
|
||||||
|
console.error(err);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.then(ok => process.exit(ok ? 0 : 1));
|
||||||
Reference in New Issue
Block a user