mirror of
				https://github.com/KevinMidboe/linguist.git
				synced 2025-10-29 17:50:22 +00:00 
			
		
		
		
	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:
		| @@ -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 | ||||
|   | ||||
		Reference in New Issue
	
	Block a user