From d10c12dedabee305a051d0ce23991453ac9f8cd8 Mon Sep 17 00:00:00 2001 From: Nico Rehwaldt Date: Mon, 24 Feb 2025 14:18:04 +0100 Subject: [PATCH] test: verify resolution of local plug-in --- test/integration/cli-spec.mjs | 29 ++++++++++++ test/integration/cli/local-rules/.bpmnlintrc | 3 ++ test/integration/cli/local-rules/diagram.bpmn | 47 +++++++++++++++++++ .../local-rules/lib/bpmnlint-plugin/index.js | 11 +++++ .../lib/bpmnlint-plugin/package.json | 6 +++ .../lib/bpmnlint-plugin/rules/no-label-bar.js | 15 ++++++ test/integration/cli/local-rules/package.json | 10 ++++ 7 files changed, 121 insertions(+) create mode 100644 test/integration/cli/local-rules/.bpmnlintrc create mode 100644 test/integration/cli/local-rules/diagram.bpmn create mode 100644 test/integration/cli/local-rules/lib/bpmnlint-plugin/index.js create mode 100644 test/integration/cli/local-rules/lib/bpmnlint-plugin/package.json create mode 100644 test/integration/cli/local-rules/lib/bpmnlint-plugin/rules/no-label-bar.js create mode 100644 test/integration/cli/local-rules/package.json diff --git a/test/integration/cli-spec.mjs b/test/integration/cli-spec.mjs index 0d79659f..b6dd337a 100644 --- a/test/integration/cli-spec.mjs +++ b/test/integration/cli-spec.mjs @@ -220,6 +220,35 @@ describe('cli', function() { }); + describe('should resolve plug-in sources from working directory', function() { + + before(function() { + + this.timeout(100000); + + return exec('install-local', [], __dirname + '/cli/local-rules'); + }); + + + verify({ + cmd: [ 'bpmnlint', 'diagram.bpmn' ], + cwd: __dirname + '/cli/local-rules', + expect: { + code: 1, + stderr: EMPTY, + stdout: ` + + ${diagramPath('local-rules/diagram.bpmn')} + END error Element has non-sense label local/no-label-bar + + ✖ 1 problem (1 error, 0 warnings) + ` + } + }); + + }); + + describe('should handle namespaced packages', function() { before(function() { diff --git a/test/integration/cli/local-rules/.bpmnlintrc b/test/integration/cli/local-rules/.bpmnlintrc new file mode 100644 index 00000000..82a42ee5 --- /dev/null +++ b/test/integration/cli/local-rules/.bpmnlintrc @@ -0,0 +1,3 @@ +{ + "extends": "plugin:local/recommended" +} \ No newline at end of file diff --git a/test/integration/cli/local-rules/diagram.bpmn b/test/integration/cli/local-rules/diagram.bpmn new file mode 100644 index 00000000..e6186205 --- /dev/null +++ b/test/integration/cli/local-rules/diagram.bpmn @@ -0,0 +1,47 @@ + + + + + + + + + + FLOW_1 + + + FLOW_1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/integration/cli/local-rules/lib/bpmnlint-plugin/index.js b/test/integration/cli/local-rules/lib/bpmnlint-plugin/index.js new file mode 100644 index 00000000..2542c6d1 --- /dev/null +++ b/test/integration/cli/local-rules/lib/bpmnlint-plugin/index.js @@ -0,0 +1,11 @@ +module.exports = { + configs: { + recommended: { + extends: 'bpmnlint:recommended', + rules: { + 'no-label-bar': 'error', + 'bpmnlint/label-required': 'off' + } + } + } +}; \ No newline at end of file diff --git a/test/integration/cli/local-rules/lib/bpmnlint-plugin/package.json b/test/integration/cli/local-rules/lib/bpmnlint-plugin/package.json new file mode 100644 index 00000000..3a48c939 --- /dev/null +++ b/test/integration/cli/local-rules/lib/bpmnlint-plugin/package.json @@ -0,0 +1,6 @@ +{ + "name": "bpmnlint-plugin-local", + "version": "0.0.0", + "description": "Local bpmnlint rules", + "main": "index.js" +} diff --git a/test/integration/cli/local-rules/lib/bpmnlint-plugin/rules/no-label-bar.js b/test/integration/cli/local-rules/lib/bpmnlint-plugin/rules/no-label-bar.js new file mode 100644 index 00000000..a23031f7 --- /dev/null +++ b/test/integration/cli/local-rules/lib/bpmnlint-plugin/rules/no-label-bar.js @@ -0,0 +1,15 @@ +/** + * Rule that reports bar labels. + */ +module.exports = function() { + + function check(node, reporter) { + if (/^bar/.test(node.name || '')) { + reporter.report(node.id, 'Element has non-sense label <' + node.name + '>'); + } + } + + return { + check: check + }; +}; \ No newline at end of file diff --git a/test/integration/cli/local-rules/package.json b/test/integration/cli/local-rules/package.json new file mode 100644 index 00000000..d44063f6 --- /dev/null +++ b/test/integration/cli/local-rules/package.json @@ -0,0 +1,10 @@ +{ + "name": "local-rules", + "version": "0.0.0", + "description": "An application that provides local rules", + "main": "index.js", + "dependencies": { + "bpmnlint": "file:../../../..", + "bpmnlint-plugin-local": "file:./lib/bpmnlint-plugin" + } +}