Skip to content

Commit 5691ec7

Browse files
committed
use test profiles
- organize config files into .config/ folder only those that do not require repo root location - minor test improvements
1 parent d18d282 commit 5691ec7

File tree

12 files changed

+156
-74
lines changed

12 files changed

+156
-74
lines changed
File renamed without changes.
File renamed without changes.

.config/nextest.toml

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# required minimum nextest version
2+
nextest-version = "0.9.77"
3+
4+
[profile.default]
5+
# A profile to run most tests, except tests that run longer than 10 seconds
6+
default-filter = "not test(#*rate_limit_secondary) - test(#git::test::with_*)"
7+
8+
# This will flag any test that runs longer than 10 seconds. Useful when writing new tests.
9+
slow-timeout = "10s"
10+
11+
[profile.ci]
12+
# A profile to run only tests that use clang-tidy and/or clang-format
13+
# NOTE: This profile is intended to keep CI runtime low. Locally, use default or all profiles
14+
15+
# This is all tests in tests/ folder + unit test for --extra-args.
16+
default-filter = "kind(test) + test(#*use_extra_args)"
17+
18+
# show wich tests were skipped
19+
status-level = "skip"
20+
21+
# show log output from each test
22+
success-output = "final"
23+
failure-output = "immediate-final"
24+
25+
[profile.all]
26+
# A profile to run all tests (including tests that run longer than 10 seconds)
27+
default-filter = "all()"
28+
29+
# Revert slow-timeout to nextest default value.
30+
# Otherwise, default profile value (10s) is inherited.
31+
slow-timeout = "60s"

.github/workflows/bump-n-release.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ jobs:
5454
uses: orhun/git-cliff-action@v4
5555
id: git-cliff
5656
with:
57-
config: cliff.toml
57+
config: .config/cliff.toml
5858
args: --unreleased
5959
env:
6060
OUTPUT: ${{ runner.temp }}/changes.md

.github/workflows/bump_version.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,16 @@ def main():
120120
subprocess.run(["napi", "version"], cwd="node-binding", check=True)
121121
print("Updated version in node-binding/**package.json")
122122

123-
subprocess.run(["git", "cliff", "--tag", Updater.new_version], check=True)
123+
subprocess.run(
124+
[
125+
"git-cliff",
126+
"--config",
127+
".config/cliff.toml",
128+
"--tag",
129+
Updater.new_version,
130+
],
131+
check=True,
132+
)
124133
print("Updated CHANGELOG.md")
125134

126135
subprocess.run(["git", "add", "--all"], check=True)

.github/workflows/run-dev-tests.yml

+12-12
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ jobs:
8888
if: runner.os == 'Linux'
8989
env:
9090
CLANG_VERSION: '7'
91-
run: just test
91+
run: just test ci
9292

9393
- name: Install clang v8
9494
if: runner.os == 'Linux'
@@ -100,7 +100,7 @@ jobs:
100100
if: runner.os == 'Linux'
101101
env:
102102
CLANG_VERSION: '8'
103-
run: just test
103+
run: just test ci
104104

105105
- name: Install clang v9
106106
uses: cpp-linter/cpp_linter_rs/install-clang-action@main
@@ -110,7 +110,7 @@ jobs:
110110
- name: Collect Coverage for clang v9
111111
env:
112112
CLANG_VERSION: '9'
113-
run: just test
113+
run: just test ci
114114

115115
- name: Install clang v10
116116
uses: cpp-linter/cpp_linter_rs/install-clang-action@main
@@ -120,7 +120,7 @@ jobs:
120120
- name: Collect Coverage for clang v10
121121
env:
122122
CLANG_VERSION: '10'
123-
run: just test
123+
run: just test ci
124124

125125
- name: Install clang 11
126126
uses: cpp-linter/cpp_linter_rs/install-clang-action@main
@@ -130,7 +130,7 @@ jobs:
130130
- name: Collect Coverage for clang v11
131131
env:
132132
CLANG_VERSION: '11'
133-
run: just test
133+
run: just test ci
134134

135135
- name: Install clang 12
136136
uses: cpp-linter/cpp_linter_rs/install-clang-action@main
@@ -140,7 +140,7 @@ jobs:
140140
- name: Collect Coverage for clang v12
141141
env:
142142
CLANG_VERSION: '12'
143-
run: just test
143+
run: just test ci
144144

145145
- name: Install clang 13
146146
uses: cpp-linter/cpp_linter_rs/install-clang-action@main
@@ -150,7 +150,7 @@ jobs:
150150
- name: Collect Coverage for clang v13
151151
env:
152152
CLANG_VERSION: '13'
153-
run: just test
153+
run: just test ci
154154

155155
- name: Install clang 14
156156
uses: cpp-linter/cpp_linter_rs/install-clang-action@main
@@ -160,7 +160,7 @@ jobs:
160160
- name: Collect Coverage for clang v14
161161
env:
162162
CLANG_VERSION: '14'
163-
run: just test
163+
run: just test ci
164164

165165
- name: Install clang 15
166166
uses: cpp-linter/cpp_linter_rs/install-clang-action@main
@@ -170,7 +170,7 @@ jobs:
170170
- name: Collect Coverage for clang v15
171171
env:
172172
CLANG_VERSION: '15'
173-
run: just test
173+
run: just test ci
174174

175175
- name: Install clang 16
176176
uses: cpp-linter/cpp_linter_rs/install-clang-action@main
@@ -180,7 +180,7 @@ jobs:
180180
- name: Collect Coverage for clang v16
181181
env:
182182
CLANG_VERSION: '16'
183-
run: just test
183+
run: just test ci
184184

185185
- name: Install clang 17
186186
uses: cpp-linter/cpp_linter_rs/install-clang-action@main
@@ -190,7 +190,7 @@ jobs:
190190
- name: Collect Coverage for clang v17
191191
env:
192192
CLANG_VERSION: '17'
193-
run: just test
193+
run: just test ci
194194

195195
- name: Install clang 18
196196
uses: cpp-linter/cpp_linter_rs/install-clang-action@main
@@ -200,7 +200,7 @@ jobs:
200200
- name: Collect Coverage for clang v18
201201
env:
202202
CLANG_VERSION: '18'
203-
run: just test --run-ignored=all
203+
run: just test all
204204

205205
- name: Generate Coverage HTML report
206206
run: just pretty-cov

cpp-linter/src/clang_tools/clang_format.rs

+15-12
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,15 @@ pub struct Replacement {
5757
///
5858
/// This value is not provided by the XML output, but we calculate it after
5959
/// deserialization.
60-
pub line: Option<usize>,
60+
#[serde(default)]
61+
pub line: usize,
6162

6263
/// The column number on the line described by the [`Replacement::offset`].
6364
///
6465
/// This value is not provided by the XML output, but we calculate it after
6566
/// deserialization.
66-
pub cols: Option<usize>,
67+
#[serde(default)]
68+
pub cols: usize,
6769
}
6870

6971
impl Clone for Replacement {
@@ -188,11 +190,12 @@ pub fn run_clang_format(
188190
});
189191
format_advice.patched = patched;
190192
if !format_advice.replacements.is_empty() {
193+
// get line and column numbers from format_advice.offset
191194
let mut filtered_replacements = Vec::new();
192195
for replacement in &mut format_advice.replacements {
193196
let (line_number, columns) = get_line_cols_from_offset(&file.name, replacement.offset);
194-
replacement.line = Some(line_number);
195-
replacement.cols = Some(columns);
197+
replacement.line = line_number;
198+
replacement.cols = columns;
196199
for range in &ranges {
197200
if range.contains(&line_number.try_into().unwrap_or(0)) {
198201
filtered_replacements.push(replacement.clone());
@@ -233,29 +236,29 @@ mod tests {
233236
offset: 113,
234237
length: 5,
235238
value: Some(String::from("\n ")),
236-
line: None,
237-
cols: None,
239+
line: 0,
240+
cols: 0,
238241
},
239242
Replacement {
240243
offset: 147,
241244
length: 0,
242245
value: Some(String::from(" ")),
243-
line: None,
244-
cols: None,
246+
line: 0,
247+
cols: 0,
245248
},
246249
Replacement {
247250
offset: 161,
248251
length: 0,
249252
value: None,
250-
line: None,
251-
cols: None,
253+
line: 0,
254+
cols: 0,
252255
},
253256
Replacement {
254257
offset: 165,
255258
length: 19,
256259
value: Some(String::from("\n\n")),
257-
line: None,
258-
cols: None,
260+
line: 0,
261+
cols: 0,
259262
},
260263
],
261264
patched: None,

cpp-linter/src/git.rs

-3
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,6 @@ mod test {
415415
}
416416

417417
#[tokio::test]
418-
#[ignore]
419418
async fn with_no_changed_sources() {
420419
// commit with no modified C/C++ sources
421420
let sha = "0c236809891000b16952576dc34de082d7a40bf3";
@@ -430,7 +429,6 @@ mod test {
430429
}
431430

432431
#[tokio::test]
433-
#[ignore]
434432
async fn with_changed_sources() {
435433
// commit with modified C/C++ sources
436434
let sha = "950ff0b690e1903797c303c5fc8d9f3b52f1d3c5";
@@ -450,7 +448,6 @@ mod test {
450448
}
451449

452450
#[tokio::test]
453-
#[ignore]
454451
async fn with_staged_changed_sources() {
455452
// commit with no modified C/C++ sources
456453
let sha = "0c236809891000b16952576dc34de082d7a40bf3";

0 commit comments

Comments
 (0)