Permalink
Browse files

v6.21.1. Improvement.

- v6.21.1 January 6, 2013
	- Added support for running multiple plugin tests for the same plugin
		- Closes [issue #393](#393)
  • Loading branch information...
balupton committed Jan 6, 2013
1 parent 97e7659 commit 4af0a0605bc60fd9f56a01165cb891b746bc4cbe
Showing with 38 additions and 25 deletions.
  1. +4 −0 History.md
  2. +1 −1 package.json
  3. +33 −24 src/lib/testers.coffee
View
@@ -1,5 +1,9 @@
## History
- v6.21.1 January 6, 2013
- Added support for running multiple plugin tests for the same plugin
- Closes [issue #393](https://github.com/bevry/docpad/issues/393)
- v6.21.0 January 2, 2013
- Cleanup focused around loading, parsing, and writing of files and documents
- Added
View
@@ -1,6 +1,6 @@
{
"name": "docpad",
"version": "6.21.0",
"version": "6.21.1",
"description": "DocPad is a language agnostic document management system. This means you write your website as documents, in whatever language you wish, and DocPad will handle the compiling, templates and layouts for you. For static documents it will generate static files, for dynamic documents it'll re-render them on each request. You can utilise DocPad by itself, or use it as a module your own custom system. It's pretty cool, and well worth checking out. We love it.",
"homepage": "https://github.com/bevry/docpad",
"installUrl": "http://docpad.org/install",
View
@@ -35,18 +35,22 @@ class PluginTester
config:
pluginName: null
pluginPath: null
outExpectedPath: null
autoExit: true
testPath: null
outExpectedPath: null
docpadConfig:
port: null
growl: false
logLevel: (if ('-d' in process.argv) then 7 else 5)
rootPath: null
outPath: null
srcPath: null
pluginPaths: null
enableUnlistedPlugins: false
enabledPlugins: null
skipUnsupportedPlugins: false
catchExceptions: false
environment: null
# DocPad Instance
docpad: null
@@ -55,18 +59,13 @@ class PluginTester
logger: null
# Constructor
constructor: (config={}) ->
constructor: (config={},docpadConfig={},next) ->
# Apply Configuration
tester = @
@config = balUtil.deepExtendPlainObjects({}, PluginTester::config ,@config, config)
@docpadConfig = balUtil.deepExtendPlainObjects({}, PluginTester::docpadConfig, @docpadConfig)
@docpadConfig = balUtil.deepExtendPlainObjects({}, PluginTester::docpadConfig, @docpadConfig, docpadConfig)
@docpadConfig.port ?= ++pluginPort
# Test API
joe.describe @config.pluginName, (suite,task,complete) ->
tester.describe = tester.suite = suite
tester.it = tester.test = task
tester.done = tester.exit = complete
@config.testerName ?= @config.pluginName
# Extend Configuration
@config.testPath or= pathUtil.join(@config.pluginPath,'test')
@@ -81,6 +80,16 @@ class PluginTester
defaultEnabledPlugins[@config.pluginName] = true
@docpadConfig.enabledPlugins or= defaultEnabledPlugins
# Test API
joe.describe @config.testerName, (suite,task,complete) ->
tester.describe = tester.suite = suite
tester.it = tester.test = task
tester.done = tester.exit = complete
next?(null,tester)
# Chain
@
# Create DocPad Instance
testCreate: ->
# Prepare
@@ -89,9 +98,10 @@ class PluginTester
# Create Instance
@test "create", (done) ->
tester.docpad = DocPad.createInstance docpadConfig, (err) ->
DocPad.createInstance docpadConfig, (err,docpad) ->
return done(err) if err
tester.logger = tester.docpad.logger
tester.docpad = docpad
tester.logger = docpad.logger
tester.docpad.action 'clean', (err) ->
return done(err) if err
tester.docpad.action 'install', (err) ->
@@ -169,7 +179,8 @@ class PluginTester
@test 'finish up', (done) ->
done()
tester.exit()
process.exit()
if tester.config.autoExit isnt 'safe'
process.exit()
# Chain
@
@@ -212,23 +223,21 @@ class RendererTester extends PluginTester
# Test a plugin
# test({pluginPath: String})
testers.test =
test = (pluginDetails) ->
test = (testerConfig, docpadConfig) ->
# Configure
pluginDetails.pluginPath = pathUtil.resolve(pluginDetails.pluginPath)
pluginDetails.pluginName ?= pathUtil.basename(pluginDetails.pluginPath)
pluginDetails.testerPath ?= pathUtil.join('out', "#{pluginDetails.pluginName}.tester.js")
pluginDetails.testerPath = pathUtil.resolve(pluginDetails.pluginPath, pluginDetails.testerPath)
testerConfig.pluginPath = pathUtil.resolve(testerConfig.pluginPath)
testerConfig.pluginName ?= pathUtil.basename(testerConfig.pluginPath)
testerConfig.testerPath ?= pathUtil.join('out', "#{testerConfig.pluginName}.tester.js")
testerConfig.testerPath = pathUtil.resolve(testerConfig.pluginPath, testerConfig.testerPath)
# Test the plugin's tester
testerClass = require(pluginDetails.testerPath)(testers)
testerInstance = new testerClass(
pluginName: pluginDetails.pluginName
pluginPath: pluginDetails.pluginPath
)
testerInstance.testEverything()
testerClass = require(testerConfig.testerPath)(testers)
new testerClass testerConfig, docpadConfig, (err,testerInstance) ->
throw err if err
testerInstance.testEverything()
# Chain
@
return testers
# Export Testers
module.exports = testers

0 comments on commit 4af0a06

Please sign in to comment.