Skip to content

Commit

Permalink
Move more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Jun 26, 2019
1 parent b48988e commit 33d6fe2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
14 changes: 14 additions & 0 deletions test/stream.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import path from 'path';
import fs from 'fs';
import stream from 'stream';
import test from 'ava';
import getStream from 'get-stream';
import tempfile from 'tempfile';
import execa from '..';

process.env.PATH = path.join(__dirname, 'fixtures') + path.delimiter + process.env.PATH;
Expand All @@ -12,6 +14,18 @@ test('buffer', async t => {
t.is(stdout.toString(), 'foo');
});

test('pass `stdout` to a file descriptor', async t => {
const file = tempfile('.txt');
await execa('test/fixtures/noop', ['foo bar'], {stdout: fs.openSync(file, 'w')});
t.is(fs.readFileSync(file, 'utf8'), 'foo bar\n');
});

test('pass `stderr` to a file descriptor', async t => {
const file = tempfile('.txt');
await execa('test/fixtures/noop-err', ['foo bar'], {stderr: fs.openSync(file, 'w')});
t.is(fs.readFileSync(file, 'utf8'), 'foo bar\n');
});

test.serial('result.all shows both `stdout` and `stderr` intermixed', async t => {
const {all} = await execa('noop-132');
t.is(all, '132');
Expand Down
14 changes: 0 additions & 14 deletions test/test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import path from 'path';
import fs from 'fs';
import test from 'ava';
import isRunning from 'is-running';
import tempfile from 'tempfile';
import execa from '..';

process.env.PATH = path.join(__dirname, 'fixtures') + path.delimiter + process.env.PATH;
Expand All @@ -27,18 +25,6 @@ if (process.platform === 'win32') {
});
}

test('pass `stdout` to a file descriptor', async t => {
const file = tempfile('.txt');
await execa('test/fixtures/noop', ['foo bar'], {stdout: fs.openSync(file, 'w')});
t.is(fs.readFileSync(file, 'utf8'), 'foo bar\n');
});

test('pass `stderr` to a file descriptor', async t => {
const file = tempfile('.txt');
await execa('test/fixtures/noop-err', ['foo bar'], {stderr: fs.openSync(file, 'w')});
t.is(fs.readFileSync(file, 'utf8'), 'foo bar\n');
});

test('execa.sync()', t => {
const {stdout} = execa.sync('noop', ['foo']);
t.is(stdout, 'foo');
Expand Down

0 comments on commit 33d6fe2

Please sign in to comment.