add build switch for test code

This commit is contained in:
ccd0 2014-06-27 16:56:23 -07:00
parent 2a797eb953
commit deedfba851
4 changed files with 18 additions and 0 deletions

View File

@ -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'

View File

@ -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
<% } %>

View File

@ -330,7 +330,9 @@ Main =
['Keybinds', Keybinds]
['Show Dice Roll', Dice]
['Banner', Banner]
<% if (tests_enabled) { %>
['Build Test', BuildTest]
<% } %>
]
Main.init()

View File

@ -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}"