diff --git a/gulpfile.js b/gulpfile.js index 84000e4921..cd98a40042 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -15,12 +15,22 @@ const reactPatcher = require('./gulp/gulp-react-patcher'); // list of folders from where .js files are compiled and non-js files are symlinked const dirs = [ - 'chrome', 'components', 'defaults', 'resource', 'resource/web-library' + 'chrome', + 'components', + 'defaults', + 'resource', + 'resource/web-library', + 'test', + 'test/resource/chai', + 'test/resource/chai-as-promised', + 'test/resource/mocha' ]; -// list of folders from where all files are symlinked +// list of folders from which all files are symlinked const symlinkDirs = [ - 'styles', 'translators' + 'styles', + 'translators', + 'test/tests/data' ]; // list of files from root folder to symlink @@ -29,6 +39,7 @@ const symlinkFiles = [ ]; const jsGlob = `./\{${dirs.join(',')}\}/**/*.js`; +const jsGlobIgnore = `./\{${symlinkDirs.join(',')}\}/**/*.js`; function onError(err) { gutil.log(gutil.colors.red('Error:'), err); @@ -39,7 +50,10 @@ function onSuccess(msg) { gutil.log(gutil.colors.green('Build:'), msg); } -function getJS(source = jsGlob) { +function getJS(source, sourceIgnore) { + if (sourceIgnore) { + source = [source, '!' + sourceIgnore]; + } return gulp.src(source, { base: '.' }) .pipe(babel()) .pipe(reactPatcher()) @@ -50,8 +64,8 @@ function getJS(source = jsGlob) { .pipe(gulp.dest('./build')); } -function getJSParallel(source = jsGlob) { - const jsFiles = glob.sync(source); +function getJSParallel(source, sourceIgnore) { + const jsFiles = glob.sync(source, { ignore: sourceIgnore }); const cpuCount = os.cpus().length; const threadCount = Math.min(cpuCount, jsFiles.length); let threadsActive = threadCount; @@ -93,7 +107,7 @@ function getSymlinks() { const match = symlinkFiles .concat(dirs.map(d => `${d}/**`)) .concat(symlinkDirs.map(d => `${d}/**`)) - .concat([`!{${dirs.join(',')}}/**/*.js`]); + .concat([`!./{${dirs.join(',')}}/**/*.js`]); return gulp .src(match, { nodir: true, base: '.', read: false }) @@ -122,7 +136,7 @@ gulp.task('symlink', ['clean'], () => { }); gulp.task('js', done => { - getJSParallel(jsGlob).then(() => done()); + getJSParallel(jsGlob, jsGlobIgnore).then(() => done()); }); gulp.task('sass', () => { @@ -137,7 +151,7 @@ gulp.task('dev', ['clean'], () => { let watcher = gulp.watch(jsGlob, { interval }); watcher.on('change', function(event) { - getJS(event.path); + getJS(event.path, jsGlobIgnore); }); gulp.watch('src/styles/*.scss', { interval }, ['sass']); diff --git a/package.json b/package.json index c49b5c9f65..43150a6954 100644 --- a/package.json +++ b/package.json @@ -30,12 +30,15 @@ "babel-plugin-transform-async-to-module-method": "^6.16.0", "babel-plugin-transform-es2015-modules-commonjs": "^6.18.0", "babel-preset-react": "^6.16.0", + "chai": "^3.5.0", + "chai-as-promised": "^6.0.0", "del": "^2.2.2", "glob": "^7.1.2", "gulp": "^3.9.1", "gulp-babel": "^6.1.2", "gulp-sass": "^3.1.0", "gulp-util": "^3.0.7", + "mocha": "^3.4.1", "through2": "^2.0.1", "tiny-worker": "^2.1.1", "vinyl-buffer": "^1.0.0", diff --git a/test/resource/chai b/test/resource/chai deleted file mode 160000 index b369f25243..0000000000 --- a/test/resource/chai +++ /dev/null @@ -1 +0,0 @@ -Subproject commit b369f252432c3486a66a0e93f441e4abb133d229 diff --git a/test/resource/chai b/test/resource/chai new file mode 120000 index 0000000000..17a8fad25b --- /dev/null +++ b/test/resource/chai @@ -0,0 +1 @@ +../../node_modules/chai/lib \ No newline at end of file diff --git a/test/resource/chai-as-promised b/test/resource/chai-as-promised deleted file mode 160000 index c0d887605a..0000000000 --- a/test/resource/chai-as-promised +++ /dev/null @@ -1 +0,0 @@ -Subproject commit c0d887605a6df879d7ff1700600ad450e6e09a84 diff --git a/test/resource/chai-as-promised b/test/resource/chai-as-promised new file mode 120000 index 0000000000..8aa67b3f95 --- /dev/null +++ b/test/resource/chai-as-promised @@ -0,0 +1 @@ +../../node_modules/chai-as-promised/lib \ No newline at end of file diff --git a/test/resource/mocha b/test/resource/mocha deleted file mode 160000 index 2a8594424c..0000000000 --- a/test/resource/mocha +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 2a8594424c73ffeca41ef1668446372160528b4a diff --git a/test/resource/mocha b/test/resource/mocha new file mode 120000 index 0000000000..9b47837150 --- /dev/null +++ b/test/resource/mocha @@ -0,0 +1 @@ +../../node_modules/mocha/lib \ No newline at end of file diff --git a/test/runtests.sh b/test/runtests.sh index b9e288c91b..945debef65 100755 --- a/test/runtests.sh +++ b/test/runtests.sh @@ -109,12 +109,12 @@ TEMPDIR="`mktemp -d 2>/dev/null || mktemp -d -t 'zotero-unit'`" PROFILE="$TEMPDIR/profile" mkdir -p "$PROFILE/extensions" -makePath ZOTERO_UNIT_PATH "$CWD" -echo "$ZOTERO_UNIT_PATH" > "$PROFILE/extensions/zotero-unit@zotero.org" - -makePath ZOTERO_PATH "`dirname "$CWD"`" +makePath ZOTERO_PATH "`dirname "$CWD"`/build" echo "$ZOTERO_PATH" > "$PROFILE/extensions/zotero@chnm.gmu.edu" +makePath ZOTERO_UNIT_PATH "$ZOTERO_PATH/test" +echo "$ZOTERO_UNIT_PATH" > "$PROFILE/extensions/zotero-unit@zotero.org" + # Create data directory mkdir "$TEMPDIR/Zotero"