Add failing test for stdout flush on exit
authorRyan Dahl <ry@tinyclouds.org>
Mon, 8 Feb 2010 02:05:58 +0000 (18:05 -0800)
committerRyan Dahl <ry@tinyclouds.org>
Mon, 8 Feb 2010 02:05:58 +0000 (18:05 -0800)
test/mjsunit/fixtures/print-chars.js [new file with mode: 0644]
test/mjsunit/test-readdir.js
test/mjsunit/test-stdout-flush.js [new file with mode: 0644]

diff --git a/test/mjsunit/fixtures/print-chars.js b/test/mjsunit/fixtures/print-chars.js
new file mode 100644 (file)
index 0000000..c4202b6
--- /dev/null
@@ -0,0 +1,12 @@
+process.mixin(require("../common"));
+
+var n = parseInt(process.argv[2]);
+
+var s = "";
+for (var i = 0; i < n-1; i++) {
+  s += 'c';
+}
+
+puts(s); // \n is the nth char.
+
+process.exit(0);
index 766dc6e..8cc0ee8 100644 (file)
@@ -13,6 +13,7 @@ promise.addCallback(function (files) {
                    , 'echo.js'
                    , 'multipart.js'
                    , 'nested-index'
+                   , 'print-chars.js'
                    , 'test_ca.pem'
                    , 'test_cert.pem'
                    , 'test_key.pem'
diff --git a/test/mjsunit/test-stdout-flush.js b/test/mjsunit/test-stdout-flush.js
new file mode 100644 (file)
index 0000000..52d9633
--- /dev/null
@@ -0,0 +1,44 @@
+process.mixin(require("./common"));
+
+var sub = path.join(fixturesDir, 'print-chars.js');
+
+completedTests = 0;
+
+function test (n, cb) {
+  var child = process.createChildProcess(process.argv[0], [sub, n]);
+
+  var count = 0;
+
+  child.addListener("error", function (data){
+    if (data) {
+      puts("parent stderr: " + data);
+      assert.ok(false);
+    }
+  });
+
+  child.addListener("output", function (data){
+    if (data) {
+      count += data.length;
+    }
+  });
+
+  child.addListener("exit", function (data) {
+    assert.equal(n, count);
+    puts(n + " okay");
+    completedTests++;
+    if (cb) cb();
+  });
+}
+
+
+
+test(5000, function () {
+  test(50000, function () {
+    test(500000);
+  });
+});
+
+
+process.addListener('exit', function () {
+  assert.equal(3, completedTests);
+});