Skip to content

Commit

Permalink
test dir creation
Browse files Browse the repository at this point in the history
Signed-off-by: Jan Kowalleck <[email protected]>
  • Loading branch information
jkowalleck committed Dec 22, 2024
1 parent 537ae97 commit 3c5f237
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ export async function run (process: NodeJS.Process): Promise<number> {
}
const directory = dirname(options.outputFile)
if (!existsSync(directory)) {
myConsole.info('INFO | Creating directory', directory)
myConsole.info('INFO | creating directory', directory)
mkdirSync(directory, { recursive: true })
}
myConsole.log('LOG | writing BOM to', options.outputFile)
Expand Down
18 changes: 8 additions & 10 deletions tests/integration/cli.from-setups.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ Copyright (c) OWASP Foundation. All Rights Reserved.
*/

const { spawnSync } = require('child_process')
const { join } = require('path')
const { writeFileSync, readFileSync, mkdirSync } = require('fs')
const { dirname, join } = require('path')
const { writeFileSync, readFileSync } = require('fs')

const { describe, expect, test } = require('@jest/globals')

Expand All @@ -37,9 +37,6 @@ describe('integration.cli.from-setups', () => {
const formats = ['json', 'xml']

describe('dummy_projects', () => {
const tmpRootRun = join(tmpRoot, 'with-prepared')
mkdirSync(tmpRootRun)

const useCases = [
{
subject: 'bare',
Expand All @@ -60,7 +57,8 @@ describe('integration.cli.from-setups', () => {

function runTest (subject, project, format, additionalCliArgs = []) {
const expectedOutSnap = join(dummyResultsRoot, subject, `${project}.snap.${format}`)
const outFile = join(tmpRoot, `${subject}_${project}.${format}`)
const outFile = join(tmpRoot, subject, `${project}.${format}`)
// no need to create that outFile dir first - the tool is expected to do that for us
const res = spawnSync(
process.execPath,
['--', cliWrapper,
Expand All @@ -69,10 +67,11 @@ describe('integration.cli.from-setups', () => {
'--output-format', format,
'--output-reproducible',
'--output-file', outFile,
'--validate'
'--validate',
'-vvv'
], {
cwd: join(dummyProjectsRoot, project),
stdio: ['ignore', 'inherit', 'pipe'],
stdio: ['ignore', 'ignore', 'pipe'],
encoding: 'utf8'
}
)
Expand All @@ -84,6 +83,7 @@ describe('integration.cli.from-setups', () => {
process.stderr.write('\n')
throw err
}

const actualOutput = makeReproducible(format, readFileSync(outFile, 'utf8'))

if (UPDATE_SNAPSHOTS) {
Expand All @@ -97,8 +97,6 @@ describe('integration.cli.from-setups', () => {
}

describe.each(useCases)('subject: $subject', (ud) => {
mkdirSync(join(tmpRootRun, ud.subject))

describe.each(ud.dummyProject)('dummyProject: %s', (dummyProject) => {
describe.each(formats)('format: %s', (format) => {
(skipAllTests
Expand Down

0 comments on commit 3c5f237

Please sign in to comment.