Skip to content
This repository was archived by the owner on Aug 12, 2020. It is now read-only.

Commit aa21ff3

Browse files
richardschneiderdaviddias
authored andcommittedNov 10, 2017
feat: windows interop (#195)
* fix: export files with a POSIX path * test(with-dag-api): some fixup for windows It is still failing, because it uses IPFS for testing and IPFS is not yet windows ready. * chore: run on appveyor * test: run more tests in the browser * test: timeout * test: remove debug code * test: fix lint issues * test(browser): are taking forever!!! * test: skip with-dag-api until #196 is resolved * test: more timeouts * Revert "test: run more tests in the browser" This reverts commit c6f2bff. * test: more testing issues * chore: npm ERR! peer dep missing: ajv@^5.0.0, required by ajv-keywords@2.1.1 * test: lint issues * test: more issues * test: follow the standards * test: ipfs-repo@0.18.3 breaks our tests * chore: bump deps * chore: bump timeouts for nodejs 6
1 parent 90dd99a commit aa21ff3

13 files changed

+61
-22
lines changed
 

‎.appveyor.yml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
environment:
2+
matrix:
3+
- nodejs_version: "6"
4+
- nodejs_version: "8"
5+
6+
# cache:
7+
# - node_modules
8+
9+
platform:
10+
- x64
11+
12+
install:
13+
- ps: Install-Product node $env:nodejs_version $env:platform
14+
- npm install
15+
16+
test_script:
17+
- node --version
18+
- npm --version
19+
- npm test
20+
21+
build: off
22+
23+
version: "{build}"

‎package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,12 @@
4141
"homepage": "https://github.com/ipfs/js-ipfs-unixfs-engine#readme",
4242
"devDependencies": {
4343
"aegir": "^12.1.3",
44+
"ajv": "^5.3.0",
4445
"chai": "^4.1.2",
4546
"dirty-chai": "^2.0.1",
4647
"ipfs": "~0.26.0",
4748
"ipfs-block-service": "~0.13.0",
48-
"ipfs-repo": "~0.18.3",
49+
"ipfs-repo": "0.18.3",
4950
"ncp": "^2.0.0",
5051
"pre-commit": "^1.2.2",
5152
"pull-generate": "^2.2.0",

‎src/exporter/dir-flat.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
'use strict'
22

3-
const path = require('path')
43
const pull = require('pull-stream')
54
const paramap = require('pull-paramap')
65
const CID = require('cids')
@@ -22,7 +21,7 @@ function dirExporter (node, name, pathRest, ipldResolver, resolve, parent) {
2221
pull.values(node.links),
2322
pull.map((link) => ({
2423
linkName: link.name,
25-
path: path.join(name, link.name),
24+
path: name + '/' + link.name,
2625
hash: link.multihash
2726
})),
2827
pull.filter((item) => accepts === undefined || item.linkName === accepts),

‎src/exporter/dir-hamt-sharded.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
'use strict'
22

3-
const path = require('path')
43
const pull = require('pull-stream')
54
const paramap = require('pull-paramap')
65
const CID = require('cids')
@@ -25,7 +24,7 @@ function shardedDirExporter (node, name, pathRest, ipldResolver, resolve, parent
2524
pull.map((link) => {
2625
// remove the link prefix (2 chars for the bucket index)
2726
const p = link.name.substring(2)
28-
const pp = p ? path.join(name, p) : name
27+
const pp = p ? name + '/' + p : name
2928
let accept = true
3029
let fromPathRest = false
3130

‎src/exporter/object.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
'use strict'
22

3-
const path = require('path')
43
const CID = require('cids')
54
const pull = require('pull-stream')
65
const pullDefer = require('pull-defer')
@@ -10,7 +9,7 @@ module.exports = (node, name, pathRest, ipldResolver, resolve) => {
109
if (pathRest.length) {
1110
const pathElem = pathRest.shift()
1211
newNode = node[pathElem]
13-
const newName = path.join(name, pathElem)
12+
const newName = name + '/' + pathElem
1413
if (CID.isCID(newNode)) {
1514
const d = pullDefer.source()
1615
ipldResolver.get(sanitizeCID(newNode), (err, newNode) => {

‎test/builder-dir-sharding.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const leftPad = require('left-pad')
1818

1919
module.exports = (repo) => {
2020
describe('builder: directory sharding', function () {
21-
this.timeout(20 * 1000)
21+
this.timeout(30 * 1000)
2222

2323
let ipldResolver
2424

‎test/exporter-subtree.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ const exporter = unixFSEngine.exporter
1616
const smallFile = loadFixture(__dirname, 'fixtures/200Bytes.txt')
1717

1818
module.exports = (repo) => {
19-
describe('exporter', () => {
19+
describe('exporter', function () {
20+
this.timeout(10 * 1000)
21+
2022
let ipldResolver
2123

2224
before(() => {

‎test/exporter.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ module.exports = (repo) => {
8383
fileEql(files[0], bigFile, done)
8484
})
8585
)
86-
})
86+
}).timeout(30 * 1000)
8787

8888
it('export a small file with links using CID instead of multihash', (done) => {
8989
const cid = new CID('QmW7BDxEbGqxxSYVtn3peNPQgdDXbWkoQ6J1EFYAEuQV3Q')
@@ -96,7 +96,7 @@ module.exports = (repo) => {
9696
fileEql(files[0], bigFile, done)
9797
})
9898
)
99-
})
99+
}).timeout(30 * 1000)
100100

101101
it('export a large file > 5mb', (done) => {
102102
const hash = 'QmRQgufjp9vLE8XK2LGKZSsPCFCF6e4iynCQtNB5X2HBKE'
@@ -109,7 +109,7 @@ module.exports = (repo) => {
109109
fileEql(files[0], null, done)
110110
})
111111
)
112-
})
112+
}).timeout(30 * 1000)
113113

114114
it('export a directory', (done) => {
115115
const hash = 'QmWChcSFMNcFkfeJtNd8Yru1rE6PhtCRfewi1tMwjkwKjN'
@@ -149,7 +149,7 @@ module.exports = (repo) => {
149149
)
150150
})
151151
)
152-
})
152+
}).timeout(30 * 1000)
153153

154154
it('returns an empty stream for dir', (done) => {
155155
const hash = 'QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn'

‎test/hamt.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ describe('HAMT', () => {
9797
})
9898

9999
it('can remove all the keys and still find remaining', function (done) {
100-
this.timeout(30 * 1000)
100+
this.timeout(50 * 1000)
101101

102102
masterHead = keys.pop()
103103
iterate()

‎test/import-export-nested-dir.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ module.exports = (repo) => {
2222
ipldResolver = new IPLDResolver(bs)
2323
})
2424

25-
it('imports', (done) => {
25+
it('imports', function (done) {
26+
this.timeout(20 * 1000)
27+
2628
pull(
2729
pull.values([
2830
{ path: 'a/b/c/d/e', content: pull.values([Buffer.from('banana')]) },
@@ -56,7 +58,9 @@ module.exports = (repo) => {
5658
)
5759
})
5860

59-
it('exports', done => {
61+
it('exports', function (done) {
62+
this.timeout(20 * 1000)
63+
6064
pull(
6165
unixFSEngine.exporter(rootHash, ipldResolver),
6266
pull.collect((err, files) => {

‎test/import-export.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/* eslint-env mocha */
2+
/* eslint max-nested-callbacks: ["error", 5] */
23
'use strict'
34

45
const chai = require('chai')
@@ -32,7 +33,9 @@ function fileEql (f1, fileData, callback) {
3233
}
3334

3435
module.exports = (repo) => {
35-
describe('import and export', () => {
36+
describe('import and export', function () {
37+
this.timeout(30 * 1000)
38+
3639
strategies.forEach((strategy) => {
3740
const importerOptions = { strategy: strategy }
3841

‎test/importer.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ module.exports = (repo) => {
161161
const expected = extend({}, defaultResults, strategies[strategy])
162162

163163
describe('importer: ' + strategy, function () {
164-
this.timeout(20 * 1000)
164+
this.timeout(30 * 1000)
165165

166166
let ipldResolver
167167

‎test/with-dag-api.js

+13-4
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ const pull = require('pull-stream')
1313
const mh = require('multihashes')
1414
const loadFixture = require('aegir/fixtures')
1515
const IPFS = require('ipfs')
16+
const os = require('os')
17+
const path = require('path')
1618

1719
function stringifyMh (files) {
1820
return files.map((file) => {
@@ -105,7 +107,12 @@ const strategyOverrides = {
105107

106108
}
107109

108-
describe('with dag-api', () => {
110+
describe('with dag-api', function () {
111+
// TODO: waiting for IPFS support on windows, https://github.com/ipfs/js-ipfs-unixfs-engine/issues/196
112+
if (os.platform() === 'win32') {
113+
return
114+
}
115+
109116
strategies.forEach(strategy => {
110117
const baseFiles = strategyBaseFiles[strategy]
111118
const defaultResults = extend({}, baseFiles, {
@@ -159,7 +166,7 @@ describe('with dag-api', () => {
159166
const expected = extend({}, defaultResults, strategies[strategy])
160167

161168
describe('importer: ' + strategy, function () {
162-
this.timeout(20 * 1000)
169+
this.timeout(50 * 1000)
163170

164171
let node
165172

@@ -171,9 +178,11 @@ describe('with dag-api', () => {
171178
}
172179
}
173180

174-
before((done) => {
181+
before(function (done) {
182+
this.timeout(30 * 1000)
183+
175184
node = new IPFS({
176-
repo: '/tmp/unixfs-test-' + Math.random(),
185+
repo: path.join(os.tmpdir(), 'unixfs-test-' + Math.random()),
177186
start: false
178187
})
179188

0 commit comments

Comments
 (0)
This repository has been archived.