Repository: ember-cli/ember-cli
Pull request #5846 (2016-04-25 20:19:39)

Add YUIDoc lint test
This implements the YUIDoc lint as test suite idea from #5834

/cc @stefanpenner 


Patch:
diff --git a/lib/broccoli/ember-app.js b/lib/broccoli/ember-app.js
index c79ce22db..355cbebf0 100644
--- a/lib/broccoli/ember-app.js
+++ b/lib/broccoli/ember-app.js
@@ -1516,7 +1516,7 @@ EmberApp.prototype._import = function(assetPath, options, directory, subdirector
   @return {(String|undefined)} assetPath
  */
 EmberApp.prototype._getAssetPath = function(asset) {
-  /** @type {String} */
+  /* @type {String} */
   var assetPath;
 
   if (typeof asset === 'object') {
@@ -1690,7 +1690,7 @@ EmberApp.prototype._contentForAppBoot = function(content, config) {
   }
 };
 
-/**
+/*
   Returns the <base> tag for index.html
 
   @param  {Object} config Application configuration
diff --git a/package.json b/package.json
index eeb931d37..561041144 100644
--- a/package.json
+++ b/package.json
@@ -10,7 +10,7 @@
   },
   "scripts": {
     "docs": "yuidoc",
-    "lint": "mocha tests/unit/lint-test",
+    "lint": "node tests/runner lint",
     "test": "node tests/runner",
     "test:debug": "node debug tests/runner",
     "test-slow": "node tests/runner slow",


Test patch:
diff --git a/tests/runner.js b/tests/runner.js
index 10a0af104..74587f4d6 100644
--- a/tests/runner.js
+++ b/tests/runner.js
@@ -24,8 +24,10 @@ var mocha = new Mocha({
 var testFiles = glob.sync(root + '/**/*-test.js');
 var lintPosition = testFiles.indexOf('tests/unit/lint-test.js');
 var lint = testFiles.splice(lintPosition, 1);
+var docsLintPosition = testFiles.indexOf('tests/unit/docs-lint-test.js');
+var docsLint = testFiles.splice(docsLintPosition, 1);
 
-testFiles = lint.concat(testFiles);
+testFiles = lint.concat(docsLint).concat(testFiles);
 
 if (optionOrFile === 'all') {
   addFiles(mocha, testFiles);
@@ -34,6 +36,7 @@ if (optionOrFile === 'all') {
   addFiles(mocha, '/**/*-slow.js');
 } else if (optionOrFile === 'lint')  {
   addFiles(mocha, lint);
+  addFiles(mocha, docsLint);
 } else if (process.argv.length > 2)  {
   addFiles(mocha, process.argv.slice(2));
 } else {
diff --git a/tests/unit/docs-lint-test.js b/tests/unit/docs-lint-test.js
new file mode 100644
index 000000000..63577b377
--- /dev/null
+++ b/tests/unit/docs-lint-test.js
@@ -0,0 +1,45 @@
+'use strict';
+
+var Y = require('yuidocjs');
+var EOL = require('os').EOL;
+
+describe('YUIDoc', function() {
+  var options = Y.Project.init({
+    quiet: true,
+  });
+  var yuiDoc = new Y.YUIDoc(options);
+
+  var json = yuiDoc.run();
+
+  var warnings = {};
+  json.warnings.forEach(function(warning) {
+    var tmp = warning.line.split(':');
+    var file = tmp[0].trim();
+    var line = tmp[1];
+
+    if (!warnings[file]) {
+      warnings[file] = [];
+    }
+
+    warnings[file].push({
+      line: line,
+      message: warning.message,
+    });
+  });
+
+  Object.keys(json.files).forEach(function(file) {
+    it(file, function() {
+      var fileWarnings = warnings[file];
+      if (fileWarnings) {
+        var message = 'YUIDoc issues found:' + EOL + EOL;
+        fileWarnings.forEach(function(warning) {
+          message += 'line ' + warning.line + ': ' + warning.message + EOL;
+        });
+
+        var error = new Error(message);
+        delete error.stack;
+        throw error;
+      }
+    });
+  });
+});