Просмотр исходного кода

test(appveyor): add appveyor testing

Add testing on windows environment
Estevão Soares dos Santos 8 лет назад
Родитель
Сommit
c6ac36d9f2
4 измененных файлов с 99 добавлено и 42 удалено
  1. 53 0
      .appveyor.yml
  2. 44 16
      Gruntfile.js
  3. 0 24
      test/node/legacyExtensionSupport.js
  4. 2 2
      test/node/showdown.Converter.makeHtml.js

+ 53 - 0
.appveyor.yml

@@ -0,0 +1,53 @@
+# branches to build
+#branches:
+  # whitelist
+  #only:
+  #  - master
+
+# What combinations to test
+environment:
+  matrix:
+    - nodejs_version: "0.10"
+      platform: x86
+    - nodejs_version: "0.12"
+      platform: x86
+    - nodejs_version: "4"
+      platform: x64
+    - nodejs_version: "4"
+      platform: x86
+    - nodejs_version: "6"
+      platform: x64
+    - nodejs_version: "7"
+      platform: x64
+
+install:
+  # Use version based on tag
+  - ps: $env:package_version = (Get-Content -Raw -Path package.json | ConvertFrom-Json).version
+  - ps: Update-AppveyorBuild -Version "$env:package_version-$env:APPVEYOR_BUILD_NUMBER"
+
+  # install node
+  # Get the latest stable version of Node.js or io.js
+  - ps: Install-Product node $env:nodejs_version
+  - ps: >-
+      if ($env:nodejs_version -eq "0.12" -or $env:nodejs_version -eq "0.10") {
+        $env:PATH="$env:APPDATA\npm;$env:PATH"
+      }
+  # install grunt-cli globally
+  - npm install -g grunt-cli
+  # install modules
+  - npm install
+
+test_script:
+  # Output useful info for debugging
+  - node --version && npm --version
+  - ps: >-
+      if ($env:nodejs_version -eq "0.12" -or $env:nodejs_version -eq "0.10") {
+        echo ----- Running tests in LEGACY mode -----
+        grunt test-old
+      } else {
+        echo ----- Running tests in NORMAL mode -----
+        grunt test
+      }
+
+# Don't actually build.
+build: off

+ 44 - 16
Gruntfile.js

@@ -169,15 +169,48 @@ module.exports = function (grunt) {
 
   grunt.initConfig(config);
 
+  /**
+   * Load common tasks for legacy and normal tests
+   */
   grunt.loadNpmTasks('grunt-contrib-clean');
   grunt.loadNpmTasks('grunt-contrib-concat');
   grunt.loadNpmTasks('grunt-contrib-uglify');
-  grunt.loadNpmTasks('grunt-conventional-changelog');
-  grunt.loadNpmTasks('grunt-conventional-github-releaser');
-  grunt.loadNpmTasks('grunt-endline');
   grunt.loadNpmTasks('grunt-simple-mocha');
+  grunt.loadNpmTasks('grunt-endline');
   grunt.loadNpmTasks('grunt-contrib-jshint');
 
+  /**
+   * Generate Changelog
+   */
+  grunt.registerTask('generate-changelog', function () {
+    'use strict';
+    grunt.loadNpmTasks('grunt-conventional-changelog');
+    grunt.loadNpmTasks('grunt-conventional-github-releaser');
+    grunt.task.run('conventionalChangelog');
+  });
+
+  /**
+   * Lint tasks
+   */
+  grunt.registerTask('lint', function () {
+    'use strict';
+    grunt.loadNpmTasks('grunt-eslint');
+    grunt.task.run('jshint', 'eslint');
+  });
+
+  /**
+   * Performance task
+   */
+  grunt.registerTask('performancejs', function () {
+    'use strict';
+    var perf = require('./test/node/performance.js');
+    perf.runTests();
+    perf.generateLogs();
+  });
+
+  /**
+   * Run a single test
+   */
   grunt.registerTask('single-test', function (grep) {
     'use strict';
     grunt.config.merge({
@@ -193,24 +226,19 @@ module.exports = function (grunt) {
     grunt.task.run(['lint', 'concat:test', 'simplemocha:single', 'clean']);
   });
 
-  grunt.registerTask('performancejs', function () {
-    'use strict';
-    var perf = require('./test/node/performance.js');
-    perf.runTests();
-    perf.generateLogs();
-  });
 
-  grunt.registerTask('lint', function () {
-    'use strict';
-    grunt.loadNpmTasks('grunt-eslint');
-    grunt.task.run('jshint', 'eslint');
-  });
+  /**
+   * Test in Legacy Node
+   */
+  grunt.registerTask('test-old', ['concat:test', 'simplemocha:node', 'clean']);
 
+  /**
+   * Tasks for new node versions
+   */
   grunt.registerTask('test', ['clean', 'lint', 'concat:test', 'simplemocha:node', 'clean']);
-  grunt.registerTask('test-old', ['concat:test', 'simplemocha:node', 'clean']);
   grunt.registerTask('performance', ['concat:test', 'performancejs', 'clean']);
   grunt.registerTask('build', ['test', 'concat:dist', 'uglify', 'endline']);
-  grunt.registerTask('prep-release', ['build', 'conventionalChangelog']);
+  grunt.registerTask('prep-release', ['build', 'generate-changelog']);
 
   // Default task(s).
   grunt.registerTask('default', ['test']);

+ 0 - 24
test/node/legacyExtensionSupport.js

@@ -1,24 +0,0 @@
-/**
- * Created by Estevao on 06-06-2015.
- */
-require('source-map-support').install();
-var expect = require('chai').expect,
-    showdown = require('../bootstrap').showdown;
-
-describe('showdown legacy extension support', function () {
-  'use strict';
-  var extObjMock =
-      {
-        type: 'lang',
-        filter: function () {}
-      },
-      extFunc = function () {
-        return [extObjMock];
-      };
-
-  it('accept extensions loaded by the old mechanism', function () {
-    showdown.extensions.bazinga = extFunc;
-    var cnv = new showdown.Converter({extensions: ['bazinga']});
-    expect(cnv.getAllExtensions().language).to.eql([extObjMock]);
-  });
-});

+ 2 - 2
test/node/showdown.Converter.makeHtml.js

@@ -12,7 +12,7 @@ describe('showdown.Converter', function () {
 
   describe('Converter.options extensions', function () {
     var runCount;
-    showdown.extensions.testext = function () {
+    showdown.extension('testext', function () {
       return [{
         type: 'output',
         filter: function (text) {
@@ -20,7 +20,7 @@ describe('showdown.Converter', function () {
           return text;
         }
       }];
-    };
+    });
 
     var converter = new showdown.Converter({extensions: ['testext']});