Przeglądaj źródła

Add grunt task to run the tests.

- Removed phantom-jasmine, not used.
- Updated CONTRIBUTING.rst
JC Brand 12 lat temu
rodzic
commit
8e04ea51c3
3 zmienionych plików z 40 dodań i 16 usunięć
  1. 9 2
      CONTRIBUTING.rst
  2. 31 13
      Gruntfile.js
  3. 0 1
      package.json

+ 9 - 2
CONTRIBUTING.rst

@@ -2,7 +2,7 @@
 Contributing to Converse.js
 ===========================
 
-Thanks for contributing to Converse.js_! 
+Thanks for contributing to Converse.js_.
 
 Please follow the usual github workflow. Create your own local fork of this repository,
 make your changes and then submit a pull request.
@@ -19,12 +19,19 @@ for testing.
 Take a look at ``tests.html`` and ``spec/MainSpec.js`` to see how
 the tests are implemented.
 
+If you are unsure how to write tests, please `contact me`_ and I'll be happy to
+help.
+
 Check that the tests run
 ------------------------
 
-Check that the Jasmine BDD tests complete sucessfully. Open tests.html in your
+Check that the Jasmine tests complete sucessfully. Open tests.html in your
 browser, and the tests will run automatically.
 
 You can see the current test output online, here: http://conversejs.org/tests.html
 
+On the command line you can run ``grunt test`` (if you have before run ``npm
+install``).
+
 .. _Converse.js: http://conversejs.org
+.. _`contact me`: http://opkode.com/contact.html

+ 31 - 13
Gruntfile.js

@@ -1,20 +1,38 @@
 module.exports = function(grunt) {
     grunt.initConfig({
         jshint: {
-        options: {
-            trailing: true
-        },
-        target: {
-            src : [
-                'converse.js',
-                'mock.js',
-                'main.js',
-                'tests_main.js',
-                'spec/*.js'
-            ]
-        }
+            options: {
+                trailing: true
+            },
+            target: {
+                src : [
+                    'converse.js',
+                    'mock.js',
+                    'main.js',
+                    'tests_main.js',
+                    'spec/*.js'
+                ]
+            }
         }
     });
     grunt.loadNpmTasks('grunt-contrib-jshint');
-    grunt.registerTask('default', ['jshint']);
+    grunt.registerTask('test', 'Run Tests', function () {
+        var done = this.async();
+        var child_process = require('child_process');
+        var exec = child_process.exec;
+        exec('phantomjs '+
+             'node_modules/jasmine-reporters/test/phantomjs-testrunner.js '+
+             __dirname+'/tests.html',
+             function (err, stdout, stderr) {
+                if (err) {
+                    grunt.log.write('Tests failed with error code '+err.code);
+                    grunt.log.write(stderr);
+                }
+                grunt.log.write(stdout);
+                done();
+        });
+    });
+    grunt.registerTask('default', 'Perform all checks (e.g. before releasing)', function () {
+        grunt.task.run('jshint', 'test');
+    });
 };

+ 0 - 1
package.json

@@ -31,7 +31,6 @@
     "grunt": "~0.4.1",
     "grunt-contrib-jshint": "~0.6.0",
     "phantomjs": "~1.9.1-0",
-    "phantom-jasmine": "~0.3.0",
     "jasmine-reporters": "~0.2.1"
   }
 }