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

Merged

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.
  • 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.

Copy link
Member

@lildude lildude left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks.

Note: this PR will not be merged until close to when the next release is made. See here for more details.

@lildude lildude added this pull request to the merge queue Jun 7, 2024
Merged via the queue into github-linguist:master with commit 00bf9c9 Jun 7, 2024
5 checks passed
@spenserblack spenserblack deleted the language/toml/Cargo.toml.orig branch June 7, 2024 11:52
@github-linguist github-linguist locked as resolved and limited conversation to collaborators Sep 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants