From 6ce141d308bf2a6aea7bb185c4b89bc6e26ff172 Mon Sep 17 00:00:00 2001 From: Mathias Buus Date: Tue, 17 Dec 2019 11:48:22 +0100 Subject: [PATCH] try to fix flaky tests on ancient osx --- test/helpers/index.js | 6 ++++++ test/links.js | 3 ++- test/misc.js | 15 ++++++++------- test/read.js | 4 ++-- test/statfs.js | 7 ++++--- test/write.js | 3 ++- 6 files changed, 24 insertions(+), 14 deletions(-) create mode 100644 test/helpers/index.js diff --git a/test/helpers/index.js b/test/helpers/index.js new file mode 100644 index 0000000..cf8ee0c --- /dev/null +++ b/test/helpers/index.js @@ -0,0 +1,6 @@ +exports.unmount = function (fuse, cb) { // This only seems to be nessesary an the ancient osx we use on travis so ... yolo + fuse.unmount(function (err) { + if (err) return cb(err) + setTimeout(cb, 1000) + }) +} diff --git a/test/links.js b/test/links.js index ac4b35d..a52d5c1 100644 --- a/test/links.js +++ b/test/links.js @@ -1,6 +1,7 @@ const tape = require('tape') const fs = require('fs') const path = require('path') +const { unmount } = require('./helpers') const Fuse = require('../') const mnt = require('./fixtures/mnt') @@ -53,7 +54,7 @@ tape('readlink', function (t) { t.error(err, 'no error') t.same(buf, Buffer.from('hello world'), 'can read link content') - fuse.unmount(function () { + unmount(fuse, function () { t.end() }) }) diff --git a/test/misc.js b/test/misc.js index 1aec5b6..53644b4 100644 --- a/test/misc.js +++ b/test/misc.js @@ -1,14 +1,15 @@ -var mnt = require('./fixtures/mnt') -var tape = require('tape') +const mnt = require('./fixtures/mnt') +const tape = require('tape') -var Fuse = require('../') +const Fuse = require('../') +const { unmount } = require('./helpers') tape('mount', function (t) { const fuse = new Fuse(mnt, {}, { force: true }) fuse.mount(function (err) { t.error(err, 'no error') t.ok(true, 'works') - fuse.unmount(function () { + unmount(fuse, function () { t.end() }) }) @@ -21,11 +22,11 @@ tape('mount + unmount + mount', function (t) { fuse1.mount(function (err) { t.error(err, 'no error') t.ok(true, 'works') - fuse1.unmount(function () { + unmount(fuse1, function () { fuse2.mount(function (err) { t.error(err, 'no error') t.ok(true, 'works') - fuse2.unmount(function () { + unmount(fuse2, function () { t.end() }) }) @@ -39,7 +40,7 @@ tape('mount + unmount + mount with same instance fails', function (t) { fuse.mount(function (err) { t.error(err, 'no error') t.ok(true, 'works') - fuse.unmount(function () { + unmount(fuse, function () { fuse.mount(function (err) { t.ok(err, 'had error') t.end() diff --git a/test/read.js b/test/read.js index 96be7f5..3115a27 100644 --- a/test/read.js +++ b/test/read.js @@ -6,6 +6,7 @@ const concat = require('concat-stream') const Fuse = require('../') const mnt = require('./fixtures/mnt') const stat = require('./fixtures/stat') +const { unmount } = require('./helpers') tape('read', function (t) { var ops = { @@ -23,7 +24,6 @@ tape('read', function (t) { return process.nextTick(cb, 0, 42) }, release: function (path, fd, cb) { - console.log('IN JS RELEASE') t.same(fd, 42, 'fd was passed to release') return process.nextTick(cb, 0) }, @@ -53,7 +53,7 @@ tape('read', function (t) { fs.createReadStream(path.join(mnt, 'test'), { start: 6, end: 10 }).pipe(concat(function (buf) { t.same(buf, Buffer.from('world'), 'partial read file + start offset') - fuse.unmount(function () { + unmount(fuse, function () { t.end() }) })) diff --git a/test/statfs.js b/test/statfs.js index 558a916..5fcd377 100644 --- a/test/statfs.js +++ b/test/statfs.js @@ -1,7 +1,8 @@ const { exec } = require('child_process') -var tape = require('tape') +const { unmount } = require('./helpers') +const tape = require('tape') -var Fuse = require('../') +const Fuse = require('../') const mnt = require('./fixtures/mnt') const stat = require('./fixtures/stat') @@ -29,7 +30,7 @@ tape('statfs', function (t) { t.error(err, 'no error') exec(`df ${mnt}`, (err) => { t.error(err, 'no error') - fuse.unmount(function () { + unmount(fuse, function () { t.end() }) }) diff --git a/test/write.js b/test/write.js index 7239598..b3aa051 100644 --- a/test/write.js +++ b/test/write.js @@ -5,6 +5,7 @@ const path = require('path') const Fuse = require('../') const mnt = require('./fixtures/mnt') const stat = require('./fixtures/stat') +const { unmount } = require('./helpers') tape('write', function (t) { var created = false @@ -48,7 +49,7 @@ tape('write', function (t) { t.error(err, 'no error') t.same(data.slice(0, size), Buffer.from('hello world'), 'data was written') - fuse.unmount(function () { + unmount(fuse, function () { t.end() }) })