Skip to content

Commit

Permalink
Refactored tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Pierstoval committed Apr 9, 2017
1 parent ddfc176 commit 94f1c58
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 22 deletions.
29 changes: 15 additions & 14 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,8 @@ gulp.task('less', function(done) {
console.info(" > "+assets[i]);
}
}
done();

pipes ? pipes.on('end', function(){done();}) : done();
});

/**
Expand Down Expand Up @@ -215,7 +216,8 @@ gulp.task('sass', function(done) {
console.info(" > "+assets[i]);
}
}
done();

pipes ? pipes.on('end', function(){done();}) : done();
});

/**
Expand All @@ -242,7 +244,8 @@ gulp.task('copy', function(done) {
console.info(" > "+assets[i]);
}
}
done();

pipes ? pipes.on('end', function(){done();}) : done();
});

/**
Expand Down Expand Up @@ -275,7 +278,8 @@ gulp.task('images', function(done) {
console.info(" > "+assets[i]);
}
}
done();

pipes ? pipes.on('end', function(){done();}) : done();
});

/**
Expand Down Expand Up @@ -304,7 +308,8 @@ gulp.task('css', function(done) {
console.info(" > "+assets[i]);
}
}
done();

pipes ? pipes.on('end', function(){done();}) : done();
});

/**
Expand Down Expand Up @@ -333,20 +338,16 @@ gulp.task('js', function(done) {
console.info(" > "+assets[i]);
}
}
done();

pipes ? pipes.on('end', function(){done();}) : done();
});

/**
* Runs all the needed commands to dump all assets and manifests
*/
var dumpTasks = [];
if (hasImages) { dumpTasks.push('images'); }
if (hasCopy) { dumpTasks.push('copy'); }
if (hasLess) { dumpTasks.push('less'); }
if (hasSass) { dumpTasks.push('sass'); }
if (hasCss) { dumpTasks.push('css'); }
if (hasJs) { dumpTasks.push('js'); }
gulp.task('dump', gulp.parallel.apply(gulp, dumpTasks), function(done) { done(); });
gulp.task('dump', gulp.series('images', 'copy', 'less', 'sass', 'css', 'js', function(done){
done();
}));

/**
* Will watch for files and run "dump" for each modification
Expand Down
2 changes: 1 addition & 1 deletion tests/output_expected/css.css
Original file line number Diff line number Diff line change
@@ -1 +1 @@
body{background:#fff}
body{background:#fff}
2 changes: 1 addition & 1 deletion tests/output_expected/js.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
!function(e){e("#element").hide()}(jQuery);
!function(e){e("#element").hide()}(jQuery);
2 changes: 1 addition & 1 deletion tests/output_expected/less.css
Original file line number Diff line number Diff line change
@@ -1 +1 @@
body{border-radius:3px;color:#333}
body{border-radius:3px;color:#333}
2 changes: 1 addition & 1 deletion tests/output_expected/sass.css
Original file line number Diff line number Diff line change
@@ -1 +1 @@
body{border-radius:3px;color:#333}
body{border-radius:3px;color:#333}
4 changes: 2 additions & 2 deletions tests/prepare_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ var gulpfileContents = fs
.readFileSync(testsDir+'/../gulpfile.js')
.toString()
.replace(
/var config =(?:[^£]+)(\*)+ End config/g,
'var config = ' + JSON.stringify(config, null, 4) + ";\n"+ '/$1 End config'
/const config =(?:[^£]+)(\*+) End config \*/g,
'const config = ' + JSON.stringify(config, null, 4) + ";\n"+ '/$1 End config *'
)
;

Expand Down
14 changes: 12 additions & 2 deletions tests/tests.bash
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
#!/bin/bash

set -e

# Go back to root project directory
cd `dirname $0`/../

echo "Directory: `pwd`"

REINSTALL=0

while test $# -gt 0
Expand All @@ -23,11 +27,17 @@ if [[ ${REINSTALL} == 1 ]]; then
npm install
fi

rm tests/output_tests/*
rm tests/gulpfile.js
rm -f tests/output_tests/*
test -f tests/gulpfile.js && rm tests/gulpfile.js

echo "Preparing tests..."
node tests/prepare_tests.js

echo "Executing gulp dump..."
node node_modules/gulp4/bin/gulp.js --gulpfile tests/gulpfile.js dump --prod

echo "Test expected files are correctly dumped"
echo -e " > css.css\c" && cmp tests/output_expected/css.css tests/output_tests/css.css && echo -e " > OK"
echo -e " > js.js\c" && cmp tests/output_expected/js.js tests/output_tests/js.js && echo -e " > OK"
echo -e " > less.css\c" && cmp tests/output_expected/less.css tests/output_tests/less.css && echo -e " > OK"
echo -e " > sass.css\c" && cmp tests/output_expected/sass.css tests/output_tests/sass.css && echo -e " > OK"

0 comments on commit 94f1c58

Please sign in to comment.