Commit 8f0f9ec
committed
tracing: generate macro tests
There are a large number of combinations of field types which currently
are not matched by the level event macros (e.g. `info!`).
Some recent examples from #3407 is the following that doesn't work:
```rust
info!(name: "order.received.ok", order.id = 123, "order received");
```
However, the corresponding `event!` macro does work:
```rust
event!(name: "order.received.ok", Level::INFO, order.id = 123, "order received");
```
And other variants also work:
```rust
// Without `name:` directive
info!(order.id = 123, "order received");
// With another field before the dotted one
info!(name: "order.received.ok", foo = true, order.id = 123, "order received");
```
Many such cases have been fixed in the past (#2983, #2883, #2879).
However, this has been a bit like wack-a-mole, where we keep finding
issues and then fixing those issues, adding extra tests for them and
then going on our way.
Since the complexity is often in combinations (as above, only when using
the `name:` directive together with a dotted field name on the first
field), it would be useful to have some extensive tests that attempt to
cover all possible combinations.
It turns out that there are **a lot** of combiantions.
This change adds an `xtask` that generates tests for event macros (span
macros are out of scope for this change) similar to the ones found in
`tracing/tests/macros.rs`. Which is to say, tests containing macros
which should compile, but don't need to run.
Owing to the large number of combinations, the tests are split into test
files by macro (e.g. `event!`, `info!`) and directive combination (e.g.
no directives, just `name:`, `name:` and `target:`). The tests are kept
in a separate crate outside the main workspace to avoid rust-analyzer
trying to parse the files - as they are quite large. Specifically, there
are 1220 macro invocations per test file.
When run against the unmodified macros in `tracing`, there were 504
`info!` macro invocations which failed to compile, out of a total of
9760 (including all combinations of directives).
The test files are generated (no need to check them in) and then
validated by `cargo check` on CI.
The CI job has not been made blocking because none of the errors have
been fixed yet!1 parent cc44064 commit 8f0f9ec
File tree
8 files changed
+740
-24
lines changed- .github/workflows
- tracing
- test-macros
- tests
- tests
- xtask
- src
8 files changed
+740
-24
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
314 | 314 | | |
315 | 315 | | |
316 | 316 | | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
317 | 331 | | |
318 | 332 | | |
319 | 333 | | |
| |||
326 | 340 | | |
327 | 341 | | |
328 | 342 | | |
| 343 | + | |
329 | 344 | | |
330 | 345 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
0 commit comments