Skip to content

Commit

Permalink
test: Please TravisCI
Browse files Browse the repository at this point in the history
  • Loading branch information
q2s2t committed Oct 12, 2018
1 parent 6be37cb commit b3fb376
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ package-lock.json

# Dummy files for local testing
dummy.*
_tmp/

# Editors, IDE & stuff inbetween
.c9
Expand Down
11 changes: 6 additions & 5 deletions lib/stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,14 @@ export class SevenZipStream extends Readable {
onSubprocessError (chunk) {
const stderr = chunk.toString()
const inLineErrorRegExp = /ERROR: (?<message>.*)\n/
const offLineErrorRegExp = /ERROR:\n(?<message>.*)\n/
const offLineErrorRegExp = /(?<level>WARNING|ERROR): (?<message>.+)(\n(?<path>.+)\n)?/
const inLineError = stderr.match(inLineErrorRegExp)
const offLineError = stderr.match(offLineErrorRegExp)
let message = 'unknown error'
message = (inLineError) ? inLineError.groups.message : message
message = (offLineError) ? offLineError.groups.message : message
const err = new Error(message)
const err = new Error('unknown error')
let errProps = {}
errProps = (inLineError) ? inLineError.groups : errProps
errProps = (offLineError) ? offLineError.groups : errProps
Object.assign(err, errProps)
err.stderr = stderr // @TODO doc: usage of raw stderr to get more info
this.emit('error', err)

Expand Down
18 changes: 16 additions & 2 deletions test/func/add.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,29 @@ describe('Functional: add()', function () {

before(function (done) {
rimraf('*/**/.DS_Store')
rimraf(`${tmpDir}/*`)
// rimraf(`${tmpDir}/*`)
done()
})

after(function (done) {
rimraf(`${tmpDir}/*`)
// rimraf(`${tmpDir}/*`)
done()
})

it('should return an error on 7z error', function (done) {
const archive = `${tmpDir}/addnot.7z`
const source = `${mockDir}/dev/null`
const seven = add(archive, source)
seven.on('error', function (err) {
expect(err).to.be.an.instanceof(Error)
expect(err.level).to.equal('WARNING')
expect(err.message).to.equal('No such file or directory')
expect(err.path).to.equal(source)
done()
try { kill(seven._childProcess.pid) } catch (e) {}
})
})

it('should emit progress values', function (done) {
const archive = `${tmpDir}/progress.7z`
const source = `${mockDir}/DirImages/`
Expand Down

0 comments on commit b3fb376

Please sign in to comment.