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

Add Cargo.toml.orig as TOML filename #6787

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

spenserblack
Copy link
Contributor

@spenserblack spenserblack commented Apr 8, 2024

This is a file that is generated by commands like cargo package.

Checklist:

  • I am adding a new extension filename to a language.
    • The new extension filename is used in hundreds of repositories on GitHub.com
    • I have included a real-world usage sample for all extensions added in this PR:
      • Sample source(s):
      • Sample license(s):
    • I have included a change to the heuristics to distinguish my language from others using the same extension.
  • I am adding new or changing current functionality
    • I have added or updated the tests for the new or changed functionality.

@spenserblack
Copy link
Contributor Author

I've noticed that some tests for generated files go in test_generated and some in test_blob (like the Cargo.lock test). Is there a reason to choose one over the other?

@spenserblack spenserblack marked this pull request as ready for review April 8, 2024 16:07
@spenserblack spenserblack requested a review from a team as a code owner April 8, 2024 16:07
@Alhadis
Copy link
Collaborator

Alhadis commented Apr 9, 2024

Is there a reason to choose one over the other?

@spenserblack I believe test_blob.rb is for testing the functionality and expected behaviour of the Linguist::Blob class proper, while the test_generated.rb file holds individual tests for the contents of Linguist::Generated (the latter is more format-specific). @lildude will correct me if I'm wrong. 😉

@lildude
Copy link
Member

lildude commented Apr 9, 2024

@Alhadis is spot on. teat_blob.rb is essentially testing the helper methods used by the Blob class which in turn is doing the same things as the tests in test_generated.rb in this case, so there's no value in adding even more tests for generated to test_blob.rb, or test_file_blob.rb which is essentially the same, as that functionality isn't changing. Doing so only unnecessarily extends the time CI takes to run by effectively adding duplicate tests. This is one of a few places where a refactoring has left things in an incomplete and duplicating state. I've been meaning to find time to clean this all up for years 😁

@Alhadis
Copy link
Collaborator

Alhadis commented Apr 9, 2024

This is one of a few places where a refactoring has left things in an incomplete and duplicating state. I've been meaning to find time to clean this all up for years 😁

@lildude One straightforward simplification might be to have test_heuristics.rb index the heuristics and test the samples automatically, unless a heuristics.yml field is define that explicitly disables this behaviour:

 - extensions: ['.tsp']
+  auto_test: false
   rules:
   - language: TypeSpec
     pattern: '^(import|using|namespace|interface|op|model|scalar|alias|union|enum)\s'
   - language: TSPLIB data
     pattern: '^(NAME|TYPE|DIMENSION|EDGE_WEIGHT_TYPE|EDGE_WEIGHT_FORMAT)\s*:'

I bring this up because I recently fixed a pedantic test failure in #6775 (392acb1), and all I needed to add to test_heuristics.rb was just copy+pasting the nearest def test_?_by_heuristics method and updating the language/extension names. This could be automated to use all_fixtures in the absence of an explicit test-method.

In fact, a lot of the pedantic-level tests could be fixed automatically without a contributor's input (possibly via a command-line switch). Specifically, the alphabetisation of arrays in languages.yml and friends.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants