Skip to content

Commit

Permalink
add message test, fix matcher implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
juliangruber committed Mar 26, 2022
1 parent 1433d4b commit 1758e9d
Show file tree
Hide file tree
Showing 6 changed files with 740 additions and 59 deletions.
65 changes: 10 additions & 55 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"test": "prettier-standard && standard && node test/parallel/* && node test/message"
},
"devDependencies": {
"matcher": "^5.0.0",
"prettier-standard": "^16.4.1",
"standard": "^16.0.4"
},
Expand Down
12 changes: 9 additions & 3 deletions test/message.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ const { exec } = require('child_process')
const assert = require('assert')

const main = async () => {
const { isMatch } = await import('matcher')

const dir = join(__dirname, 'message')
for (const fileName of await fs.readdir(dir)) {
if (extname(fileName) === '.js') {
Expand All @@ -17,20 +15,28 @@ const main = async () => {
filePath.replace('.js', '.out'),
'utf8'
)
console.log(fileName)
let actual
try {
const res = await promisify(exec)(`node ${filePath}`)
actual = res.stdout.trim()
} catch (err) {
actual = err.stdout.trim()
}
const reg = new RegExp(
expected
.replace(/\+/g, '\\+')
.replace(/\*/g, '.*')
)
try {
assert(isMatch(actual, expected, actual))
assert(reg.test(actual))
} catch (err) {
console.error('expected:')
console.error(expected)
console.error('actual:')
console.error(actual)
console.error('reg:')
console.error(reg)
throw err
}
}
Expand Down
7 changes: 7 additions & 0 deletions test/message/test_runner_no_refs.out
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ TAP version 13
code: ERR_TEST_FAILURE
stack: |-
*
*
*
*
*
...
1..1
not ok 1 - does not keep event loop alive
Expand All @@ -17,6 +21,9 @@ not ok 1 - does not keep event loop alive
code: ERR_TEST_FAILURE
stack: |-
*
*
*
*
...
1..1
# tests 1
Expand Down
Loading

0 comments on commit 1758e9d

Please sign in to comment.