mirror of https://github.com/lukechilds/node.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.8 KiB
45 lines
1.8 KiB
10 years ago
|
'use strict';
|
||
14 years ago
|
var common = require('../common');
|
||
|
var assert = require('assert');
|
||
14 years ago
|
var join = require('path').join;
|
||
10 years ago
|
var childProcess = require('child_process');
|
||
14 years ago
|
var fs = require('fs');
|
||
15 years ago
|
|
||
11 years ago
|
var stdoutScript = join(common.fixturesDir, 'echo-close-check.js');
|
||
9 years ago
|
var tmpFile = join(common.tmpDir, 'stdin.txt');
|
||
15 years ago
|
|
||
13 years ago
|
var cmd = '"' + process.argv[0] + '" "' + stdoutScript + '" < "' +
|
||
9 years ago
|
tmpFile + '"';
|
||
15 years ago
|
|
||
14 years ago
|
var string = 'abc\nümlaut.\nsomething else\n' +
|
||
|
'南越国是前203年至前111年存在于岭南地区的一个国家,国都位于番禺,' +
|
||
|
'疆域包括今天中国的广东、广西两省区的大部份地区,福建省、湖南、贵州、' +
|
||
|
'云南的一小部份地区和越南的北部。南越国是秦朝灭亡后,' +
|
||
|
'由南海郡尉赵佗于前203年起兵兼并桂林郡和象郡后建立。前196年和前179年,' +
|
||
|
'南越国曾先后两次名义上臣属于西汉,成为西汉的“外臣”。前112年,' +
|
||
|
'南越国末代君主赵建德与西汉发生战争,被汉武帝于前111年所灭。南越国共存在93年,' +
|
||
|
'历经五代君主。南越国是岭南地区的第一个有记载的政权国家,' +
|
||
|
'采用封建制和郡县制并存的制度,' +
|
||
|
'它的建立保证了秦末乱世岭南地区社会秩序的稳定,' +
|
||
|
'有效的改善了岭南地区落后的政治、##济现状。\n';
|
||
15 years ago
|
|
||
15 years ago
|
|
||
9 years ago
|
common.refreshTmpDir();
|
||
|
|
||
14 years ago
|
console.log(cmd + '\n\n');
|
||
15 years ago
|
|
||
|
try {
|
||
|
fs.unlinkSync(tmpFile);
|
||
|
} catch (e) {}
|
||
|
|
||
15 years ago
|
fs.writeFileSync(tmpFile, string);
|
||
15 years ago
|
|
||
10 years ago
|
childProcess.exec(cmd, function(err, stdout, stderr) {
|
||
15 years ago
|
fs.unlinkSync(tmpFile);
|
||
|
|
||
|
if (err) throw err;
|
||
15 years ago
|
console.log(stdout);
|
||
14 years ago
|
assert.equal(stdout, 'hello world\r\n' + string);
|
||
|
assert.equal('', stderr);
|
||
15 years ago
|
});
|