Commit 89810d797532892ef70d5ee23f3b82c5466e7858
Get test working
Charles Lehner committed on 2/8/2016, 4:36:42 AMParent: cc32919e93ce91c6d66985c7ca2b78da5ea7f92d
Files changed
index.js | changed |
package.json | changed |
test/run.js | changed |
index.js | ||
---|---|---|
@@ -140,9 +140,8 @@ | ||
140 | 140 | if (ended = end) return cb(end) |
141 | 141 | var len = parseInt(buf, 16) |
142 | 142 | b.chunks(len)(null, function (end, buf) { |
143 | 143 | if (ended = end) return cb(end) |
144 | - console.error('refline', buf) | |
145 | 144 | cb(end, buf) |
146 | 145 | }) |
147 | 146 | }) |
148 | 147 | } |
@@ -198,11 +197,13 @@ | ||
198 | 197 | |
199 | 198 | function receiveRefs(readLine, cb) { |
200 | 199 | var refs = [] |
201 | 200 | readLine(null, function next(end, line) { |
201 | + /* | |
202 | 202 | if (end === true) |
203 | 203 | cb(new Error('refs line ended early')) |
204 | - else if (end) | |
204 | + else */ | |
205 | + if (end) | |
205 | 206 | cb(end) |
206 | 207 | else if (line === '') |
207 | 208 | cb(null, refs) |
208 | 209 | else { |
@@ -281,9 +282,9 @@ | ||
281 | 282 | return handleConnect(args[1], read) |
282 | 283 | case 'option': |
283 | 284 | return optionSource(args[1]) |
284 | 285 | default: |
285 | - return pull.error(new Error('Unknown command ' + args[0])) | |
286 | + return pull.error(new Error('Unknown command ' + line)) | |
286 | 287 | } |
287 | 288 | } |
288 | 289 | |
289 | 290 | return function (read) { |
@@ -291,12 +292,15 @@ | ||
291 | 292 | b(read) |
292 | 293 | var command |
293 | 294 | |
294 | 295 | function getCommand(cb) { |
295 | - b.lines(null, function (end, line) { | |
296 | + b.lines(null, function next(end, line) { | |
296 | 297 | if (ended = end) |
297 | 298 | return cb(end) |
298 | 299 | |
300 | + if (line == '') | |
301 | + return b.lines(null, next) | |
302 | + | |
299 | 303 | if (options.verbosity > 1) |
300 | 304 | console.error('command:', line) |
301 | 305 | |
302 | 306 | var cmdSource = handleCommand(line, b.passthrough) |
package.json | ||
---|---|---|
@@ -28,8 +28,10 @@ | ||
28 | 28 | "pull-stream": "^3.1.0", |
29 | 29 | "stream-to-pull-stream": "^1.6.6" |
30 | 30 | }, |
31 | 31 | "devDependencies": { |
32 | + "mktemp": "^0.4.0", | |
32 | 33 | "pull-stream": "^3.1.0", |
34 | + "rimraf": "^2.5.1", | |
33 | 35 | "tape": "^4.4.0" |
34 | 36 | } |
35 | 37 | } |
test/run.js | ||
---|---|---|
@@ -1,20 +1,38 @@ | ||
1 | 1 | var spawn = require('child_process').spawn |
2 | 2 | var tape = require('tape') |
3 | +var path = require('path') | |
4 | +var mktemp = require('mktemp') | |
5 | +var rimraf = require('rimraf') | |
3 | 6 | |
4 | 7 | var env = Object.create(process.env) |
5 | -env.PATH = 'test:' + env.PATH | |
8 | +env.PATH = __dirname + ':' + env.PATH | |
6 | 9 | var remote = 'test.js://foo' |
7 | 10 | |
11 | +var tmpDir = mktemp.createDirSync(path.join(require('os').tmpdir(), 'XXXXXXX')) | |
12 | + | |
8 | 13 | function git(args, cb) { |
9 | 14 | spawn('git', args, { |
10 | 15 | env: env, |
11 | - stdio: ['ignore', 'ignore', 'inherit'] | |
16 | + cwd: tmpDir, | |
17 | + stdio: ['ignore', process.stderr, process.stderr] | |
12 | 18 | }).on('close', cb) |
13 | 19 | } |
14 | 20 | |
15 | -tape('push to the remote', function (t) { | |
21 | +tape('init repo', function (t) { | |
22 | + git(['init'], function (code) { | |
23 | + t.equals(code, 0, 'inited') | |
24 | + t.end() | |
25 | + }) | |
26 | +}) | |
27 | + | |
28 | +tape('push with empty repo', function (t) { | |
16 | 29 | git(['push', remote], function (code) { |
17 | - t.equals(code, 0, 'exit status') | |
30 | + t.equals(code, 0, 'pushed') | |
18 | 31 | t.end() |
19 | 32 | }) |
20 | 33 | }) |
34 | + | |
35 | +tape.onFinish(function () { | |
36 | + if (tmpDir) | |
37 | + rimraf.sync(tmpDir) | |
38 | +}) |
Built with git-ssb-web