mirror of
https://github.com/erlef/setup-beam.git
synced 2026-07-31 12:10:48 +00:00
Add tests for github actions problem matchers (#64)
This commit is contained in:
@@ -0,0 +1,63 @@
|
|||||||
|
const assert = require('assert')
|
||||||
|
const { problemMatcher } = require('../.github/elixir-matchers.json')
|
||||||
|
|
||||||
|
async function all() {
|
||||||
|
await testElixirMixCompileError()
|
||||||
|
await testElixirMixCompileWarning()
|
||||||
|
await testElixirMixTestFailure()
|
||||||
|
}
|
||||||
|
|
||||||
|
async function testElixirMixCompileError() {
|
||||||
|
const [matcher] = problemMatcher.find(
|
||||||
|
({ owner }) => owner === 'elixir-mixCompileError',
|
||||||
|
).pattern
|
||||||
|
|
||||||
|
const output = '** (CompileError) lib/test.ex:16: undefined function err/0'
|
||||||
|
const [message, , file, line] = output.match(matcher.regexp)
|
||||||
|
assert.equal(file, 'lib/test.ex')
|
||||||
|
assert.equal(line, '16')
|
||||||
|
assert.equal(message, output)
|
||||||
|
}
|
||||||
|
|
||||||
|
async function testElixirMixCompileWarning() {
|
||||||
|
const [messagePattern, filePattern] = problemMatcher.find(
|
||||||
|
({ owner }) => owner === 'elixir-mixCompileWarning',
|
||||||
|
).pattern
|
||||||
|
|
||||||
|
const firstOutput =
|
||||||
|
'warning: variable "err" does not exist and is being expanded to "err()"'
|
||||||
|
const secondOutput = ' lib/test.ex:16: Test.hello/0'
|
||||||
|
|
||||||
|
const [, message] = firstOutput.match(messagePattern.regexp)
|
||||||
|
assert.equal(
|
||||||
|
message,
|
||||||
|
'variable "err" does not exist and is being expanded to "err()"',
|
||||||
|
)
|
||||||
|
|
||||||
|
const [, file, line] = secondOutput.match(filePattern.regexp)
|
||||||
|
assert.equal(file, 'lib/test.ex')
|
||||||
|
assert.equal(line, '16')
|
||||||
|
}
|
||||||
|
|
||||||
|
async function testElixirMixTestFailure() {
|
||||||
|
const [messagePattern, filePattern] = problemMatcher.find(
|
||||||
|
({ owner }) => owner === 'elixir-mixTestFailure',
|
||||||
|
).pattern
|
||||||
|
|
||||||
|
const firstOutput = '1) test throws (TestTest)'
|
||||||
|
const secondOutput = ' test/test_test.exs:9'
|
||||||
|
|
||||||
|
const [, message] = firstOutput.match(messagePattern.regexp)
|
||||||
|
assert.equal(message, 'test throws (TestTest)')
|
||||||
|
|
||||||
|
const [, file, line] = secondOutput.match(filePattern.regexp)
|
||||||
|
assert.equal(file, 'test/test_test.exs')
|
||||||
|
assert.equal(line, '9')
|
||||||
|
}
|
||||||
|
|
||||||
|
all()
|
||||||
|
.then(() => process.exit(0))
|
||||||
|
.catch((err) => {
|
||||||
|
console.error(err)
|
||||||
|
process.exit(1)
|
||||||
|
})
|
||||||
+1
-1
@@ -9,7 +9,7 @@
|
|||||||
"licenses": "yarn licenses generate-disclaimer > 3RD_PARTY_LICENSES",
|
"licenses": "yarn licenses generate-disclaimer > 3RD_PARTY_LICENSES",
|
||||||
"markdownlint": "markdownlint *.md",
|
"markdownlint": "markdownlint *.md",
|
||||||
"shellcheck": "shellcheck src/install-*.sh",
|
"shellcheck": "shellcheck src/install-*.sh",
|
||||||
"test": "node __tests__/setup-beam.test.js",
|
"test": "node __tests__/setup-beam.test.js && node ./__tests__/problem-matchers.test.js",
|
||||||
"yamllint": "yamllint .github/workflows/**.yml && yamllint .*.yml && yamllint *.yml"
|
"yamllint": "yamllint .github/workflows/**.yml && yamllint .*.yml && yamllint *.yml"
|
||||||
},
|
},
|
||||||
"husky": {
|
"husky": {
|
||||||
|
|||||||
Reference in New Issue
Block a user