Skip to content

Commit

Permalink
Create separate dir for integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lukekarrys committed Oct 10, 2024
1 parent 943c1e5 commit b4577e4
Showing 1 changed file with 8 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
// this isn't for coverage. it's basically a smoke test, to ensure that
// we can delete a lot of files on CI in multiple platforms and node versions.
import t from 'tap'

if (/^v10\./.test(process.version)) {
t.plan(0, 'skip this on node 10, it runs out of memory')
process.exit(0)
}
import { statSync, mkdirSync, readdirSync } from '../../src/fs.js'
import { writeFileSync } from 'fs'
import { resolve, dirname } from 'path'
import { manual } from '../../src/index.js'
import { setTimeout } from 'timers/promises'
const cases = { manual }

// run with RIMRAF_TEST_START_CHAR/_END_CHAR/_DEPTH environs to
// make this more or less aggressive.
const START = (process.env.RIMRAF_TEST_START_CHAR || 'a').charCodeAt(0)
const END = (process.env.RIMRAF_TEST_END_CHAR || 'f').charCodeAt(0)
const DEPTH = +(process.env.RIMRAF_TEST_DEPTH || '') || 4

import { statSync, mkdirSync, readdirSync } from '../dist/esm/fs.js'
import { writeFileSync } from 'fs'
import { resolve, dirname } from 'path'

const create = (path: string, depth = 0) => {
mkdirSync(path)
for (let i = START; i <= END; i++) {
Expand All @@ -30,9 +27,6 @@ const create = (path: string, depth = 0) => {
return path
}

import { manual } from '../dist/esm/index.js'
const cases = { manual }

const base = t.testdir(
Object.fromEntries(
Object.entries(cases).map(([name]) => [
Expand All @@ -45,15 +39,15 @@ const base = t.testdir(
),
)

t.test('create all fixtures', t => {
t.test('create all fixtures', async t => {
for (const name of Object.keys(cases)) {
for (const type of ['sync', 'async']) {
const path = `${base}/${name}/${type}/test`
create(path)
t.equal(statSync(path).isDirectory(), true, `${name}/${type} created`)
}
}
setTimeout(() => t.end(), 3000)
await setTimeout(3000)
})

t.test('delete all fixtures', t => {
Expand Down

0 comments on commit b4577e4

Please sign in to comment.