Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Markdown lint version in SARIF output test #469

Merged
merged 2 commits into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion test/fixtures/output/sarif/with_matches.sarif
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"$schema":"https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json","version":"2.1.0","runs":[{"tool":{"driver":{"name":"Markdown lint","version":"0.12.0","informationUri":"https://github.com/markdownlint/markdownlint","rules":[{"id":"MD002","name":"FirstHeaderH1","defaultConfiguration":{"level":"note"},"properties":{"description":"First header should be a top level header","tags":["headers"],"queryURI":"https://github.com/markdownlint/markdownlint/blob/main/docs/RULES.md#md002---first-header-should-be-a-top-level-header"},"shortDescription":{"text":"First header should be a top level header"},"fullDescription":{"text":"First header should be a top level header"},"helpUri":"https://github.com/markdownlint/markdownlint/blob/main/docs/RULES.md#md002---first-header-should-be-a-top-level-header","help":{"text":"More info: https://github.com/markdownlint/markdownlint/blob/main/docs/RULES.md#md002---first-header-should-be-a-top-level-header","markdown":"[More info](https://github.com/markdownlint/markdownlint/blob/main/docs/RULES.md#md002---first-header-should-be-a-top-level-header)"}}]}},"results":[{"ruleId":"MD002","ruleIndex":0,"message":{"text":"MD002 - First header should be a top level header"},"locations":[{"physicalLocation":{"artifactLocation":{"uri":"(stdin)","uriBaseId":"%SRCROOT%"},"region":{"startLine":1}}}]}]}]}
{"$schema":"https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json","version":"2.1.0","runs":[{"tool":{"driver":{"name":"Markdown lint","version":"<%= MarkdownLint::VERSION %>","informationUri":"https://github.com/markdownlint/markdownlint","rules":[{"id":"MD002","name":"FirstHeaderH1","defaultConfiguration":{"level":"note"},"properties":{"description":"First header should be a top level header","tags":["headers"],"queryURI":"https://github.com/markdownlint/markdownlint/blob/main/docs/RULES.md#md002---first-header-should-be-a-top-level-header"},"shortDescription":{"text":"First header should be a top level header"},"fullDescription":{"text":"First header should be a top level header"},"helpUri":"https://github.com/markdownlint/markdownlint/blob/main/docs/RULES.md#md002---first-header-should-be-a-top-level-header","help":{"text":"More info: https://github.com/markdownlint/markdownlint/blob/main/docs/RULES.md#md002---first-header-should-be-a-top-level-header","markdown":"[More info](https://github.com/markdownlint/markdownlint/blob/main/docs/RULES.md#md002---first-header-should-be-a-top-level-header)"}}]}},"results":[{"ruleId":"MD002","ruleIndex":0,"message":{"text":"MD002 - First header should be a top level header"},"locations":[{"physicalLocation":{"artifactLocation":{"uri":"(stdin)","uriBaseId":"%SRCROOT%"},"region":{"startLine":1}}}]}]}]}
2 changes: 1 addition & 1 deletion test/fixtures/output/sarif/without_matches.sarif
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"$schema":"https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json","version":"2.1.0","runs":[{"tool":{"driver":{"name":"Markdown lint","version":"0.12.0","informationUri":"https://github.com/markdownlint/markdownlint","rules":[]}},"results":[]}]}
{"$schema":"https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json","version":"2.1.0","runs":[{"tool":{"driver":{"name":"Markdown lint","version":"<%= MarkdownLint::VERSION %>","informationUri":"https://github.com/markdownlint/markdownlint","rules":[]}},"results":[]}]}
7 changes: 5 additions & 2 deletions test/test_cli.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require_relative 'setup_tests'
require 'open3'
require 'set'
require 'erb'
require 'fileutils'
require 'json'

Expand Down Expand Up @@ -29,15 +30,17 @@ def test_json_output_with_matches
def test_sarif_output
result = run_cli_with_input('-S', "# header\n")
assert_ran_ok(result)
expected = File.read('test/fixtures/output/sarif/without_matches.sarif')
sarif_file = File.read('test/fixtures/output/sarif/without_matches.sarif')
expected = ERB.new(sarif_file).result(binding)
assert_equal(expected, result[:stdout])
end

def test_sarif_output_with_matches
result = run_cli_with_input('-S -r MD002', "## header2\n")
assert_equal(1, result[:status])
assert_equal('', result[:stderr])
expected = File.read('test/fixtures/output/sarif/with_matches.sarif')
sarif_file = File.read('test/fixtures/output/sarif/with_matches.sarif')
expected = ERB.new(sarif_file).result(binding)
assert_equal(expected, result[:stdout])
end

Expand Down
Loading