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

Commit f351dd5

Browse files
authored
chore: windows build fixes (#2793)
Stop things that were started and checkout things with the right line endings. Must move gateway fixtures to fixtures dir, or preferably generate data during the tests.
1 parent ceee358 commit f351dd5

File tree

25 files changed

+104
-58
lines changed

25 files changed

+104
-58
lines changed

.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
* text=auto
22
**/test/fixtures/** text eol=lf
3+
**/test/gateway/** text eol=lf
34
**/src/init-files/** text eol=lf
45

56
*.data binary

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,6 @@ docs
2323

2424
# Deployment files
2525
.npmrc
26+
27+
# Editor files
28+
.vscode

packages/interface-ipfs-core/src/add.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ module.exports = (common, options) => {
458458
})
459459

460460
it('should add from a HTTP URL', async () => {
461-
const text = `TEST${Date.now()}`
461+
const text = `TEST${Math.random()}`
462462
const url = echoUrl(text)
463463

464464
const [result, expectedResult] = await Promise.all([
@@ -474,7 +474,7 @@ module.exports = (common, options) => {
474474
})
475475

476476
it('should add from a HTTP URL with redirection', async () => {
477-
const text = `TEST${Date.now()}`
477+
const text = `TEST${Math.random()}`
478478
const url = echoUrl(text) + '?foo=bar#buzz'
479479

480480
const [result, expectedResult] = await Promise.all([
@@ -490,7 +490,7 @@ module.exports = (common, options) => {
490490
})
491491

492492
it('should add from a URL with only-hash=true', async function () {
493-
const text = `TEST${Date.now()}`
493+
const text = `TEST${Math.random()}`
494494
const url = echoUrl(text)
495495

496496
const res = await all(ipfs.add(urlSource(url), { onlyHash: true }))

packages/interface-ipfs-core/src/block/get.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ module.exports = (common, options) => {
5454
})
5555

5656
it('should get a block added as CIDv0 with a CIDv1', async () => {
57-
const input = Buffer.from(`TEST${Date.now()}`)
57+
const input = Buffer.from(`TEST${Math.random()}`)
5858

5959
const res = await ipfs.block.put(input, { version: 0 })
6060

@@ -68,7 +68,7 @@ module.exports = (common, options) => {
6868
})
6969

7070
it('should get a block added as CIDv1 with a CIDv0', async () => {
71-
const input = Buffer.from(`TEST${Date.now()}`)
71+
const input = Buffer.from(`TEST${Math.random()}`)
7272

7373
const res = await ipfs.block.put(input, { version: 1 })
7474

packages/interface-ipfs-core/src/block/put.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ module.exports = (common, options) => {
5656
})
5757

5858
it('should put a buffer, using options', async () => {
59-
const blob = Buffer.from(`TEST${Date.now()}`)
59+
const blob = Buffer.from(`TEST${Math.random()}`)
6060

6161
const block = await ipfs.block.put(blob, {
6262
format: 'raw',

packages/interface-ipfs-core/src/cat.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ module.exports = (common, options) => {
5050
})
5151

5252
it('should cat a file added as CIDv0 with a CIDv1', async () => {
53-
const input = Buffer.from(`TEST${Date.now()}`)
53+
const input = Buffer.from(`TEST${Math.random()}`)
5454

5555
const res = await all(ipfs.add(input, { cidVersion: 0 }))
5656

@@ -64,7 +64,7 @@ module.exports = (common, options) => {
6464
})
6565

6666
it('should cat a file added as CIDv1 with a CIDv0', async () => {
67-
const input = Buffer.from(`TEST${Date.now()}`)
67+
const input = Buffer.from(`TEST${Math.random()}`)
6868

6969
const res = await all(ipfs.add(input, { cidVersion: 1, rawLeaves: false }))
7070

packages/interface-ipfs-core/src/dag/get.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ module.exports = (common, options) => {
138138
})
139139

140140
it('should get a node added as CIDv0 with a CIDv1', async () => {
141-
const input = Buffer.from(`TEST${Date.now()}`)
141+
const input = Buffer.from(`TEST${Math.random()}`)
142142

143143
const node = new DAGNode(input)
144144

@@ -152,7 +152,7 @@ module.exports = (common, options) => {
152152
})
153153

154154
it('should get a node added as CIDv1 with a CIDv0', async () => {
155-
const input = Buffer.from(`TEST${Date.now()}`)
155+
const input = Buffer.from(`TEST${Math.random()}`)
156156

157157
const res = await all(ipfs.add(input, { cidVersion: 1, rawLeaves: false }))
158158

packages/interface-ipfs-core/src/dht/utils.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const multihashing = require('multihashing-async')
44
const CID = require('cids')
55

66
exports.fakeCid = async (data) => {
7-
const bytes = data || Buffer.from(`TEST${Date.now()}`)
7+
const bytes = data || Buffer.from(`TEST${Math.random()}`)
88
const mh = await multihashing(bytes, 'sha2-256')
99
return new CID(0, 'dag-pb', mh)
1010
}

packages/interface-ipfs-core/src/get.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ module.exports = (common, options) => {
4646
})
4747

4848
it('should get a file added as CIDv0 with a CIDv1', async () => {
49-
const input = Buffer.from(`TEST${Date.now()}`)
49+
const input = Buffer.from(`TEST${Math.random()}`)
5050

5151
const res = await all(ipfs.add(input, { cidVersion: 0 }))
5252

@@ -60,7 +60,7 @@ module.exports = (common, options) => {
6060
})
6161

6262
it('should get a file added as CIDv1 with a CIDv0', async () => {
63-
const input = Buffer.from(`TEST${Date.now()}`)
63+
const input = Buffer.from(`TEST${Math.random()}`)
6464

6565
const res = await all(ipfs.add(input, { cidVersion: 1, rawLeaves: false }))
6666

packages/ipfs-mfs/test/core/chmod.js

+12-8
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,12 @@ describe('chmod', () => {
1111
mfs = await createMfs()
1212
})
1313

14+
after(async () => {
15+
await mfs.repo.close()
16+
})
17+
1418
async function testChmod (initialMode, modification, expectedFinalMode) {
15-
const path = `/foo-${Date.now()}`
19+
const path = `/foo-${Math.random()}`
1620

1721
await mfs.write(path, Buffer.from('Hello world'), {
1822
create: true,
@@ -28,7 +32,7 @@ describe('chmod', () => {
2832
}
2933

3034
it('should update the mode for a file', async () => {
31-
const path = `/foo-${Date.now()}`
35+
const path = `/foo-${Math.random()}`
3236

3337
await mfs.write(path, Buffer.from('Hello world'), {
3438
create: true,
@@ -45,7 +49,7 @@ describe('chmod', () => {
4549
})
4650

4751
it('should update the mode for a directory', async () => {
48-
const path = `/foo-${Date.now()}`
52+
const path = `/foo-${Math.random()}`
4953

5054
await mfs.mkdir(path)
5155
const originalMode = (await mfs.stat(path)).mode
@@ -59,7 +63,7 @@ describe('chmod', () => {
5963
})
6064

6165
it('should update the mode for a hamt-sharded-directory', async () => {
62-
const path = `/foo-${Date.now()}`
66+
const path = `/foo-${Math.random()}`
6367

6468
await mfs.mkdir(path)
6569
await mfs.write(`${path}/foo.txt`, Buffer.from('Hello world'), {
@@ -160,7 +164,7 @@ describe('chmod', () => {
160164
})
161165

162166
it('should apply special execute permissions to world', async () => {
163-
const path = `/foo-${Date.now()}`
167+
const path = `/foo-${Math.random()}`
164168
const sub = `${path}/sub`
165169
const file = `${path}/sub/foo.txt`
166170
const bin = `${path}/sub/bar`
@@ -197,7 +201,7 @@ describe('chmod', () => {
197201
})
198202

199203
it('should apply special execute permissions to user', async () => {
200-
const path = `/foo-${Date.now()}`
204+
const path = `/foo-${Math.random()}`
201205
const sub = `${path}/sub`
202206
const file = `${path}/sub/foo.txt`
203207
const bin = `${path}/sub/bar`
@@ -234,7 +238,7 @@ describe('chmod', () => {
234238
})
235239

236240
it('should apply special execute permissions to user and group', async () => {
237-
const path = `/foo-${Date.now()}`
241+
const path = `/foo-${Math.random()}`
238242
const sub = `${path}/sub`
239243
const file = `${path}/sub/foo.txt`
240244
const bin = `${path}/sub/bar`
@@ -271,7 +275,7 @@ describe('chmod', () => {
271275
})
272276

273277
it('should apply special execute permissions to sharded directories', async () => {
274-
const path = `/foo-${Date.now()}`
278+
const path = `/foo-${Math.random()}`
275279
const sub = `${path}/sub`
276280
const file = `${path}/sub/foo.txt`
277281
const bin = `${path}/sub/bar`

packages/ipfs-mfs/test/core/cp.js

+4
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ describe('cp', () => {
2020
mfs = await createMfs()
2121
})
2222

23+
after(async () => {
24+
await mfs.repo.close()
25+
})
26+
2327
it('refuses to copy files without arguments', async () => {
2428
try {
2529
await mfs.cp()

packages/ipfs-mfs/test/core/flush.js

+4
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ describe('flush', () => {
1313
mfs = await createMfs()
1414
})
1515

16+
after(async () => {
17+
await mfs.repo.close()
18+
})
19+
1620
it('flushes the root node', async () => {
1721
const cid = await mfs.flush()
1822

packages/ipfs-mfs/test/core/ls.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ describe('ls', () => {
2121
mfs = await createMfs()
2222
})
2323

24+
after(async () => {
25+
await mfs.repo.close()
26+
})
27+
2428
it('lists the root directory by default', async () => {
2529
const fileName = `small-file-${Math.random()}.txt`
2630
const content = Buffer.from('Hello world')
@@ -145,8 +149,8 @@ describe('ls', () => {
145149

146150
expect(child.Hash.codec).to.equal('raw')
147151

148-
const dir = `/dir-with-raw-${Date.now()}`
149-
const path = `${dir}/raw-${Date.now()}`
152+
const dir = `/dir-with-raw-${Math.random()}`
153+
const path = `${dir}/raw-${Math.random()}`
150154

151155
await mfs.mkdir(dir)
152156
await mfs.cp(`/ipfs/${child.Hash}`, path)

packages/ipfs-mfs/test/core/mkdir.js

+4
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ describe('mkdir', () => {
1717
mfs = await createMfs()
1818
})
1919

20+
after(async () => {
21+
await mfs.repo.close()
22+
})
23+
2024
it('requires a directory', async () => {
2125
try {
2226
await mfs.mkdir('')

packages/ipfs-mfs/test/core/mv.js

+4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ describe('mv', () => {
1616
mfs = await createMfs()
1717
})
1818

19+
after(async () => {
20+
await mfs.repo.close()
21+
})
22+
1923
it('refuses to move files without arguments', async () => {
2024
try {
2125
await mfs.mv()

packages/ipfs-mfs/test/core/read.js

+4
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ describe('read', () => {
1717
mfs = await createMfs()
1818
})
1919

20+
after(async () => {
21+
await mfs.repo.close()
22+
})
23+
2024
it('reads a small file', async () => {
2125
const filePath = '/small-file.txt'
2226

packages/ipfs-mfs/test/core/rm.js

+4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ describe('rm', () => {
1919
mfs = await createMfs()
2020
})
2121

22+
after(async () => {
23+
await mfs.repo.close()
24+
})
25+
2226
it('refuses to remove files without arguments', async () => {
2327
try {
2428
await mfs.rm()

packages/ipfs-mfs/test/core/stat.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ describe('stat', () => {
2121
mfs = await createMfs()
2222
})
2323

24+
after(async () => {
25+
await mfs.repo.close()
26+
})
27+
2428
it('refuses to stat files with an empty path', async () => {
2529
try {
2630
await mfs.stat('')
@@ -130,8 +134,8 @@ describe('stat', () => {
130134

131135
expect(child.Hash.codec).to.equal('raw')
132136

133-
const dir = `/dir-with-raw-${Date.now()}`
134-
const path = `${dir}/raw-${Date.now()}`
137+
const dir = `/dir-with-raw-${Math.random()}`
138+
const path = `${dir}/raw-${Math.random()}`
135139

136140
await mfs.mkdir(dir)
137141
await mfs.cp(`/ipfs/${child.Hash}`, path)

packages/ipfs-mfs/test/core/touch.js

+8-4
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,12 @@ describe('touch', () => {
1313
mfs = await createMfs()
1414
})
1515

16+
after(async () => {
17+
await mfs.repo.close()
18+
})
19+
1620
it('should update the mtime for a file', async () => {
17-
const path = `/foo-${Date.now()}`
21+
const path = `/foo-${Math.random()}`
1822

1923
await mfs.write(path, Buffer.from('Hello world'), {
2024
create: true,
@@ -31,7 +35,7 @@ describe('touch', () => {
3135
})
3236

3337
it('should update the mtime for a directory', async () => {
34-
const path = `/foo-${Date.now()}`
38+
const path = `/foo-${Math.random()}`
3539

3640
await mfs.mkdir(path, {
3741
mtime: new Date()
@@ -47,7 +51,7 @@ describe('touch', () => {
4751
})
4852

4953
it('should update the mtime for a hamt-sharded-directory', async () => {
50-
const path = `/foo-${Date.now()}`
54+
const path = `/foo-${Math.random()}`
5155

5256
await mfs.mkdir(path, {
5357
mtime: new Date()
@@ -67,7 +71,7 @@ describe('touch', () => {
6771
})
6872

6973
it('should create an empty file', async () => {
70-
const path = `/foo-${Date.now()}`
74+
const path = `/foo-${Math.random()}`
7175

7276
await mfs.touch(path, {
7377
flush: true

packages/ipfs-mfs/test/core/write.js

+7-3
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ describe('write', () => {
6262
mfs = await createMfs()
6363
})
6464

65+
after(async () => {
66+
await mfs.repo.close()
67+
})
68+
6569
it('explodes if it cannot convert content to a pull stream', async () => {
6670
try {
6771
await mfs.write('/foo', -1, {
@@ -827,7 +831,7 @@ describe('write', () => {
827831
it('results in the same hash as a sharded directory created by the importer when causing a subshard of a subshard to be created', async function () {
828832
this.timeout(60000)
829833

830-
const dir = `/some-dir-${Date.now()}`
834+
const dir = `/some-dir-${Math.random()}`
831835

832836
const nodeGrContent = Buffer.from([0, 1, 2, 3, 4])
833837
const superModuleContent = Buffer.from([5, 6, 7, 8, 9])
@@ -876,7 +880,7 @@ describe('write', () => {
876880
it('adds files that cause sub-sub-shards to be created', async function () {
877881
// this.timeout(60000)
878882

879-
const dir = `/updated-dir-${Date.now()}`
883+
const dir = `/updated-dir-${Math.random()}`
880884
const buf = Buffer.from([0, 1, 2, 3, 4])
881885

882886
const dirCid = await createShard(mfs.ipld, [{
@@ -898,7 +902,7 @@ describe('write', () => {
898902
it('removes files that cause sub-sub-shards to be removed', async function () {
899903
this.timeout(60000)
900904

901-
const dir = `/imported-dir-${Date.now()}`
905+
const dir = `/imported-dir-${Math.random()}`
902906
const buf = Buffer.from([0, 1, 2, 3, 4])
903907

904908
const dirCid = await createShard(mfs.ipld, [{

0 commit comments

Comments
 (0)