node/test/wasi/test-wasi-io.js
James M Snell 0713ee3a17 test: simplify common/index.js
Move single or trivial and limited use things out of
common/index.js for the purpose of simplifying and reducing
common/index.js

PR-URL: https://github.com/nodejs/node/pull/56712
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2025-01-25 07:23:09 +00:00

20 lines
798 B
JavaScript

'use strict';
require('../common');
const { readFileSync } = require('fs');
const { testWasiPreview1 } = require('../common/wasi');
const checkoutEOL = readFileSync(__filename).includes('\r\n') ? '\r\n' : '\n';
// TODO(@jasnell): It's not entirely clear what this test is asserting.
// More comments would be helpful.
testWasiPreview1(['freopen'], {}, { stdout: `hello from input2.txt${checkoutEOL}` });
testWasiPreview1(['read_file'], {}, { stdout: `hello from input.txt${checkoutEOL}` });
testWasiPreview1(['read_file_twice'], {}, {
stdout: `hello from input.txt${checkoutEOL}hello from input.txt${checkoutEOL}`,
});
// Tests that are currently unsupported on Windows.
if (process.platform !== 'win32') {
testWasiPreview1(['stdin'], { input: 'hello world' }, { stdout: 'hello world' });
}