Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a19de97

Browse filesBrowse files
santigimenoevanlucas
authored andcommitted
test: remove the use of curl in the test suite
There were 2 tests using curl: `test-http-304.js` is removed because it was initially included to test that the 304 response does not contain a body, and this is already covered by `test-http-chunked-304.js`. `test-http-curl-chunk-problem` has been renamed and refactored so instead of using curl, it uses 2 child node processes: one for sending the HTTP request and the other to calculate the sha1sum. Originally, this test was introduced to fix a bug in `nodejs@0.2.x`, and it was not fixed until `nodejs@0.2.5`. A modified version of this test has been run with `nodejs@0.2.0` and reproduces the problem. This same test has been run with `nodejs@0.2.6` and runs correctly. Fixes: #5174 PR-URL: #5750 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Johan Bergström <bugs@bergstroem.nu> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
1 parent 6928a17 commit a19de97
Copy full SHA for a19de97

File tree

Expand file treeCollapse file tree

3 files changed

+93
-89
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

3 files changed

+93
-89
lines changed
Open diff view settings
Collapse file

‎test/parallel/test-http-304.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-http-304.js
-18Lines changed: 0 additions & 18 deletions
This file was deleted.
Collapse file
+93Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
'use strict';
2+
// http://groups.google.com/group/nodejs/browse_thread/thread/f66cd3c960406919
3+
const common = require('../common');
4+
const assert = require('assert');
5+
if (!common.hasCrypto) {
6+
console.log('1..0 # Skipped: missing crypto');
7+
return;
8+
}
9+
10+
if (process.argv[2] === 'request') {
11+
const http = require('http');
12+
const options = {
13+
port: common.PORT,
14+
path : '/'
15+
};
16+
17+
http.get(options, (res) => {
18+
res.pipe(process.stdout);
19+
});
20+
21+
return;
22+
}
23+
24+
if (process.argv[2] === 'shasum') {
25+
const crypto = require('crypto');
26+
const shasum = crypto.createHash('sha1');
27+
process.stdin.on('data', (d) => {
28+
shasum.update(d);
29+
});
30+
31+
process.stdin.on('close', () => {
32+
process.stdout.write(shasum.digest('hex'));
33+
});
34+
35+
return;
36+
}
37+
38+
const http = require('http');
39+
const cp = require('child_process');
40+
41+
const filename = require('path').join(common.tmpDir, 'big');
42+
43+
function executeRequest(cb) {
44+
cp.exec([process.execPath,
45+
__filename,
46+
'request',
47+
'|',
48+
process.execPath,
49+
__filename,
50+
'shasum' ].join(' '),
51+
(err, stdout, stderr) => {
52+
if (err) throw err;
53+
assert.equal('8c206a1a87599f532ce68675536f0b1546900d7a',
54+
stdout.slice(0, 40));
55+
cb();
56+
}
57+
);
58+
}
59+
60+
61+
common.refreshTmpDir();
62+
63+
const ddcmd = common.ddCommand(filename, 10240);
64+
65+
cp.exec(ddcmd, function(err, stdout, stderr) {
66+
if (err) throw err;
67+
const server = http.createServer(function(req, res) {
68+
res.writeHead(200);
69+
70+
// Create the subprocess
71+
const cat = cp.spawn('cat', [filename]);
72+
73+
// Stream the data through to the response as binary chunks
74+
cat.stdout.on('data', (data) => {
75+
res.write(data);
76+
});
77+
78+
cat.stdout.on('end', () => res.end());
79+
80+
// End the response on exit (and log errors)
81+
cat.on('exit', (code) => {
82+
if (code !== 0) {
83+
console.error('subprocess exited with code ' + code);
84+
process.exit(1);
85+
}
86+
});
87+
88+
});
89+
90+
server.listen(common.PORT, () => {
91+
executeRequest(() => server.close());
92+
});
93+
});
Collapse file

‎test/parallel/test-http-curl-chunk-problem.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-http-curl-chunk-problem.js
-71Lines changed: 0 additions & 71 deletions
This file was deleted.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.