mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 09:40:21 +00:00
Add test to keep grammar-list synced with submodules (#3793)
* Add test to check if grammar list is outdated * Update grammar list * Fix duplicate punctuation in error messages
This commit is contained in:
@@ -90,7 +90,7 @@ class TestGrammars < Minitest::Test
|
||||
message << unlisted_submodules.sort.join("\n")
|
||||
end
|
||||
|
||||
assert nonexistent_submodules.empty? && unlisted_submodules.empty?, message
|
||||
assert nonexistent_submodules.empty? && unlisted_submodules.empty?, message.sub(/\.\Z/, "")
|
||||
end
|
||||
|
||||
def test_local_scopes_are_in_sync
|
||||
@@ -106,18 +106,24 @@ class TestGrammars < Minitest::Test
|
||||
end
|
||||
end
|
||||
|
||||
def test_readme_file_is_in_sync
|
||||
current_data = File.read("#{ROOT}/vendor/README.md").to_s.sub(/\A.+?<!--.+?-->\n/ms, "")
|
||||
updated_data = `script/list-grammars --print`
|
||||
assert_equal current_data, updated_data, "Grammar list is out-of-date. Run `script/list-grammars`"
|
||||
end
|
||||
|
||||
def test_submodules_have_recognized_licenses
|
||||
unrecognized = submodule_licenses.select { |k,v| v.nil? && Licensee::FSProject.new(k).license_file }
|
||||
unrecognized.reject! { |k,v| PROJECT_WHITELIST.include?(k) }
|
||||
message = "The following submodules have unrecognized licenses:\n* #{unrecognized.keys.join("\n* ")}\n"
|
||||
message << "Please ensure that the project's LICENSE file contains the full text of the license."
|
||||
message << "Please ensure that the project's LICENSE file contains the full text of the license"
|
||||
assert_equal Hash.new, unrecognized, message
|
||||
end
|
||||
|
||||
def test_submodules_have_licenses
|
||||
unlicensed = submodule_licenses.select { |k,v| v.nil? }.reject { |k,v| PROJECT_WHITELIST.include?(k) }
|
||||
message = "The following submodules don't have licenses:\n* #{unlicensed.keys.join("\n* ")}\n"
|
||||
message << "Please ensure that the project has a LICENSE file, and that the LICENSE file contains the full text of the license."
|
||||
message << "Please ensure that the project has a LICENSE file, and that the LICENSE file contains the full text of the license"
|
||||
assert_equal Hash.new, unlicensed, message
|
||||
end
|
||||
|
||||
@@ -127,14 +133,14 @@ class TestGrammars < Minitest::Test
|
||||
HASH_WHITELIST.include?(v) }
|
||||
.map { |k,v| "#{k}: #{v}"}
|
||||
message = "The following submodules have unapproved licenses:\n* #{unapproved.join("\n* ")}\n"
|
||||
message << "The license must be added to the LICENSE_WHITELIST in /test/test_grammars.rb once approved."
|
||||
message << "The license must be added to the LICENSE_WHITELIST in /test/test_grammars.rb once approved"
|
||||
assert_equal [], unapproved, message
|
||||
end
|
||||
|
||||
def test_whitelisted_submodules_dont_have_licenses
|
||||
licensed = submodule_licenses.reject { |k,v| v.nil? }.select { |k,v| PROJECT_WHITELIST.include?(k) }
|
||||
message = "The following whitelisted submodules have a license:\n* #{licensed.keys.join("\n* ")}\n"
|
||||
message << "Please remove them from the project whitelist."
|
||||
message << "Please remove them from the project whitelist"
|
||||
assert_equal Hash.new, licensed, message
|
||||
end
|
||||
|
||||
@@ -142,7 +148,7 @@ class TestGrammars < Minitest::Test
|
||||
used_hashes = submodule_licenses.values.reject { |v| v.nil? || LICENSE_WHITELIST.include?(v) }
|
||||
unused_hashes = HASH_WHITELIST - used_hashes
|
||||
message = "The following whitelisted license hashes are unused:\n* #{unused_hashes.join("\n* ")}\n"
|
||||
message << "Please remove them from the hash whitelist."
|
||||
message << "Please remove them from the hash whitelist"
|
||||
assert_equal Array.new, unused_hashes, message
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user