bazel: check cycle test

This commit is contained in:
Jason Choi
2016-08-20 09:50:05 -07:00
parent 5ed72a8a6c
commit ec4a53e44d
3 changed files with 43 additions and 0 deletions

26
BUILD
View File

@ -853,3 +853,29 @@ public_api_test(
public_api = ":public_api", public_api = ":public_api",
size = "small", size = "small",
) )
nodejs_test(
name = "check_cycle_test",
srcs = [
"//build_defs:check_cycle.js",
],
deps = [
":madge",
],
entry_point = "check_cycle.js",
data = [
":core",
":common",
":compiler",
":compiler-cli",
":forms",
":http",
":platform-browser",
":platform-browser-dynamic",
":platform-server",
":router",
":upgrade",
":tsc-wrapped",
],
size = "small",
)

View File

@ -5,4 +5,5 @@ exports_files([
"rollup_config_template.js", "rollup_config_template.js",
"protractor_launcher_template.sh", "protractor_launcher_template.sh",
"ts_api_guardian_launcher_template.sh", "ts_api_guardian_launcher_template.sh",
"check_cycle.js",
]) ])

16
build_defs/check_cycle.js Normal file
View File

@ -0,0 +1,16 @@
'use strict';
const madge = require('madge');
const dependencyObject = madge([process.env.RUNFILES + '/modules/'], {
format: 'cjs',
extensions: ['.js'],
onParseFile: function(data) { data.src = data.src.replace(/\/\* circular \*\//g, '//'); }
});
const circularDependencies = dependencyObject.circular().getArray();
if (circularDependencies.length > 0) {
console.log('Found circular dependencies!');
console.log(circularDependencies);
process.exit(1);
}