Skip to content

Commit 83c2c3b

Browse files
committedAug 29, 2015
test: lint and refactor to avoid autocrlf issue
The test was failing after adding 'use strict' because the windows CI uses the autocrlf option of git which converts \r into \r\n on checkout. Refactored the test to not read itself anymore and create a temp file on the fly instead to avoid this line-ending issue. PR-URL: #2494 Reviewed-By: Joao Reis <reis@janeasystems.com>
1 parent 4c5fc3b commit 83c2c3b

File tree

2 files changed

+20
-14
lines changed

2 files changed

+20
-14
lines changed
 

‎.eslintignore

-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,5 @@ lib/punycode.js
22
test/addons/doc-*/
33
test/fixtures
44
test/**/node_modules
5-
test/parallel/test-fs-non-number-arguments-throw.js
65
test/disabled
76
test/tmp*/
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,31 @@
1-
var assert = require('assert'),
2-
fs = require('fs'),
3-
saneEmitter,
4-
sanity = 'ire(\'assert\')';
1+
'use strict';
52

6-
saneEmitter = fs.createReadStream(__filename, { start: 17, end: 29 });
3+
const common = require('../common');
4+
const assert = require('assert');
5+
const fs = require('fs');
6+
const path = require('path');
7+
const tempFile = path.join(common.tmpDir, 'fs-non-number-arguments-throw');
78

8-
assert.throws(function () {
9-
fs.createReadStream(__filename, { start: "17", end: 29 });
9+
common.refreshTmpDir();
10+
fs.writeFileSync(tempFile, 'abc\ndef');
11+
12+
// a sanity check when using numbers instead of strings
13+
const sanity = 'def';
14+
const saneEmitter = fs.createReadStream(tempFile, { start: 4, end: 6 });
15+
16+
assert.throws(function() {
17+
fs.createReadStream(tempFile, { start: '4', end: 6 });
1018
}, "start as string didn't throw an error for createReadStream");
1119

12-
assert.throws(function () {
13-
fs.createReadStream(__filename, { start: 17, end: "29" });
20+
assert.throws(function() {
21+
fs.createReadStream(tempFile, { start: 4, end: '6' });
1422
}, "end as string didn't throw an error");
1523

16-
assert.throws(function () {
17-
fs.createWriteStream(__filename, { start: "17" });
24+
assert.throws(function() {
25+
fs.createWriteStream(tempFile, { start: '4' });
1826
}, "start as string didn't throw an error for createWriteStream");
1927

20-
saneEmitter.on('data', function (data) {
21-
// a sanity check when using numbers instead of strings
28+
saneEmitter.on('data', function(data) {
2229
assert.strictEqual(sanity, data.toString('utf8'), 'read ' +
2330
data.toString('utf8') + ' instead of ' + sanity);
2431
});

0 commit comments

Comments
 (0)