From deedfba851838e14f6385159bfe4793c87c2255d Mon Sep 17 00:00:00 2001 From: ccd0 Date: Fri, 27 Jun 2014 16:56:23 -0700 Subject: [PATCH] add build switch for test code --- Gruntfile.coffee | 12 ++++++++++++ src/General/BuildTest.coffee | 2 ++ src/General/Main.coffee | 2 ++ src/General/lib/post.class | 2 ++ 4 files changed, 18 insertions(+) diff --git a/Gruntfile.coffee b/Gruntfile.coffee index c3ad155bf..60c509a29 100755 --- a/Gruntfile.coffee +++ b/Gruntfile.coffee @@ -12,6 +12,7 @@ module.exports = (grunt) -> get: -> pkg = grunt.config 'pkg' pkg.importHTML = importHTML + pkg.tests_enabled or= false pkg enumerable: true ) @@ -185,6 +186,11 @@ module.exports = (grunt) -> grunt.log.ok 'pkg.type = %s', type + grunt.registerTask 'enable-tests', 'Include testing code', () -> + pkg = grunt.config 'pkg' + pkg.tests_enabled = true + grunt.config 'pkg', pkg + grunt.registerTask 'build', [ 'concurrent:build' ] @@ -207,6 +213,12 @@ module.exports = (grunt) -> 'clean:tmpuserscript' ] + grunt.registerTask 'build-tests', [ + 'enable-tests' + 'build-userscript' + 'build-crx' + ] + grunt.registerTask 'testing', [ 'build' 'shell:pack' diff --git a/src/General/BuildTest.coffee b/src/General/BuildTest.coffee index 89b23c7e8..797388f6e 100644 --- a/src/General/BuildTest.coffee +++ b/src/General/BuildTest.coffee @@ -1,3 +1,4 @@ +<% if (tests_enabled) { %> BuildTest = init: -> return if !Conf['Menu'] @@ -51,3 +52,4 @@ BuildTest = g.posts.forEach (post) -> unless post.isClone or post.isFetchedQuote or $ '.abbr', post.nodes.comment BuildTest.runTest post +<% } %> diff --git a/src/General/Main.coffee b/src/General/Main.coffee index 951f523f4..ab27d75b3 100755 --- a/src/General/Main.coffee +++ b/src/General/Main.coffee @@ -330,7 +330,9 @@ Main = ['Keybinds', Keybinds] ['Show Dice Roll', Dice] ['Banner', Banner] + <% if (tests_enabled) { %> ['Build Test', BuildTest] + <% } %> ] Main.init() diff --git a/src/General/lib/post.class b/src/General/lib/post.class index 912a2be6c..235e9f46d 100755 --- a/src/General/lib/post.class +++ b/src/General/lib/post.class @@ -3,6 +3,7 @@ class Post toString: -> @ID constructor: (root, @thread, @board, that={}) -> + <% if (tests_enabled) { %> root2 = root.cloneNode true for el in $$ '.mobile', root2 $.rm el @@ -15,6 +16,7 @@ class Post for el in $$ 'img[src]', root2 el.src = el.src.replace /^(\w+:\/\/)[0-2](\.t\.4cdn\.org\/)/, '$10$2' @normalizedOriginal = root2 + <% } %> @ID = +root.id[2..] @fullID = "#{@board}.#{@ID}"