Skip to content

Commit

Permalink
Improve tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed May 16, 2019
1 parent 4debb76 commit 10594b7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
6 changes: 3 additions & 3 deletions test/helpers/test.gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import getStream from 'get-stream'

import { exec, task, stream } from '../../src/main.js'

const { command, opts, streamOpts, buffer } = JSON.parse(env.INPUT)
const { command, opts, streamOpts, buffer = true } = JSON.parse(env.INPUT)

export const execFunc = () => exec(command, opts)

Expand All @@ -18,10 +18,10 @@ export const streamFunc = () => src(__filename, { buffer })
.pipe(stream(() => command, { ...opts, ...streamOpts }))
.pipe(through.obj(execVinyl))

const cExecVinyl = async function({ path, contents, execa }) {
const cExecVinyl = async function({ contents, execa }) {
const string = await stringifyContents({ contents, execa })
// eslint-disable-next-line no-restricted-globals, no-console
console.log(`${path}\n${string}`)
console.log(string)
}

const stringifyContents = function({ contents, execa }) {
Expand Down
9 changes: 9 additions & 0 deletions test/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ import execa from 'execa'
const GULPFILE = `${__dirname}/helpers/test.gulpfile.js`

const DATA = [
// { method: 'exec', command: true },
// { method: 'task', command: true },
// { method: 'stream', command: true },
// { method: 'stream', command: true, streamOpts: { buffer: false } },
// { method: 'stream', command: true, streamOpts: { result: 'save' } },
{ method: 'stream', command: 'echo test', opts: { verbose: true }, streamOpts: { result: 'save' }, buffer: false },
]

Expand Down Expand Up @@ -40,6 +45,10 @@ const replacePart = function(message, [before, after]) {
const REPLACEMENTS = [
// File paths
[/[^ (\n]+\/[^ )\n]+/gu, '/path'],
// Stack traces
[/ +at [^]+/gu, ' at STACK TRACE'],
// Gulp shows file content that triggered an error
[/[^]+Error: /gu, ''],
// Timestamps
[/\[\d{2}:\d{2}:\d{2}\]/gu, '[12:00:00]'],
// Duration
Expand Down

0 comments on commit 10594b7

Please sign in to comment.