Skip to content

Commit

Permalink
Merge pull request #922 from camflint/FixBuildAndTestTasksOnWindows
Browse files Browse the repository at this point in the history
Fix build and test tasks on Windows
  • Loading branch information
philc committed Aug 12, 2014
2 parents 4ab7587 + 0672927 commit be76291
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
*.swp
*.crx
*.js
*.sublime*
node_modules/*
dist
3 changes: 2 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ install Vimium from source:
Our tests use [shoulda.js](https://github.com/philc/shoulda.js) and [PhantomJS](http://phantomjs.org/). To run the tests:

1. `git submodule update --init --recursive` -- this pulls in shoulda.js.
1. [Install PhantomJS.](http://phantomjs.org/download.html)
1. Install [PhantomJS](http://phantomjs.org/download.html).
1. `npm install path` to install the [Node.js Path module](http://nodejs.org/api/path.html), used by the test runner.
1. `cake build` to compile `*.coffee` to `*.js`
1. `cake test` to run the tests.

Expand Down
6 changes: 6 additions & 0 deletions Cakefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
util = require "util"
fs = require "fs"
path = require "path"
child_process = require "child_process"

spawn = (procName, optArray, silent=false) ->
if process.platform is "win32"
# if win32, prefix arguments with "/c {original command}"
# e.g. "coffee -c c:\git\vimium" becomes "cmd.exe /c coffee -c c:\git\vimium"
optArray.unshift "/c", procName
procName = "cmd.exe"
proc = child_process.spawn procName, optArray
unless silent
proc.stdout.on 'data', (data) -> process.stdout.write data
Expand Down
15 changes: 10 additions & 5 deletions tests/dom_tests/phantom_runner.coffee
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
system = require 'system'
fs = require 'fs'
path = require 'path'
page = require('webpage').create()

page.settings.userAgent = 'phantom'
Expand All @@ -12,12 +13,16 @@ page.viewportSize =
page.onConsoleMessage = (msg) ->
console.log msg

dirname = do ->
pathParts = system.args[0].split(fs.separator)
pathParts[pathParts.length - 1] = ''
pathParts.join(fs.separator)
page.onError = (msg, trace) ->
console.log(msg);
trace.forEach (item) ->
console.log(' ', item.file, ':', item.line)

page.open dirname + 'dom_tests.html', (status) ->
page.onResourceError = (resourceError) ->
console.log(resourceError.errorString)

testfile = path.join(path.dirname(system.args[0]), 'dom_tests.html')
page.open testfile, (status) ->
if status != 'success'
console.log 'Unable to load tests.'
phantom.exit 1
Expand Down

0 comments on commit be76291

Please sign in to comment.