Skip to content

Commit

Permalink
Fix plural (s) and add polkadot#7537 test
Browse files Browse the repository at this point in the history
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
  • Loading branch information
ggwpez committed Jul 24, 2023
1 parent 3638de7 commit c4a26d0
Show file tree
Hide file tree
Showing 19 changed files with 78 additions and 65 deletions.
3 changes: 2 additions & 1 deletion src/cmd/lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -469,13 +469,14 @@ fn error_stats(errors: usize, warnings: usize, fixes: usize, fix: bool) -> Strin
if warnings + errors > 0 {
ret.push_str(" and");
}
ret.push_str(&format!(" fixed {} issue{}", fixes, plural(fixes)));
ret.push_str(&format!(" fixed {}", fixes));
if fix && fixes < errors {
ret.push_str(&format!(" ({} could not be fixed)", errors - fixes));
}
ret
}

/// Add an plural `s` for English grammar iff `n != 1`.
fn plural(n: usize) -> &'static str {
if n == 1 {
""
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/polkadot/issue-7261.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ cases:
beefy-primitives (renamed from sp-consensus-beefy)
sp-mmr-primitives
sp-trie
Found 5 issues and fixed 0 issues.
Found 5 issues and fixed 0.
12 changes: 12 additions & 0 deletions tests/integration/polkadot/issue-7537.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
repo:
name: polkadot
ref: 30a0be939e09c3ad9c471960091b32a5b3f9c622
cases:
- cmd: lint propagate-feature -p xcm-executor --feature std
stdout: |
crate "xcm-executor"
feature "std"
must propagate to:
environmental
frame-benchmarking
Found 2 issues and fixed 0.
8 changes: 4 additions & 4 deletions tests/integration/substrate/frame-support.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ cases:
serde_json
sp-debug-derive
sp-state-machine
Found 7 issues and fixed 0 issues.
Found 7 issues and fixed 0.
- cmd: lint propagate-feature -p frame-support --feature std --workspace
stdout: |
crate "frame-support"
Expand All @@ -29,20 +29,20 @@ cases:
frame-system
sp-debug-derive
sp-state-machine
Found 3 issues and fixed 0 issues.
Found 3 issues and fixed 0.
- cmd: lint propagate-feature -p frame-support --feature try-runtime
stdout: |
crate "frame-support"
feature "try-runtime"
must propagate to:
frame-system
sp-runtime
Found 2 issues and fixed 0 issues.
Found 2 issues and fixed 0.
- cmd: lint propagate-feature -p frame-support --feature try-runtime --workspace
stdout: |
crate "frame-support"
feature "try-runtime"
must propagate to:
frame-system
sp-runtime
Found 2 issues and fixed 0 issues.
Found 2 issues and fixed 0.
8 changes: 4 additions & 4 deletions tests/integration/substrate/frame.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ cases:
frame-support
frame-system
sp-runtime
Found 3 issues and fixed 0 issues.
Found 3 issues and fixed 0.
- cmd: lint propagate-feature -p frame --feature runtime-benchmarks --workspace
stdout: |
crate "frame"
Expand All @@ -25,7 +25,7 @@ cases:
frame-support
frame-system
sp-runtime
Found 3 issues and fixed 0 issues.
Found 3 issues and fixed 0.
- cmd: lint propagate-feature -p frame --feature try-runtime
stdout: |
crate "frame"
Expand All @@ -35,7 +35,7 @@ cases:
frame-support
frame-system
sp-runtime
Found 4 issues and fixed 0 issues.
Found 4 issues and fixed 0.
- cmd: lint propagate-feature -p frame --feature try-runtime --workspace
stdout: |
crate "frame"
Expand All @@ -45,7 +45,7 @@ cases:
frame-support
frame-system
sp-runtime
Found 4 issues and fixed 0 issues.
Found 4 issues and fixed 0.
- cmd: lint never-enables --precondition default --stays-disabled runtime-benchmarks
- cmd: lint never-enables --precondition default --stays-disabled try-runtime
- cmd: lint never-enables --precondition default --stays-disabled runtime-benchmarks --workspace
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/substrate/issue-14044-pre.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ cases:
frame-system
sp-runtime
sp-staking
Found 3 issues and fixed 0 issues.
Found 3 issues and fixed 0.
12 changes: 6 additions & 6 deletions tests/integration/substrate/master.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1153,7 +1153,7 @@ cases:
is required by 2 dependencies:
sc-service
sp-runtime
Found 549 issues and fixed 0 issues.
Found 549 issues and fixed 0.
- cmd: lint propagate-feature --feature runtime-benchmarks --workspace
stdout: |
crate "binary-merkle-tree"
Expand Down Expand Up @@ -2305,7 +2305,7 @@ cases:
is required by 2 dependencies:
sc-service
sp-runtime
Found 549 issues and fixed 0 issues.
Found 549 issues and fixed 0.
- cmd: lint propagate-feature --feature std
stdout: |
crate "Inflector"
Expand Down Expand Up @@ -6419,7 +6419,7 @@ cases:
feature "std"
must propagate to:
libc
Found 2230 issues and fixed 0 issues.
Found 2230 issues and fixed 0.
- cmd: lint propagate-feature --feature std --workspace
stdout: |
crate "binary-merkle-tree"
Expand Down Expand Up @@ -7737,7 +7737,7 @@ cases:
sp-transaction-storage-proof
sp-version
sp-weights
Found 757 issues and fixed 0 issues.
Found 757 issues and fixed 0.
- cmd: lint propagate-feature --feature try-runtime
stdout: |
crate "binary-merkle-tree"
Expand Down Expand Up @@ -8847,7 +8847,7 @@ cases:
must propagate to:
frame-try-runtime
sp-runtime
Found 510 issues and fixed 0 issues.
Found 510 issues and fixed 0.
- cmd: lint propagate-feature --feature try-runtime --workspace
stdout: |
crate "binary-merkle-tree"
Expand Down Expand Up @@ -9957,4 +9957,4 @@ cases:
must propagate to:
frame-try-runtime
sp-runtime
Found 510 issues and fixed 0 issues.
Found 510 issues and fixed 0.
2 changes: 1 addition & 1 deletion tests/ui/lint/propagate-feature/args.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ cases:
feature "F0"
must propagate to:
B
Found 1 issue and fixed 0 issues.
Found 1 issue and fixed 0.
16 changes: 8 additions & 8 deletions tests/ui/lint/propagate-feature/diamond.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,28 +34,28 @@ cases:
feature "F0"
must propagate to:
D
Found 3 issues and fixed 0 issues.
Found 3 issues and fixed 0.
- cmd: lint propagate-feature -p A --feature F0
stdout: |
crate "A"
feature "F0"
must propagate to:
C
Found 1 issue and fixed 0 issues.
Found 1 issue and fixed 0.
- cmd: lint propagate-feature -p B --feature F0
stdout: |
crate "B"
feature "F0"
is required by 1 dependency:
D
Found 1 issue and fixed 0 issues.
Found 1 issue and fixed 0.
- cmd: lint propagate-feature -p C --feature F0
stdout: |
crate "C"
feature "F0"
must propagate to:
D
Found 1 issue and fixed 0 issues.
Found 1 issue and fixed 0.
- cmd: lint propagate-feature -p D --feature F0
stdout: |
Found no issues.
Expand All @@ -76,28 +76,28 @@ cases:
feature "F0"
must propagate to:
D
Found 3 issues and fixed 0 issues.
Found 3 issues and fixed 0.
- cmd: lint propagate-feature -p A --feature F0 --workspace
stdout: |
crate "A"
feature "F0"
must propagate to:
C
Found 1 issue and fixed 0 issues.
Found 1 issue and fixed 0.
- cmd: lint propagate-feature -p B --feature F0 --workspace
stdout: |
crate "B"
feature "F0"
is required by 1 dependency:
D
Found 1 issue and fixed 0 issues.
Found 1 issue and fixed 0.
- cmd: lint propagate-feature -p C --feature F0 --workspace
stdout: |
crate "C"
feature "F0"
must propagate to:
D
Found 1 issue and fixed 0 issues.
Found 1 issue and fixed 0.
- cmd: lint propagate-feature -p D --feature F0 --workspace
stdout: |
Found no issues.
16 changes: 8 additions & 8 deletions tests/ui/lint/propagate-feature/diamond_re.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,28 +38,28 @@ cases:
feature "F0"
must propagate to:
dd (renamed from D)
Found 3 issues and fixed 0 issues.
Found 3 issues and fixed 0.
- cmd: lint propagate-feature -p A --feature F0
stdout: |
crate "A"
feature "F0"
must propagate to:
c (renamed from C)
Found 1 issue and fixed 0 issues.
Found 1 issue and fixed 0.
- cmd: lint propagate-feature -p B --feature F0
stdout: |
crate "B"
feature "F0"
is required by 1 dependency:
d (renamed from D)
Found 1 issue and fixed 0 issues.
Found 1 issue and fixed 0.
- cmd: lint propagate-feature -p C --feature F0
stdout: |
crate "C"
feature "F0"
must propagate to:
dd (renamed from D)
Found 1 issue and fixed 0 issues.
Found 1 issue and fixed 0.
- cmd: lint propagate-feature -p D --feature F0
stdout: |
Found no issues.
Expand All @@ -80,28 +80,28 @@ cases:
feature "F0"
must propagate to:
dd (renamed from D)
Found 3 issues and fixed 0 issues.
Found 3 issues and fixed 0.
- cmd: lint propagate-feature -p A --feature F0 --workspace
stdout: |
crate "A"
feature "F0"
must propagate to:
c (renamed from C)
Found 1 issue and fixed 0 issues.
Found 1 issue and fixed 0.
- cmd: lint propagate-feature -p B --feature F0 --workspace
stdout: |
crate "B"
feature "F0"
is required by 1 dependency:
d (renamed from D)
Found 1 issue and fixed 0 issues.
Found 1 issue and fixed 0.
- cmd: lint propagate-feature -p C --feature F0 --workspace
stdout: |
crate "C"
feature "F0"
must propagate to:
dd (renamed from D)
Found 1 issue and fixed 0 issues.
Found 1 issue and fixed 0.
- cmd: lint propagate-feature -p D --feature F0 --workspace
stdout: |
Found no issues.
8 changes: 4 additions & 4 deletions tests/ui/lint/propagate-feature/fix_not_propagated.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ cases:
feature "F0"
must propagate to:
B
Found 1 issue and fixed 1 issue.
Found 1 issue and fixed 1.
diff: "diff --git A/Cargo.toml A/Cargo.toml\nindex cf8d3d5..5b371b2 100644\n--- A/Cargo.toml\n+++ A/Cargo.toml\n@@ -10,4 +10,6 @@ B = { version = \"*\", path = \"../B\"}\n \n [features]\n F0 = [\n+\t\"B/F0\"\n+\n ]\n"
- cmd: lint propagate-feature -p A --feature F0 --fix
stdout: |
crate "A"
feature "F0"
must propagate to:
B
Found 1 issue and fixed 1 issue.
Found 1 issue and fixed 1.
diff: "diff --git A/Cargo.toml A/Cargo.toml\nindex cf8d3d5..5b371b2 100644\n--- A/Cargo.toml\n+++ A/Cargo.toml\n@@ -10,4 +10,6 @@ B = { version = \"*\", path = \"../B\"}\n \n [features]\n F0 = [\n+\t\"B/F0\"\n+\n ]\n"
- cmd: lint propagate-feature -p B --feature F0 --fix
stdout: |
Expand All @@ -36,15 +36,15 @@ cases:
feature "F0"
must propagate to:
B
Found 1 issue and fixed 1 issue.
Found 1 issue and fixed 1.
diff: "diff --git A/Cargo.toml A/Cargo.toml\nindex cf8d3d5..5b371b2 100644\n--- A/Cargo.toml\n+++ A/Cargo.toml\n@@ -10,4 +10,6 @@ B = { version = \"*\", path = \"../B\"}\n \n [features]\n F0 = [\n+\t\"B/F0\"\n+\n ]\n"
- cmd: lint propagate-feature -p A --feature F0 --workspace --fix
stdout: |
crate "A"
feature "F0"
must propagate to:
B
Found 1 issue and fixed 1 issue.
Found 1 issue and fixed 1.
diff: "diff --git A/Cargo.toml A/Cargo.toml\nindex cf8d3d5..5b371b2 100644\n--- A/Cargo.toml\n+++ A/Cargo.toml\n@@ -10,4 +10,6 @@ B = { version = \"*\", path = \"../B\"}\n \n [features]\n F0 = [\n+\t\"B/F0\"\n+\n ]\n"
- cmd: lint propagate-feature -p B --feature F0 --workspace --fix
stdout: |
Expand Down
8 changes: 4 additions & 4 deletions tests/ui/lint/propagate-feature/fix_not_propagated_opt.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ cases:
feature "F0"
must propagate to:
B
Found 1 issue and fixed 1 issue.
Found 1 issue and fixed 1.
diff: "diff --git A/Cargo.toml A/Cargo.toml\nindex b30994c..2b554d8 100644\n--- A/Cargo.toml\n+++ A/Cargo.toml\n@@ -10,4 +10,6 @@ B = { version = \"*\", path = \"../B\", optional = true}\n \n [features]\n F0 = [\n+\t\"B?/F0\"\n+\n ]\n"
- cmd: lint propagate-feature -p A --feature F0 --fix
stdout: |
crate "A"
feature "F0"
must propagate to:
B
Found 1 issue and fixed 1 issue.
Found 1 issue and fixed 1.
diff: "diff --git A/Cargo.toml A/Cargo.toml\nindex b30994c..2b554d8 100644\n--- A/Cargo.toml\n+++ A/Cargo.toml\n@@ -10,4 +10,6 @@ B = { version = \"*\", path = \"../B\", optional = true}\n \n [features]\n F0 = [\n+\t\"B?/F0\"\n+\n ]\n"
- cmd: lint propagate-feature -p B --feature F0 --fix
stdout: |
Expand All @@ -37,15 +37,15 @@ cases:
feature "F0"
must propagate to:
B
Found 1 issue and fixed 1 issue.
Found 1 issue and fixed 1.
diff: "diff --git A/Cargo.toml A/Cargo.toml\nindex b30994c..2b554d8 100644\n--- A/Cargo.toml\n+++ A/Cargo.toml\n@@ -10,4 +10,6 @@ B = { version = \"*\", path = \"../B\", optional = true}\n \n [features]\n F0 = [\n+\t\"B?/F0\"\n+\n ]\n"
- cmd: lint propagate-feature -p A --feature F0 --workspace --fix
stdout: |
crate "A"
feature "F0"
must propagate to:
B
Found 1 issue and fixed 1 issue.
Found 1 issue and fixed 1.
diff: "diff --git A/Cargo.toml A/Cargo.toml\nindex b30994c..2b554d8 100644\n--- A/Cargo.toml\n+++ A/Cargo.toml\n@@ -10,4 +10,6 @@ B = { version = \"*\", path = \"../B\", optional = true}\n \n [features]\n F0 = [\n+\t\"B?/F0\"\n+\n ]\n"
- cmd: lint propagate-feature -p B --feature F0 --workspace --fix
stdout: |
Expand Down
Loading

0 comments on commit c4a26d0

Please sign in to comment.