-
Notifications
You must be signed in to change notification settings - Fork 121
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
Extend TestingGuide (adds notes on formatting) #216
base: main
Are you sure you want to change the base?
Extend TestingGuide (adds notes on formatting) #216
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
* Follow existing conventions. | ||
|
||
By applying these best practices, we leverage available tools (e.g., test | ||
function names) to make tests easier to discover and maintain. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This a good addition: I would still add some documentation in comment to a test: it's not always clear just from a test name what's going on, and the same logic as in code applies (document the why, the context, the "what's no obvious from the code").
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, comments are also super important, thanks for raising this!
I have some ideas on "comments", so let me treat this as encouragement to extend this PR with a dedicated section on documentation :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Yes discoverability is important here.
Awesome addition. All good practices that we've been telling each other for years but always too lazy to encode in a document. :) |
|
||
When adding new tests, strive to follow these two key rules: | ||
|
||
1. **Follow the existing naming and whitespace style.** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When you say 'existing style', what scope do you have in mind? It could be that the style of a specific directory is inconsistent with the style used in majority of other dialects etc. IE, do we want to make things globally or locally consistent, or something else?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’m deliberately avoiding specifying this :)
Making things globally consistent would be great for... consistency. However, that assumes one size fits all, which isn't always realistic. Given the current state of things, I also feel this would be an impractical goal.
The same applies to per-file vs per-directory consistency. For example, "mlir/test/Dialect/Vector" has around 50 files - enforcing 100% consistency across them would require significant effort and churn.
My view is that contributors and reviewers should make the right call on a case-by-case basis while being mindful of:
- Reinventing the wheel in terms of formatting.
- New tests ignoring existing conventions (whether at the file or directory level).
Ultimately, I see this as a gradual process. Let’s start with these guidelines to help "correct the course." Over time, we can refine them - possibly transitioning from guideline to requirement if it makes sense.
WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've worked on a few different codebases that approached this differently: some preferred local consistency, some global (e.g., google3). I agree that this doesn't have to one or the other and there's some room for interpretation, but at the same time I'd like to have some codified incentive that will push us towards higher quality tests/code.
For example, we could say we prefer global consistency unless the local standards are either higher or more specialized. If a PR adheres to the global standards but sticks like a sore thumb compared to other local code, I'd think that in most cases sending a separate clean up PR would be a reasonable request.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, Jakub! Sorry for the delayed reply—I haven’t had much time for this PR today. 😅
My overall sentiment is that we should approach defining these guidelines as an incremental process, avoiding overly strict or prescriptive rules.
For example, we could say we prefer global consistency unless the local standards are either higher or more specialized.
I personally like that, but I worry that others may disagree, and we might get stuck discussing it. Also, if we ask for global consistency, who is actually going to help us get there with what we have today?
We shouldn't require new contributions to be fully consistent with everything we already have, given how... inconsistent our tests are. 😅
Proposed Levels of Consistency
How about defining different levels of consistency?
-
Per-PR consistency
- When adding new Ops, documentation, and tests, they should use an identical style.
- Mandatory.
-
Per-file consistency
- If a file is already consistent, maintain that.
- If a file is inconsistent, create a GitHub issue to address it.
- Mandatory.
-
Per-directory consistency
- This might require a lot of churn, so I’m unsure about enforcing it strictly.
- Nice-to-have.
-
Per-project (MLIR-wide) consistency
- Achieving this would require volunteers to refactor existing tests.
- Nice-to-have.
This is just a rough idea - suggestions are welcome!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My overall sentiment is that we should approach defining these guidelines as an incremental process, avoiding overly strict or prescriptive rules.
I personally like that, but I worry that others may disagree, and we might get stuck discussing it.
This is a very good point, let's revisit this once the initial version lands.
Also, if we ask for global consistency, who is actually going to help us get there with what we have today?
We shouldn't require new contributions to be fully consistent with everything we already have, given how... inconsistent our tests are.
Maybe 'consistency' is not the best term here. The idea would be that we would be getting closer to the agreed on 'testing guidelines' (similar to the coding standards) incrementally as we land new code, and refactor old tests along the way. Having the coding standards codified and linkable is a fantastic tool in code reviews because it allows you to point out the best practices without making it feel like you are making one-of arguments against someone's implementation. I'd hope that with testing guidelines we can accomplish something similar and gradually steer tests towards higher maintainability/quality/readability.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IE, my proposed rule of thumb would be something along the lines: 'Adhere to the testing guidelines while following the local naming and formatting style.'
// CHECK-LABEL: func @maskedload_regression_3( | ||
// CHECK-SAME: %[[A0:.*]]: memref<16xf32>, | ||
// CHECK-SAME: %[[A1:.*]]: vector<16xf32>) -> vector<16xf32> { | ||
// CHECK: return %[[A1]] : vector<16xf32> | ||
func.func @maskedload_regression_3(%arg0: memref<16xf32>, %arg1: vector<16xf32>) -> vector<16xf32> { | ||
%c0 = arith.constant 0 : index | ||
%vec_i1 = vector.constant_vec_i1 [0] : vector<16xi1> | ||
|
||
%ld = vector.maskedload %arg0[%c0], %vec_i1, %arg1 | ||
: memref<16xf32>, vector<16xi1>, vector<16xf32> into vector<16xf32> | ||
|
||
return %ld : vector<16xf32> | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need all 3 examples to drive your point or could we limit this to just two?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Generalization Takes Three Examples" :)
It allows me to go into a bit of nuance in this paragraph (i.e. to identify the commonalities):
##### Step 2: Improve Test Naming
Instead of using "regression" (which doesn't add unique information), rename
tests based on key attributes:
* All examples test the `vector.maskedload` to `vector.load` lowering.
* The first test uses a _dynamically_ shaped `memref`, while the others use
_static_ shapes.
* The mask in the first two examples is "all true" (`vector.constant_mas
[16]`), while it is "all false" (`vector.constant_mask [0]`) in the thir
example.
* The first and the third tests use `i32` elements, whereas the second uses
`i8`.
That's not something I feel super strongly about. Usually its tricky to see the "optimal" solution on first iteration and I guess that's the case here.
* The mask in the first two examples is "all true" (`vector.constant_mas | ||
[16]`), while it is "all false" (`vector.constant_mask [0]`) in the thir | ||
example. | ||
* The first and the third tests use `i32` elements, whereas the second uses |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The key attributes should reflect what's important for the tested transform, in this case having different data types is good for completeness but they don't trigger any special/separate logic.
It would be sufficient to highlight one case that uses different data type with, for example, a suffix and omit data type for others.
I know that's not the intention behind this example but it can be misused to push for "enterprisification" (classic java gem: https://projects.haykranen.nl/java/) of naming with combinatorial explosion of all the little details.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are good points and I have come across this myself (without a good solution).
One specific example are Vector
ops that can represent "scalars" as:
vector<1xf32>
vsvector<f32>
vsf32
.
To differentiate tests, we started adding things like @name_from_vec0d_to_vec1d
, @name_from_vec1d_to_vec0d
... It spirals very quickly.
I don't have a solution for this, but will definitely incorporate your suggestion to ... not forget about the common sense 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a short paragraph in this commit. Let me know what you think - do we need more?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great clause 👍
It conveys the spirit of these guidelines and defends against too pedantic rule lawyers.
|
||
When adding new tests, strive to follow these two key rules: | ||
|
||
1. **Follow the existing naming and whitespace style.** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Should the existing bad style (test_1, test_2, ...) prevent naming new test cases more reasonably?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great point, thanks! Let me add a dedicated paragraph on that.
Fix formatting, add paragraph on what to do when there's no (good) pre-exisiting style to follow.
Add a section on documentaiton
8d25ae8
to
f362ae2
Compare
Thank you for the reviews 🙏🏻 I've addressed most of your comments + added a section on "commenting"/"documenting". Let me know what you think and I will happily iterate based on the feedback. |
Thanks a lot! We definitely needed some specific guidelines here. Thanks for putting in the time! I think it might be helpful to clarify the level of enforcement we expect for these guidelines and the degree of flexibility we should allow. I fully agree with the motivation points highlighted in the PR but I'm also worried that we make things painfully rigid. If we set the bar too high, there’s a risk that testing becomes tedious enough to potentially impact actual coverage. I’m also worried that some of the renaming/formatting aspects of the guidelines take the focus away in the code reviews from other aspects that should have more attention. To alleviate some of this, esp. if we are going after a high level of enforcement, I think we should put some effort into automating some of the renaming/formatting aspects. For example, we could extend I also feel consistency is open to interpretation. For example, if an existing test uses Anyways, some food for thoughts and probably unpopular opinions I wanted to share 😊. Great writeup and ideas overall. Thanks! |
Thank you for the generous feedback, Diego! These are some great points. Before addressing specific comments, I see the introduction of new testing standards as a three-step process:
This is merely Step 1. Right now, we have neither guidelines nor a clear place to document best practices.
This might be tricky, and I'd rather leave it under-specified. Many LLVM guidelines are also loosely defined, and I think that’s fine.
Agreed - there needs to be a healthy balance. However, IMHO, not enough effort is put into future-proofing and maintaining our tests. My hope is that these guidelines will streamline discussions and reduce time spent debating formats in reviews. Ultimately, this should free up time to focus on the actual code.
I don’t think we should automate this just yet.
I fully agree that better tooling would help, and this is something we should aim for in the future. However, there’s little point in improving tooling if we haven’t yet agreed on what we want to standardize.
I’ve considered extending Below is an automatically generated test check using today's version: // Automatically generated - today’s version
// CHECK-LABEL: func.func @bitcast_2d(
// CHECK-SAME: %[[VAL_0:[0-9]+|[a-zA-Z$._-][a-zA-Z0-9$._-]*]]: vector<2x4xi32>) -> vector<2x16xi8> {
// CHECK: %[[VAL_1:.*]] = vector.bitcast %[[VAL_0]] : vector<2x4xi32> to vector<2x2xi64>
// CHECK: %[[VAL_2:.*]] = vector.bitcast %[[VAL_1]] : vector<2x2xi64> to vector<2x16xi8>
// CHECK: return %[[VAL_2]] : vector<2x16xi8>
func.func @bitcast_2d(%arg0: vector<2x4xi32>) -> vector<2x16xi8> {
%0 = vector.bitcast %arg0 : vector<2x4xi32> to vector<2x2xi64>
%1 = vector.bitcast %0 : vector<2x2xi64> to vector<2x16xi8>
return %1 : vector<2x16xi8>
} For a mild improvement, we could extend // Automatically generated - possible near-future version (mild improvement)
// CHECK-LABEL: func.func @bitcast_2d(
// CHECK-SAME: %[[ARG_0]]: vector<2x4xi32>) -> vector<2x16xi8> {
// CHECK: %[[BITCAST_1:.*]] = vector.bitcast %[[ARG_0]] : vector<2x4xi32> to vector<2x2xi64>
// CHECK: %[[BITCAST_2.:*]] = vector.bitcast %[[BITCAST_1]] : vector<2x2xi64> to vector<2x16xi8>
// CHECK: return %[[BITCAST_2]] : vector<2x16xi8>
func.func @bitcast_2d(%arg0: vector<2x4xi32>) -> vector<2x16xi8> {
%0 = vector.bitcast %arg0 : vector<2x4xi32> to vector<2x2xi64>
%1 = vector.bitcast %0 : vector<2x2xi64> to vector<2x16xi8>
return %1 : vector<2x16xi8>
} However, ideally, we’d want something context-aware, such as: // Human-curated, context-aware naming
// CHECK-LABEL: func.func @bitcast_2d(
// CHECK-SAME: %[[ARG_0]]: vector<2x4xi32>) -> vector<2x16xi8> {
// CHECK: %[[UPCAST:.*]] = vector.bitcast %[[ARG_0]] : vector<2x4xi32> to vector<2x2xi64>
// CHECK: %[[DOWNCAST.:*]] = vector.bitcast %[[UPCAST]] : vector<2x2xi64> to vector<2x16xi8>
// CHECK: return %[[DOWNCAST]] : vector<2x16xi8>
func.func @bitcast_2d(%arg0: vector<2x4xi32>) -> vector<2x16xi8> {
%0 = vector.bitcast %arg0 : vector<2x4xi32> to vector<2x2xi64>
%1 = vector.bitcast %0 : vector<2x2xi64> to vector<2x16xi8>
return %1 : vector<2x16xi8>
} To achieve this level of naming automation, we’d likely need LSP-based tooling, which is beyond my current capacity to explore.
Yes, I deliberately left "consistency" under-specified. I feel it's something where we should trust our judgment. See also this comment from Jakub (my reply). Ultimately, we could reduce it to a simple question:
In this case, assuming
Ultimately, we should also trust our judgment - both as reviewers and contributors. Final point The actual guidelines/requirements boil down to:
The examples I included in this PR are just that - examples. I don’t think the general principles are sufficient without concrete illustrations, but again, these are just suggestions to inspire contributors rather than rigid rules. Thanks for considering this! |
Fix typos/formatting, add paragraph on common sense
/// The permutation map was replaced with vector.transpose | ||
// CHECK-NOT: permutation_map |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This example is also made by the second example. Could they be collapsed?
Also, while the previous 3 examples at least are driven by more detailed narrative, I feel these verbose examples are overkill for a message that is summarized with two bullet points (just to be clear - I mean smaller example is more readable, not adding more description ;) ).
Or perhaps the key parts could use some emphasis (bold etc.). Or the actual test details could be omitted for documentation clarity.
Blob of IR triggers tl;dr before I filter out the message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same for the convolution example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, let me trim these examples. Let me know what you think.
Or perhaps the key parts could use some emphasis (bold etc.).
Is it possible in code blocks in Markdown?
Same for the convolution example.
Yes, it's quite long. It's a bit tricky to find good examples that are also short 🤔 But I totally agree that examples in this guide should be of highest possible quality. No pressure! 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or perhaps the key parts could use some emphasis (bold etc.).
Is it possible in code blocks in Markdown?
Not certain but most likely no (in standard Markdown).
Docs and examples like these are always art of tradeoffs. Do these the examples need to be complete and self-contained? Or are they primarily a vehicle to guide (reader's gaze) through key concepts?
I like the cleanups for Test Documentation Best Practices
section. Each code block has is a self contained example that showcases a concept with matching description.
In case of Example: Improving Test Readability & Naming
, I feel it's hard to follow changes done with each step. Especially as each code block fills up my screen, I have to jump between current block, previous block, and the step description.
Since formatting is not really an option, maybe emphasis by omission of the common elements could help? Sth like:
Base case:
// CHECK-LABEL: func @maskedload_regression_1(
// CHECK-SAME: %[[A0:.*]]: memref<?xf32>,
// CHECK-SAME: %[[A1:.*]]: vector<16xf32>
func.func @maskedload_regression_1(%arg0: memref<?xf32>, %arg1: vector<16xf32>) {
...
// CHECK: %[[LOAD:.*]] = vector.load %[[A0]][%[[C]]] : memref<?xf32>, vector<16xf32>
%ld = vector.maskedload %arg0[%c0], %vec_i1, %arg1
...
}
Step 1 - Use Consistent Variable Names:
// CHECK-LABEL: func @maskedload_regression_1(
// CHECK-SAME: %[[BASE:.*]]: memref<?xf32>,
// CHECK-SAME: %[[PASS_THRU:.*]]: vector<16xf32>
func.func @maskedload_regression_1(%base: memref<?xf32>, %pass_thru: vector<16xf32>) {
...
// CHECK: %[[LOAD:.*]] = vector.load %[[BASE]][%[[C]]]
%ld = vector.maskedload %base[%c0], %mask, %pass_thru
...
}
Step 2 - Improve Test Naming
// CHECK-LABEL: func @maskedload_to_load_dynamic_i32_all_true(
// CHECK-SAME: %[[BASE:.*]]: memref<?xf32>,
// CHECK-SAME: %[[PASS_THRU:.*]]: vector<16xf32>
func.func @maskedload_to_load_dynamic_i32_all_true(%base: memref<?xf32>, %pass_thru: vector<16xf32>) {
...
}
The doc section could open with IR blob with the original three test cases, show these reduced steps, and close with all three test cases shown again with all these steps applied.
As usual, different tradeoffs - just treat it as yet another possibility.
And of course, it is biased toward my style of reading where I prefer to do quick visual diff than read text 😉
When adding new tests, strive to follow these two key rules: | ||
|
||
1. **Follow the existing naming and whitespace style.** | ||
- This applies when modifying existing test files. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/when modifying existing test files/when modifying existing test files that already contain a number of tests following a particular convention that likely fits in that context/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like your suggestion, thanks! Shall we also ask people to create GitHub issues when a test file does not follow a consistent style?
EDIT: Let me add it to #### What if there is no pre-existing style to follow?
and keep this section short.
CC @kuhar (I mentioned something similar in another thread with you)
2. **Consistently document the edge case being tested.** | ||
- Clearly state what makes this test unique and how it complements other | ||
similar tests. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Orthogonal tests
Do not test the same things again and again. When writing tests, decide what are the categories C1,C2, you want to test (e.g. number of loops, data types). That gives a natural namingloop_depth2_int
. Struggling with good naming is sometimes reflective of absence of regular pattern in the set of tests being written.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Names and Comments
Test names should reflect what is being tested. The why shouldnt be attempted to code in the name and unless obvious from code/context, must be added as comment but avoiding over-explainng..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are great, thanks @javedabsar1 ! I'd like to keep this particular section very short (and limit the guidelines to two very high level points). Is it OK if I add these points in #### What if there is no pre-existing style to follow?
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are great, thanks @javedabsar1 ! I'd like to keep this particular section very short (and limit the guidelines to two very high level points). Is it OK if I add these points in
#### What if there is no pre-existing style to follow?
instead?
Sounds good.
Thanks @banach-space for doing this work. much appreciated. |
Thanks, Andrzej. Yes, I mostly agree with all that you said! I think the example you provided above illustrates my specific concern:
Someone might find that Regarding the automation, honestly, I think having a tool that generates variables based on the dialect/op names would be a fantastic starting point and help define where the acceptable bar is. Of course, I'm not saying you should implement such a tool :) |
I agree with you - for that small example, basic variable names would be totally fine (e.g.
I've added a note on "common sense" in this commit. Perhaps I can extend that to capture your feedback (which I agree with). |
…ting) Address comments from Javed
Update 26/2/24 The latest commit addresses comments from @javedabsar1 . Thanks Javed, great suggestions! |
A good rule of thumb is to think of yourself six months from now and ask: | ||
"What might be difficult to decipher without comments?" | ||
|
||
If you expect something to be tricky for future-you, it’s likely to be tricky |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you expect something to be tricky for future-you, it’s likely to be tricky | |
If you expect something to be tricky for the future-you, it’s likely to be tricky |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To me, 'future you' sounds more natural than 'the future you.'
A quick Google search (as a non-scientific way to gauge popularity) also suggests that 'future you' is more commonly used.
But English is my second language, so I’m happy to be corrected :) Perhaps lets see whether anyone else comments?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After I found a few typos I copy-pasted the whole doc to google docs and it gave me blue squiggles under this expression and suggested adding 'the'. I'm no authority either.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"the future-you" sounds odd to me if you haven't already referred to the future-you previously in the sentence.
But if you want to sidestep all this, rephrase to something like "6 months from now" and use more plain, albeit verbose, ways to say this.
|
||
* `@{negative_}?maskedload_to_load_{static|dynamic}_{i32|i8}_{all_true|all_false|mixed}`. | ||
|
||
#### What if there is no pre-existing style to follow? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this section, it aligns pretty close with what I had in mind in one of the comment threads. Thanks!
|
||
If the test file you are modifying lacks a clear style and instead has mixed, | ||
inconsistent styles, try to identify the dominant one and follow it. Even | ||
better, consider refactoring the file to adopt a single, consistent style — |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if it would be worth spelling out that such refactoring should generally go to a separate PR, or if that's obvious.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is something I'd leave under-specified.
I agree with you that such changes should be submitted as a separate PR. At least in general. However, there are downsides:
- more churn + more PR traffic.
Also, sometimes the noise level is fairly low and sending a dedicated PR might be too much. So, I'd trust our judgement on case-by-case basis. Is that OK? We can always refine later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the generic advice that I added recently - https://llvm.org/docs/Contributing.html#how-to-submit-a-patch
Its focus is saving new contributor's time, but it does not disagree with what you've written here.
… formatting) Address latest comments from Jakub
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
…otes on formatting) Address comments from Adam
737ddf9
to
e64268c
Compare
…(adds notes on formatting) Add a note on creating seperate PRs
Update 27/2/24 @adam-smnk , this commit addresses your most recent comments. Thanks for the suggestions 🙏🏻 Also, in this commit I've re-fined the guidelines on creating dedicated "refactoring PRs" (CC @kuhar ). Having re-read that section, it seemed like a useful addition. |
In many cases, it’s best to create a separate PR for test refactoring to reduce | ||
per-PR noise. However, this depends on the scale of changes — reducing PR | ||
traffic is also important. Work with reviewers to use your judgment and decide | ||
the best approach. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
General comment: avoid as many contractions as you can.
This is part of some style guides but I know it's (!) not a universally liked rule. So I'm saying this because personally even I find it slightly clearer when contractions are not used and if you're writing a new document, the cost to remove them is low.
Otherwise, as someone who has spent 0 time in MLIR, I would find this document helpful. It'll have a lot of corner cases of its own but it gives me something to cite to justify my starting points.
|
||
If the test file you are modifying lacks a clear style and instead has mixed, | ||
inconsistent styles, try to identify the dominant one and follow it. Even | ||
better, consider refactoring the file to adopt a single, consistent style — |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the generic advice that I added recently - https://llvm.org/docs/Contributing.html#how-to-submit-a-patch
Its focus is saving new contributor's time, but it does not disagree with what you've written here.
* Use high-level block comments to describe patterns being tested. | ||
* Think about maintainability - comments should help future developers | ||
understand tests at a glance. | ||
* Comments should assist, not replace reading the code. Avoid over-explaining. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The last part seems like a bad transition, not quite a non-sequitur though. Make that into its own point?
- Avoid redundant explanations.
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does feel a bit like:
- do a lot of this
- but don't do too much
- got it?
But this is inherent to the process, and will come down to reviewer preference so I think this is just a feature of communication in general.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's very hard to find the right balance, yes. In fact, one of my goals is to hint that:
- Finding the right balance w.r.t. comments might be your most challenging task.
Let me rephrase this a bit to improve the flow. Perhaps I should re-write it altogether, but I need a bit more time to think about it. Alternatively, wait and see how people use these guidelines in practice 🤷🏻
…gGuide (adds notes on formatting) Addressed comments from David (1/N)
Update 28/2/25 Incorporated most of the suggestions from @DavidSpickett , thanks! (see this commit). I've "resolved" the corresponding threads and left the remaining ones for later. |
Update 2/3/25 Minor updates to address feedback from David: commit |
… TestingGuide (adds notes on formatting) Incorporate suggestions from David (2/N)
f9fafae
to
0e6e62f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks.
Nothing was that misleading, so whatever you do with my remaining suggestions is fine with me. |
… Extend TestingGuide (adds notes on formatting) Address the remaining comments from David
Update 5/3/25 This commit addresses the remaining comments from David, thank you! |
No description provided.