commit 748c30206f2d9d988812b81ac58600ae5558e533
parent a55852ea1c0d61b7330c6fc30417869306b63867
Author: Dan Stillman <dstillman@zotero.org>
Date: Wed, 24 May 2017 01:01:22 -0400
Run tests from build dir
Diffstat:
6 files changed, 30 insertions(+), 13 deletions(-)
diff --git 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
@@ -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
diff --git a/test/resource/chai-as-promised b/test/resource/chai-as-promised
diff --git a/test/resource/mocha b/test/resource/mocha
diff --git 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"