Skip to content

Commit

Permalink
Use an own http server for testing (jerryscript-project#1103)
Browse files Browse the repository at this point in the history
This fixes the test failure or delay upon Travis.

The old test assumes that a web server runs on the localhost with default port. So, the requested socket could be hangged up when the web server is busy. That could cause delays or timeout especially on Travis.

IoT.js-DCO-1.0-Signed-off-by: Daeyeon Jeong [email protected]
  • Loading branch information
daeyeon authored and yichoi committed Aug 8, 2017
1 parent 54f6fdd commit abcfeab
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions test/run_pass/test_net_http_request_response.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,18 +170,26 @@ request5.end();


// Test the IncomingMessage read function.
var server6 = http.createServer(function(request, response) {
request.on('end', function() {
response.end('ok');
server6.close();
});
}).listen(8080, 5);

var readRequest = http.request({
host: 'localhost',
port: 80,
host: '127.0.0.1',
port: 8080,
path: '/',
method: 'GET'
});
readRequest.end();

readRequest.on('response', function(incomingMessage) {
incomingMessage.on('readable', function() {
var inc = incomingMessage.read();
assert.equal(inc instanceof Buffer, true);
assert(inc.toString('utf8').length > 0);
assert.assert(inc.toString('utf8').length > 0);
});
});

Expand Down

0 comments on commit abcfeab

Please sign in to comment.