@@ -25,8 +25,12 @@ const spawn = require('child_process').spawn;
2525const ts = require ( 'gulp-typescript' ) ;
2626const path = require ( 'path' ) ;
2727const process = require ( 'process' ) ;
28+ const tslint = require ( 'gulp-tslint' ) ;
29+ const clangFormat = require ( 'clang-format' ) ;
30+ const format = require ( 'gulp-clang-format' ) ;
2831
2932const tsconfigPath = path . join ( __dirname , 'tsconfig.json' ) ;
33+ const tslintPath = path . join ( __dirname , 'tslint.json' ) ;
3034const outDir = '.' ;
3135const sources = [ 'src.ts/**/*.ts' , 'src.ts/**/*.js' ] ;
3236
@@ -37,6 +41,26 @@ function onError() {
3741 }
3842}
3943
44+ gulp . task ( 'test.check-format' , ( ) => {
45+ return gulp . src ( sources )
46+ . pipe ( format . checkFormat ( 'file' , clangFormat ) )
47+ . on ( 'warning' , onError ) ;
48+ } ) ;
49+
50+ gulp . task ( 'format' , ( ) => {
51+ return gulp . src ( sources , { base : '.' } )
52+ . pipe ( format . format ( 'file' , clangFormat ) )
53+ . pipe ( gulp . dest ( '.' ) ) ;
54+ } ) ;
55+
56+ gulp . task ( 'test.check-lint' , ( ) => {
57+ return gulp . src ( sources )
58+ . pipe ( tslint (
59+ { configuration : tslintPath , formatter : 'verbose' } ) )
60+ . pipe ( tslint . report ( ) )
61+ . on ( 'warning' , onError ) ;
62+ } ) ;
63+
4064gulp . task ( 'clean' , ( ) => {
4165 return del ( [ 'src' ] ) ;
4266} ) ;
@@ -56,11 +80,25 @@ gulp.task('compile', () => {
5680 ] ) ;
5781} ) ;
5882
83+ gulp . task ( 'test.compile' , [ 'compile' ] , ( ) => {
84+ // TODO: Complete this when the test files have been converted
85+ // to Typescript.
86+ } ) ;
87+
5988gulp . task ( 'test.unit' , [ 'compile' ] , cb => {
6089 spawn ( 'bash' , [ './bin/run-test.sh' ] , {
6190 stdio : 'inherit'
6291 } ) . on ( 'close' , cb ) ;
6392} ) ;
6493
65- gulp . task ( 'test' , [ 'test.unit' ] ) ;
94+ gulp . task ( 'watch' , ( ) => {
95+ exitOnError = false ;
96+ gulp . start ( [ 'test.compile' ] ) ;
97+ // TODO: also run unit tests in a non-fatal way
98+ return gulp . watch ( sources , [ 'test.compile' ] ) ;
99+ } ) ;
100+
101+ // TODO: Add the test.check-format and test.check-lint tests when the code
102+ // is in a state that is ready to be formatted.
103+ gulp . task ( 'test' , [ 'test.unit' ] ) ; //, 'test.check-format', 'test.check-lint']);
66104gulp . task ( 'default' , [ 'compile' ] ) ;
0 commit comments