Skip to content

Commit

Permalink
wtf
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Aug 21, 2023
1 parent b459979 commit f856027
Showing 1 changed file with 48 additions and 48 deletions.
96 changes: 48 additions & 48 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@
*/

import assert from 'node:assert/strict'
import {exec as execCb, spawn} from 'node:child_process'
import {exec as execCb} from 'node:child_process'
// . spawn
import fs from 'node:fs/promises'
// . import {sep} from 'node:path'
import {platform} from 'node:process'
// import {platform} from 'node:process'
import test from 'node:test'
import {fileURLToPath} from 'node:url'
import {promisify} from 'node:util'
import concatStream from 'concat-stream'
// . import concatStream from 'concat-stream'
import stripAnsi from 'strip-ansi'

const exec = promisify(execCb)
Expand Down Expand Up @@ -680,60 +681,59 @@ test('args', async function (t) {
// )
// })

await t.test('should support `--watch`', async function () {
// Ignore checking watch mode on Windows.
if (platform === 'win32') {
console.warn('Not checking watch mode on windows…')
return
}
// await t.test('should support `--watch`', async function () {
// // Ignore checking watch mode on Windows.
// if (platform === 'win32') {
// console.warn('Not checking watch mode on windows…')
// return
// }

const url = new URL('watch.txt', base)
await fs.writeFile(url, 'alpha')
// const url = new URL('watch.txt', base)
// await fs.writeFile(url, 'alpha')

await new Promise(function (resolve) {
const delay = 500
// await new Promise(function (resolve) {
// const delay = 500

const proc = spawn(binPath, ['watch.txt', '-w'])
// const proc = spawn(binPath, ['watch.txt', '-w'])

setTimeout(seeYouLaterAlligator, delay)
// setTimeout(seeYouLaterAlligator, delay)

proc.on('close', async function (code) {
assert.equal(code, 0)
await fs.unlink(url)
resolve(undefined)
})
// proc.on('close', async function (code) {
// assert.equal(code, 0)
// await fs.unlink(url)
// resolve(undefined)
// })

proc.stdout.pipe(
concatStream(function (d) {
assert.deepEqual(String(d), '')
})
)
proc.stderr.pipe(
concatStream(function (d) {
assert.deepEqual(
cleanError(String(d)),
[
'Watching... (press CTRL+C to exit)',
'watch.txt: no issues found',
'watch.txt: no issues found',
'\n'
].join('\n')
)
})
)
// proc.stdout.pipe(
// concatStream(function (d) {
// assert.deepEqual(String(d), '')
// })
// )
// proc.stderr.pipe(
// concatStream(function (d) {
// assert.deepEqual(
// cleanError(String(d)),
// [
// 'Watching... (press CTRL+C to exit)',
// 'watch.txt: no issues found',
// 'watch.txt: no issues found',
// '\n'
// ].join('\n')
// )
// })
// )

async function seeYouLaterAlligator() {
await fs.writeFile(url, 'bravo')
setTimeout(afterAWhileCrocodile, delay)
}
// async function seeYouLaterAlligator() {
// await fs.writeFile(url, 'bravo')
// setTimeout(afterAWhileCrocodile, delay)
// }

function afterAWhileCrocodile() {
proc.kill('SIGINT')
}
})
})
// function afterAWhileCrocodile() {
// proc.kill('SIGINT')
// }
// })
// })

// .
// await t.test('should not regenerate when watching', async function () {
// // Ignore checking watch mode on Windows.
// if (platform === 'win32') {
Expand Down

0 comments on commit f856027

Please sign in to comment.