summaryrefslogtreecommitdiff
path: root/test/storage/server.js
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2016-01-05 13:57:40 +0100
committerKonstantin Käfer <mail@kkaefer.com>2016-01-05 14:14:23 +0100
commit0377e23c205decdfd3d9d885af7b0b4078f1448c (patch)
tree75e54a9da08966a822aac95479ec938bd5564ad6 /test/storage/server.js
parent70f04c8bc5ea6869e4631aff490efe646d9d870e (diff)
downloadqtlocation-mapboxgl-0377e23c205decdfd3d9d885af7b0b4078f1448c.tar.gz
[test] terminate test server when stdin closes
Diffstat (limited to 'test/storage/server.js')
-rwxr-xr-xtest/storage/server.js18
1 files changed, 9 insertions, 9 deletions
diff --git a/test/storage/server.js b/test/storage/server.js
index 249c6a124b..a814ce15e6 100755
--- a/test/storage/server.js
+++ b/test/storage/server.js
@@ -2,6 +2,13 @@
/* jshint node: true */
'use strict';
+// This needs to be here to make sure the pipe stays open.
+// We're waiting until the stdin pipe gets closed (e.g. because the parent
+// process dies)
+process.stdin.on('readable', function() {});
+process.stdin.on('end', function() { process.exit(0); });
+
+
var fs = require('fs');
var express = require('express');
var app = express();
@@ -101,13 +108,6 @@ app.get('/load/:number(\\d+)', function(req, res) {
});
var server = app.listen(3000, function () {
- var host = server.address().address;
- var port = server.address().port;
- console.warn('Storage test server listening at http://%s:%s', host, port);
-
- if (process.argv[2]) {
- // Allow the test to continue running.
- fs.write(+process.argv[2], 'OK');
- fs.close(+process.argv[2]);
- }
+ // Tell parent that we're now listening.
+ process.stdout.write("OK");
});