From 80d615b417e4c869b3cde4fec084f25e908aad1f Mon Sep 17 00:00:00 2001 From: Joseph Frazier Date: Sun, 4 Oct 2015 20:09:15 -0400 Subject: [PATCH 1/2] tests use cross-spawn-async instead of child_process.spawn This allows Windows to run the tests, as promised in https://github.com/feross/webtorrent/issues/429#issuecomment-146061289 Note that there are a couple of outstanding failures on Windows: # client.seed: filesystem path to folder with one file, string not ok 8 should be equal --- operator: equal expected: '3a686c32404af0a66913dd5f8d2b40673f8d4490' actual: 'e6887b78d89d995876c7cef3476b6fb32c4c4e3d' ... not ok 9 should be equal --- operator: equal expected: |- 'magnet:?xt=urn:btih:3a686c32404af0a66913dd5f8d2b40673f8d4490&dn=folder&tr=udp%3A%2F%2Ftracker.webtorrent.io%3A80' actual: |- 'magnet:?xt=urn:btih:e6887b78d89d995876c7cef3476b6fb32c4c4e3d&dn=folder&tr=udp%3A%2F%2Ftracker.webtorrent.io%3A80' --- bin/test.js | 6 +++--- package.json | 1 + test/cmd.js | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/bin/test.js b/bin/test.js index 2fc368b9..2675c80b 100644 --- a/bin/test.js +++ b/bin/test.js @@ -1,14 +1,14 @@ #!/usr/bin/env node -var cp = require('child_process') +var spawn = require('cross-spawn-async') var runBrowserTests = !process.env.TRAVIS_PULL_REQUEST || process.env.TRAVIS_PULL_REQUEST === 'false' -var node = cp.spawn('npm', ['run', 'test-node'], { stdio: 'inherit' }) +var node = spawn('npm', ['run', 'test-node'], { stdio: 'inherit' }) node.on('close', function (code) { if (code === 0 && runBrowserTests) { - var browser = cp.spawn('npm', ['run', 'test-browser'], { stdio: 'inherit' }) + var browser = spawn('npm', ['run', 'test-browser'], { stdio: 'inherit' }) browser.on('close', function (code) { process.exit(code) }) diff --git a/package.json b/package.json index a14cf99b..25f4e3dd 100644 --- a/package.json +++ b/package.json @@ -28,6 +28,7 @@ "chunk-store-stream": "^2.0.0", "clivas": "^0.2.0", "create-torrent": "^3.4.0", + "cross-spawn-async": "^2.0.0", "debug": "^2.1.0", "end-of-stream": "^1.0.0", "executable": "^1.1.0", diff --git a/test/cmd.js b/test/cmd.js index abba4c26..ee8a87b9 100644 --- a/test/cmd.js +++ b/test/cmd.js @@ -1,4 +1,5 @@ var cp = require('child_process') +var spawn = require('cross-spawn-async') var path = require('path') var fs = require('fs') var parseTorrent = require('parse-torrent') @@ -84,7 +85,7 @@ test('Command line: webtorrent create /path/to/file', function (t) { var leavesPath = path.resolve(__dirname, 'content', 'Leaves of Grass by Walt Whitman.epub') - var child = cp.spawn('node', [ CMD_PATH, 'create', leavesPath ]) + var child = spawn('node', [ CMD_PATH, 'create', leavesPath ]) child.on('error', function (err) { t.fail(err) }) var chunks = [] From 3f259a35da0c10a070de5a681a73d5331a7d8113 Mon Sep 17 00:00:00 2001 From: Joseph Frazier Date: Tue, 6 Oct 2015 23:42:54 -0400 Subject: [PATCH 2/2] echo "*.txt text eol=lf" >> .gitattributes This forces Windows checkouts to keep LF line endings for test files. https://help.github.com/articles/dealing-with-line-endings/#example resolves https://github.com/feross/webtorrent/issues/429 --- .gitattributes | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..f9e337fe --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +*.txt text eol=lf