Skip to content

Add madge check for circular dependencies on test-syntax #872

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 8, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,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",
Expand Down
31 changes: 27 additions & 4 deletions tasks/test_syntax.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -14,6 +15,7 @@ var bundleTestGlob = path.join(constants.pathToJasmineBundleTests, '**/*.js');
assertJasmineSuites();
assertHeaders();
assertFileNames();
assertCircularDeps();


// check for for focus and exclude jasmine blocks
Expand All @@ -38,7 +40,7 @@ function assertJasmineSuites() {

});

log(logs);
log('no jasmine suites focus/exclude blocks', logs);
});
}

Expand Down Expand Up @@ -68,7 +70,7 @@ function assertHeaders() {
}
});

log(logs);
log('correct headers in lib/ and src/', logs);
});
}

Expand All @@ -89,17 +91,38 @@ function assertFileNames() {
}
});

log(logs);
log('lower case only file names', logs);
});

}

// check circular dependencies
function assertCircularDeps() {
var dependencyObject = madge(constants.pathToSrc);
var circularDeps = dependencyObject.circular().getArray();
var logs = [];

// 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 = 33;

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(',') + '}';
}

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);
}