grunt.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /*global config:true, task:true*/
  2. module.exports = function( grunt ) {
  3. grunt.loadNpmTasks( "grunt-git-authors" );
  4. grunt.initConfig({
  5. pkg: '<json:package.json>',
  6. qunit: {
  7. qunit: [
  8. 'test/index.html',
  9. 'test/async.html'
  10. // TODO figure out why this fails on our Jenkins server (Linux)
  11. // 'test/logs.html'
  12. ],
  13. addons: [
  14. 'addons/canvas/canvas.html',
  15. 'addons/close-enough/close-enough.html',
  16. 'addons/composite/composite-demo-test.html'
  17. // TODO same as above
  18. // 'addons/step/step.html'
  19. ]
  20. },
  21. lint: {
  22. qunit: 'qunit/qunit.js',
  23. addons: 'addons/**.js',
  24. tests: 'test/**.js',
  25. grunt: 'grunt.js'
  26. },
  27. // TODO remove this once grunt 0.4 is out, see jquery-ui for other details
  28. jshint: (function() {
  29. function parserc( path ) {
  30. var rc = grunt.file.readJSON( (path || "") + ".jshintrc" ),
  31. settings = {
  32. options: rc,
  33. globals: {}
  34. };
  35. (rc.predef || []).forEach(function( prop ) {
  36. settings.globals[ prop ] = true;
  37. });
  38. delete rc.predef;
  39. return settings;
  40. }
  41. return {
  42. qunit: parserc( "qunit/" ),
  43. addons: parserc( "addons/" ),
  44. tests: parserc( "test/" )
  45. };
  46. })()
  47. });
  48. grunt.registerTask( "build-git", function( sha ) {
  49. function processor( content ) {
  50. var tagline = " - A JavaScript Unit Testing Framework";
  51. return content.replace( tagline, "-" + sha + " " + grunt.template.today('isoDate') + tagline );
  52. }
  53. grunt.file.copy( "qunit/qunit.css", "dist/qunit-git.css", {
  54. process: processor
  55. });
  56. grunt.file.copy( "qunit/qunit.js", "dist/qunit-git.js", {
  57. process: processor
  58. });
  59. });
  60. grunt.registerTask( "testswarm", function( commit, configFile ) {
  61. var testswarm = require( "testswarm" ),
  62. config = grunt.file.readJSON( configFile ).qunit,
  63. runs = {},
  64. done = this.async();
  65. ["index", "async"].forEach(function (suite) {
  66. runs[suite] = config.testUrl + commit + "/test/" + suite + ".html";
  67. });
  68. testswarm.createClient( {
  69. url: config.swarmUrl,
  70. pollInterval: 10000,
  71. timeout: 1000 * 60 * 30
  72. } )
  73. .addReporter( testswarm.reporters.cli )
  74. .auth( {
  75. id: config.authUsername,
  76. token: config.authToken
  77. } )
  78. .addjob(
  79. {
  80. name: 'QUnit commit #<a href="https://github.com/jquery/qunit/commit/' + commit + '">' + commit.substr( 0, 10 ) + '</a>',
  81. runs: runs,
  82. browserSets: config.browserSets
  83. }, function( err, passed ) {
  84. if ( err ) {
  85. grunt.log.error( err );
  86. }
  87. done( passed );
  88. }
  89. );
  90. });
  91. grunt.registerTask('default', 'lint qunit');
  92. };