Test that grammars.yml lists the right scopes for each submodule

convert-grammars now supports a few flags that we can use to make it
dump out the YAML just for the local grammar submodules. We can then
compare this to the YAML that's actually in grammars.yml to check that
they're the same. If they aren't, grammars.yml needs to be updated.
This will help catch mistakes like using the wrong scope name.
This commit is contained in:
Adam Roben
2014-12-22 16:35:01 -05:00
parent 78a0030d46
commit ada6f6882a
2 changed files with 63 additions and 10 deletions

View File

@@ -36,4 +36,17 @@ class TestGrammars < Minitest::Test
assert nonexistent_submodules.empty? && unlisted_submodules.empty?, message
end
def test_local_scopes_are_in_sync
actual = YAML.load(`"#{File.join(ROOT, "script", "convert-grammars")}" --output - --no-install --no-remote 2>/dev/null`)
assert_predicate $?, :success?
# We're not checking remote grammars. That can take a long time and make CI
# flaky if network conditions are poor.
@grammars.delete_if { |k, v| k.start_with?("http:", "https:") }
@grammars.each do |k, v|
assert_equal v, actual[k], "The scopes listed for #{k} in grammars.yml don't match the scopes found in that repository"
end
end
end