From bb3535468ced787ff62a16e9838ba5f95050e962 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20T=C3=A9treault-Pinard?= Date: Wed, 10 Aug 2016 15:45:42 -0400 Subject: [PATCH 1/3] tasks: try 'madge' to check for circular dependencies --- package.json | 1 + tasks/test_syntax.js | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/package.json b/package.json index 961010dc589..3c6e37de016 100644 --- a/package.json +++ b/package.json @@ -104,6 +104,7 @@ "karma-coverage": "^1.0.0", "karma-firefox-launcher": "^1.0.0", "karma-jasmine": "^1.0.2", + "madge": "^0.6.0", "node-sass": "^3.4.1", "npm-link-check": "^1.1.0", "open": "0.0.5", diff --git a/tasks/test_syntax.js b/tasks/test_syntax.js index 378c232ed1a..549bd86f84b 100644 --- a/tasks/test_syntax.js +++ b/tasks/test_syntax.js @@ -3,6 +3,7 @@ var fs = require('fs'); var falafel = require('falafel'); var glob = require('glob'); +var madge = require('madge'); var constants = require('./util/constants'); var srcGlob = path.join(constants.pathToSrc, '**/*.js'); @@ -14,6 +15,7 @@ var bundleTestGlob = path.join(constants.pathToJasmineBundleTests, '**/*.js'); assertJasmineSuites(); assertHeaders(); assertFileNames(); +assertCircularDeps(); // check for for focus and exclude jasmine blocks @@ -94,6 +96,23 @@ function assertFileNames() { } +// check circular dependencies +function assertCircularDeps() { + var dependencyObject = madge(constants.pathToSrc); + var circularDeps = dependencyObject.circular().getArray(); + var logs = []; + + // as of 2016/08/19 + // see https://github.com/plotly/plotly.js/milestone/9 + // for more details + var MAX_ALLOWED_CIRCULAR_DEPS = 31; + + if(circularDeps.length > MAX_ALLOWED_CIRCULAR_DEPS) { + logs.push('some new circular dependencies were added to src/'); + } + + log('circular dependencies', logs); +} function combineGlobs(arr) { return '{' + arr.join(',') + '}'; } From dc91e8d0b1f8085806bab7009f3f27a49dcd5b6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20T=C3=A9treault-Pinard?= Date: Wed, 10 Aug 2016 15:45:58 -0400 Subject: [PATCH 2/3] tasks add 'ok' logs to test-syntax --- tasks/test_syntax.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tasks/test_syntax.js b/tasks/test_syntax.js index 549bd86f84b..4bdef7531b1 100644 --- a/tasks/test_syntax.js +++ b/tasks/test_syntax.js @@ -40,7 +40,7 @@ function assertJasmineSuites() { }); - log(logs); + log('no jasmine suites focus/exclude blocks', logs); }); } @@ -70,7 +70,7 @@ function assertHeaders() { } }); - log(logs); + log('correct headers in lib/ and src/', logs); }); } @@ -91,7 +91,7 @@ function assertFileNames() { } }); - log(logs); + log('lower case only file names', logs); }); } @@ -113,12 +113,16 @@ function assertCircularDeps() { log('circular dependencies', logs); } + function combineGlobs(arr) { return '{' + arr.join(',') + '}'; } -function log(logs) { +function log(name, logs) { if(logs.length) { + console.error('test-syntax error [' + name + ']\n'); throw new Error('\n' + logs.join('\n') + '\n'); } + + console.log('ok ' + name); } From 70cd8b5c241692375265c68392a8fd68f9097208 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20T=C3=A9treault-Pinard?= Date: Wed, 7 Sep 2016 23:02:44 -0400 Subject: [PATCH 3/3] tasks: bump allowed circular dep maximum --- tasks/test_syntax.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tasks/test_syntax.js b/tasks/test_syntax.js index 4bdef7531b1..76d9f631f30 100644 --- a/tasks/test_syntax.js +++ b/tasks/test_syntax.js @@ -102,10 +102,10 @@ function assertCircularDeps() { var circularDeps = dependencyObject.circular().getArray(); var logs = []; - // as of 2016/08/19 + // as of v1.17.0 - 2016/09/08 // see https://github.com/plotly/plotly.js/milestone/9 // for more details - var MAX_ALLOWED_CIRCULAR_DEPS = 31; + var MAX_ALLOWED_CIRCULAR_DEPS = 33; if(circularDeps.length > MAX_ALLOWED_CIRCULAR_DEPS) { logs.push('some new circular dependencies were added to src/');