Run tests from build dir

This commit is contained in:
Dan Stillman 2017-05-24 01:01:22 -04:00
parent a55852ea1c
commit 748c30206f
6 changed files with 33 additions and 16 deletions

View file

@ -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']);

View file

@ -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",

@ -1 +0,0 @@
Subproject commit b369f252432c3486a66a0e93f441e4abb133d229

1
test/resource/chai Symbolic link
View file

@ -0,0 +1 @@
../../node_modules/chai/lib

@ -1 +0,0 @@
Subproject commit c0d887605a6df879d7ff1700600ad450e6e09a84

View file

@ -0,0 +1 @@
../../node_modules/chai-as-promised/lib

@ -1 +0,0 @@
Subproject commit 2a8594424c73ffeca41ef1668446372160528b4a

1
test/resource/mocha Symbolic link
View file

@ -0,0 +1 @@
../../node_modules/mocha/lib

View file

@ -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"