ソースを参照

Removed unused gulp testing tasks and testing under node.js.

Szymon Kupś 9 年 前
コミット
38a8afb8f0
4 ファイル変更1 行追加254 行削除
  1. 0 164
      dev/tasks/test/tasks.js
  2. 0 77
      dev/tests/test/tasks.js
  3. 0 2
      gulpfile.js
  4. 1 11
      package.json

+ 0 - 164
dev/tasks/test/tasks.js

@@ -1,164 +0,0 @@
-/* jshint node: true, esnext: true */
-
-'use strict';
-
-const gulp = require( 'gulp' );
-const istanbul = require( 'gulp-istanbul' );
-const gutil = require( 'gulp-util' );
-const mocha = require( 'gulp-mocha' );
-const chai = require( 'chai' );
-const filterBy = require( 'gulp-filter-by' );
-const filter = require( 'gulp-filter' );
-const sinon = require( 'sinon' );
-const semver = require( 'semver' );
-const { tools, stream } = require( 'ckeditor5-dev-utils' );
-const benderConfig = require( '../../../bender' );
-
-/**
- * Defines Node.js testing task and development tools testing tasks.
- *
- * To run tests under Node.js:
- *
- *		gulp test:node
- *
- * To run build under Node.js before testing:
- *
- *		gulp test:node:build
- *
- * To run testing under Node.js with code coverage:
- *
- *		gulp test:node:coverage
- *
- * To run development tools tests:
- *
- * 		gulp test:dev
- *
- * To run development tools tests with coverage:
- *
- * 		gulp test:dev:coverage
- */
-module.exports = () => {
-	const ignoreRegexp = /\/\* ?bender-tags:.*\bbrowser-only\b.*\*\//;
-
-	// Inject globals before running tests.
-	global.should = chai.should;
-	global.expect = chai.expect;
-	global.assert = chai.assert;
-	global.sinon = sinon;
-
-	const tasks = {
-		/**
-		 * Is set to `true` when code coverage report will be displayed.
-		 *
-		 * @type {Boolean}
-		 */
-		coverage: false,
-
-		/**
-		 * Prepares files for coverage report.
-		 *
-		 * @returns {Stream}
-		 */
-		prepareNodeCoverage() {
-			const src = benderConfig.coverage.paths.map( ( item ) => {
-				return item.replace( 'build/amd/', 'build/cjs/' );
-			} );
-			tasks.coverage = true;
-
-			return gulp.src( src )
-				.pipe( istanbul() )
-				.pipe( istanbul.hookRequire() );
-		},
-
-		/**
-		 * Runs tests in Node.js environment.
-		 *
-		 * @returns {Stream}
-		 */
-		testInNode() {
-			const minVersion = '6.0.0';
-
-			if ( semver.lt( process.version, minVersion ) ) {
-				throw new gutil.PluginError( {
-					plugin: 'test-node',
-					message: `Wrong Node.js version. Please use Node.js in version v${ minVersion } or higher.`
-				} );
-			}
-
-			const benderSrc = benderConfig.tests.all.paths.map( ( item ) => {
-				return item.replace( 'build/amd/', 'build/cjs/' ) + '/*.js' ;
-			} );
-
-			const src = [
-				...benderSrc,
-				'!build/cjs/tests/{ui,ui-*}/**/*.js',
-				'!build/cjs/tests/theme-*/**/*.js',
-				'!build/cjs/tests/creator-*/**/*.js'
-			];
-
-			return gulp.src( src )
-				.pipe( tasks.skipManual() )
-				.pipe( tasks.skipIgnored() )
-				.pipe( mocha( { reporter: 'progress' } ) )
-				.pipe( tasks.coverage ? istanbul.writeReports() : stream.noop() );
-		},
-
-		/**
-		 * Removes manual test files from source stream. It checks if the markdown file with the same name exists.
-		 *
-		 * @returns {Stream}
-		 */
-		skipManual() {
-			return filter( ( file ) => {
-				return !tools.isFile( file.path.slice( 0, -3 ) + '.md' );
-			} );
-		},
-
-		/**
-		 * Skips test files that are marked to be ignored when testing outside browser.
-		 * To ignore file, add `browser-only` to bender-tags comment in test file.
-		 *
-		 * @returns {Stream}
-		 */
-		skipIgnored() {
-			return filterBy( file => !file.contents.toString().match( ignoreRegexp ) );
-		},
-
-		/**
-		 * Runs dev unit tests.
-		 *
-		 * @returns {Stream}
-		 */
-		devTest() {
-			return gulp.src( 'dev/tests/**/*.js' )
-				.pipe( mocha() )
-				.pipe( tasks.coverage ? istanbul.writeReports() : stream.noop() );
-		},
-
-		/**
-		 * Prepares files for coverage report.
-		 *
-		 * @returns {Stream}
-		 */
-		prepareDevCoverage() {
-			tasks.coverage = true;
-
-			return gulp.src( 'dev/tasks/**/*.js' )
-				.pipe( istanbul() )
-				.pipe( istanbul.hookRequire() );
-		},
-
-		register() {
-			gulp.task( 'test:node:pre-coverage', [ 'build:js:cjs' ], tasks.prepareNodeCoverage );
-			gulp.task( 'test:node', tasks.testInNode );
-			gulp.task( 'test:node:build', [ 'build:js:cjs' ] , tasks.testInNode );
-			gulp.task( 'test:node:coverage', [ 'build:js:cjs', 'test:node:pre-coverage' ], tasks.testInNode );
-
-			gulp.task( 'test:dev:pre-coverage', tasks.prepareDevCoverage );
-			gulp.task( 'test:dev', tasks.devTest );
-			gulp.task( 'test:dev:coverage', [ 'test:dev:pre-coverage' ], tasks.devTest );
-		}
-	};
-
-	return tasks;
-};

+ 0 - 77
dev/tests/test/tasks.js

@@ -1,77 +0,0 @@
-/**
- * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-/* global describe, it, sinon */
-
-'use strict';
-
-const Vinyl = require( 'vinyl' );
-const tasks = require( '../../tasks/test/tasks' )();
-const { stream: streamUtils, tools } = require( 'ckeditor5-dev-utils' );
-
-describe( 'test-node', () => {
-	describe( 'skipManual', () => {
-		it( 'should skip manual tests', ( done ) => {
-			const stream = tasks.skipManual();
-			const spy = sinon.spy();
-			const stub = sinon.stub( tools, 'isFile', ( file ) => {
-				return file == 'file1.md';
-			} );
-			const unitTestFile = new Vinyl( {
-				cwd: './',
-				path: 'file2.js',
-				contents: null
-			} );
-			const manualTestFile = new Vinyl( {
-				cwd: './',
-				path: 'file1.js',
-				contents: null
-			} );
-
-			stream.pipe( streamUtils.noop( spy ) );
-
-			stream.once( 'finish', () => {
-				sinon.assert.calledOnce( spy );
-				sinon.assert.calledWithExactly( spy, unitTestFile );
-				done();
-			} );
-
-			stream.write( manualTestFile );
-			stream.write( unitTestFile );
-
-			stream.end();
-			stub.restore();
-		} );
-	} );
-
-	describe( 'skipIgnored', () => {
-		it( 'should skip files marked to ignore', ( done ) => {
-			const stream = tasks.skipIgnored();
-			const spy = sinon.spy();
-			const unitTestFile = new Vinyl( {
-				cwd: './',
-				path: 'file2.js',
-				contents: new Buffer( '' )
-			} );
-			const manualTestFile = new Vinyl( {
-				cwd: './',
-				path: 'file1.js',
-				contents: new Buffer( '/* bender-tags: tag, browser-only */' )
-			} );
-			const noop = streamUtils.noop( spy );
-			noop.once( 'finish', () => {
-				sinon.assert.calledOnce( spy );
-				sinon.assert.calledWithExactly( spy, unitTestFile );
-				done();
-			} );
-
-			stream.pipe( noop );
-			stream.write( manualTestFile );
-			stream.write( unitTestFile );
-
-			stream.end();
-		} );
-	} );
-} );

+ 0 - 2
gulpfile.js

@@ -30,8 +30,6 @@ const config = {
 	]
 };
 
-require( './dev/tasks/test/tasks' )( config ).register();
-
 // Lint tasks.
 const ckeditor5Lint = require( 'ckeditor5-dev-lint' )( config );
 gulp.task( 'lint', ckeditor5Lint.lint );

+ 1 - 11
package.json

@@ -31,23 +31,13 @@
     "benderjs-mocha": "^0.3.0",
     "benderjs-promise": "^0.1.0",
     "benderjs-sinon": "^0.3.0",
-    "chai": "^3.4.0",
     "ckeditor5-dev-bundler-rollup": "ckeditor/ckeditor5-dev-bundler-rollup",
     "ckeditor5-dev-compiler": "ckeditor/ckeditor5-dev-compiler",
     "ckeditor5-dev-env": "ckeditor/ckeditor5-dev-env",
     "ckeditor5-dev-lint": "ckeditor/ckeditor5-dev-lint",
-    "ckeditor5-dev-utils": "ckeditor/ckeditor5-dev-utils",
     "gulp": "^3.9.0",
-    "gulp-filter": "^3.0.1",
-    "gulp-filter-by": "^1.2.0",
-    "gulp-istanbul": "^0.10.4",
-    "gulp-mocha": "^2.2.0",
-    "gulp-util": "^3.0.7",
     "guppy-pre-commit": "^0.3.0",
-    "run-sequence": "^1.1.5",
-    "semver": "^5.1.0",
-    "sinon": "^1.17.0",
-    "vinyl": "^1.1.1"
+    "run-sequence": "^1.1.5"
   },
   "engines": {
     "node": ">=6.0.0",