From e526801095d6df7c53be47c4edbab14062b7737c Mon Sep 17 00:00:00 2001 From: alexlamsl Date: Sat, 16 Apr 2016 22:21:49 +0800 Subject: [PATCH] read QUnit.version instead of pinning in package.json add web test time-out detection --- Gruntfile.js | 18 ++++++++++++++++-- package.json | 2 +- test.js | 7 ++++++- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 9a0f738..99984e6 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1,11 +1,25 @@ 'use strict'; +function qunitVersion() { + var prepareStackTrace = Error.prepareStackTrace; + Error.prepareStackTrace = function() { + return ''; + }; + try { + return require('qunitjs').version; + } + finally { + Error.prepareStackTrace = prepareStackTrace; + } +} + module.exports = function(grunt) { // Force use of Unix newlines grunt.util.linefeed = '\n'; grunt.initConfig({ pkg: grunt.file.readJSON('package.json'), + qunit_ver: qunitVersion(), banner: '/*!\n' + ' * HTMLMinifier v<%= pkg.version %> (<%= pkg.homepage %>)\n' + ' * Copyright 2010-<%= grunt.template.today("yyyy") %> <%= pkg.author %>\n' + @@ -56,11 +70,11 @@ module.exports = function(grunt) { ], './tests/index.html': [ /("[^"]+\/qunit-)[0-9\.]+?(\.(?:css|js)")/g, - '$1<%= pkg.devDependencies.qunitjs %>$2' + '$1<%= qunit_ver %>$2' ], './tests/lint-tests.html': [ /("[^"]+\/qunit-)[0-9\.]+?(\.(?:css|js)")/g, - '$1<%= pkg.devDependencies.qunitjs %>$2' + '$1<%= qunit_ver %>$2' ] }, diff --git a/package.json b/package.json index e7b032b..31c64bd 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "grunt-contrib-uglify": "1.0.x", "grunt-eslint": "18.1.x", "phantomjs-prebuilt": "2.1.x", - "qunitjs": "1.23.1" + "qunitjs": "1.x" }, "optionalDependencies": { "brotli": "1.2.x", diff --git a/test.js b/test.js index 5ac29f7..dc5fd70 100644 --- a/test.js +++ b/test.js @@ -33,12 +33,17 @@ if (typeof phantom === 'undefined') { QUnit.load(); } else { + var system = require('system'); + setTimeout(function() { + system.stderr.write('timed out'); + phantom.exit(1); + }, 15000); var page = require('webpage').create(); page.onAlert = function(details) { console.log(details); phantom.exit(); }; - page.open(require('system').args[1], function(status) { + page.open(system.args[1], function(status) { if (status !== 'success') { phantom.exit(1); } -- 2.34.1