Dredd: Dredd fails if --output dir does not exists

Created on 22 Oct 2017  路  6Comments  路  Source: apiaryio/dredd

Describe your problem

When you specify the output file inside a directory that does not exist, Dredd fail in the boot time. You can not use a hook to create the dir because the fail is previous to the hooks execution.
The directory path should be created, or at least forced whit an option.

What command line options do you use?

$ dredd --reporter junit --output non-existing-dir/dredd.xml

What is in your dredd.yml?

blueprint: api-description.apib
endpoint: 'http://localhost:8080'
path: []

What's your dredd --version output?

dredd v4.5.0 (Darwin 16.7.0; x64)

Does dredd --level=debug uncover something?

No. The output is:

info: Configuration './dredd.yml' found, ignoring other arguments.
warn: Parser warning in file 'api-description.apib': (warning code 13) HTTP header 'Authorization' has no value on line 91
warn: Parser warning in file 'api-description.apib': (warning code 13) HTTP header 'Authorization' has no value on line 215
info: Beginning Dredd testing...
fs.js:653
  return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
                 ^

Error: ENOENT: no such file or directory, open '/Users/alex/src/globalia/ila/fake-countries/fake-countries-rest/non-existing-dir/dredd.xml'
    at Object.fs.openSync (fs.js:653:18)
    at Object.fs.writeFileSync (fs.js:1300:33)
    at Object.fs.appendFileSync (fs.js:1346:6)
    at appendLine (/usr/local/lib/node_modules/dredd/lib/reporters/x-unit-reporter.js:154:15)
    at EventEmitter.<anonymous> (/usr/local/lib/node_modules/dredd/lib/reporters/x-unit-reporter.js:47:9)
    at emitTwo (events.js:130:20)
    at EventEmitter.emit (events.js:213:7)
    at Dredd.emitStart (/usr/local/lib/node_modules/dredd/lib/dredd.js:291:39)
    at /usr/local/lib/node_modules/dredd/lib/dredd.js:139:26
    at /usr/local/lib/node_modules/dredd/lib/dredd.js:282:16
    at /usr/local/lib/node_modules/dredd/node_modules/async/dist/async.js:421:16
    at iteratorCallback (/usr/local/lib/node_modules/dredd/node_modules/async/dist/async.js:998:13)
    at /usr/local/lib/node_modules/dredd/node_modules/async/dist/async.js:906:16
    at /usr/local/lib/node_modules/dredd/lib/dredd.js:274:18
    at /usr/local/lib/node_modules/dredd/node_modules/dredd-transactions/lib/index.js:25:12
    at /usr/local/lib/node_modules/dredd/node_modules/dredd-transactions/lib/parse.js:38:12
    at /usr/local/lib/node_modules/dredd/node_modules/fury/lib/fury.js:169:13
    at /usr/local/lib/node_modules/dredd/node_modules/fury-adapter-apib-parser/lib/adapter.js:71:7
easy to fix

Most helpful comment

Ok, I will try, but tomorrow I have a trip so give me a couple of weeks.

If I show that it's impossible for me, I will told you 馃槄

All 6 comments

Thanks! This definitely makes sense. node-mkdirp could help. Would you be willing to work on this?

I'm developer but I have none, o very little, idea about node.js. I could try, but I'm sure I'm not the best option.

If you tell me more or less where I have to touch, I could try.

Up to you, if you want to try it out 馃槃 I'm happy to assist. This is pretty much "nice to have" feature, although useful, so I can't promise we'll get to this very soon ourselves.

The x-unit reporter would need to create the directory prior to reporting to the file. Using the node-mkdirp package would be probably the most robust way to do so. This would need to happen in the emitter.on 'start' part, because the node-mkdirp needs a callback (it is asynchronous).

Optionally, the other file reporters, such as markdown or html reporters would get similar treatment.

Ok, I will try, but tomorrow I have a trip so give me a couple of weeks.

If I show that it's impossible for me, I will told you 馃槄

@honzajavorek Can I try and fix this?

I'm still in a trip, so I can't fix it until I return at home. So, @jceplaras if you want to fix it, for me is perfect 馃憤

Was this page helpful?
0 / 5 - 0 ratings