Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
Checking mergeability… Don't worry, you can still create the pull request.
  • 2 commits
  • 3 files changed
  • 0 commit comments
  • 1 contributor
Showing with 68 additions and 4 deletions.
  1. +7 −3 lib/tap-runner.js
  2. +1 −1  package.json
  3. +60 −0 test/segv.js
View
10 lib/tap-runner.js
@@ -219,18 +219,22 @@ Runner.prototype.runFiles = function (files, dir, cb) {
err += c
})
- cp.on("exit", function (code) {
+ cp.on("exit", function (code, signal) {
if (cp._ended) return
cp._ended = true
- var ok = !cp._timedOut && !code
+ var ok = !cp._timedOut && code === 0
clearTimeout(timeout)
//childTests.forEach(function (c) { self.write(c) })
var res = { name: path.dirname(f).replace(process.cwd() + "/", "")
+ "/" + fileName
, ok: ok
- , timedOut: cp._timedOut
, exit: code }
+ if (cp._timedOut)
+ res.timedOut = cp._timedOut
+ if (signal)
+ res.signal = signal
+
if (err) {
res.stderr = err
if (tc.results.ok &&
View
2  package.json
@@ -1,6 +1,6 @@
{
"name": "tap",
- "version": "0.3.0",
+ "version": "0.3.1",
"author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me)",
"description": "A Test-Anything-Protocol library",
"bin": "bin/tap.js",
View
60 test/segv.js
@@ -0,0 +1,60 @@
+var test = require('../').test
+var Runner = require('../lib/tap-runner.js')
+var TC = require('../lib/tap-consumer.js')
+
+var fs = require('fs')
+var spawn = require('child_process').spawn
+var segv =
+ 'int main (void) {\n' +
+ ' char *s = "hello world";\n' +
+ ' *s = \'H\';\n' +
+ '}\n'
+var compiled = false
+
+test('setup', function (t) {
+ fs.writeFile('segv.c', segv, 'utf8', function (er) {
+ if (er)
+ throw er
+ var cp = spawn('gcc', ['segv.c', '-o', 'segv'])
+ cp.on('exit', function (code, sig) {
+ if (code !== 0) {
+ t.bailout('failed to compile segv program')
+ return
+ }
+ t.pass('compiled seg faulter')
+ t.end()
+ })
+ })
+})
+
+test('segv', function (t) {
+ var r = new Runner({argv:{remain:['./segv']}})
+ var tc = new TC()
+ var expect =
+ [ { 'id': 1,
+ 'ok': false,
+ 'name': ' ././segv',
+ 'exit': null,
+ 'timedOut': true,
+ 'signal': 'SIGBUS',
+ 'command': '"./segv"' }
+ , 'tests 1'
+ , 'fail 1' ]
+ r.pipe(tc)
+ tc.on('data', function (d) {
+ t.same(d, expect.shift())
+ })
+ tc.on('end', function () {
+ t.equal(expect.length, 0)
+ t.end()
+ })
+})
+
+test('cleanup', function (t) {
+ fs.unlink('segv.c', function () {
+ fs.unlink('segv', function () {
+ t.pass('cleaned up')
+ t.end()
+ })
+ })
+})

No commit comments for this range

Something went wrong with that request. Please try again.