Skip to content
This repository was archived by the owner on Nov 7, 2024. It is now read-only.

Commit de577a6

Browse files
committed
Merge branch 'adding-tests' into main
2 parents e19363f + 1ca059e commit de577a6

File tree

12 files changed

+144
-65
lines changed

12 files changed

+144
-65
lines changed

.github/workflows/dart.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
run: dart analyze --fatal-infos
3333

3434
- name: Run tests (& collect coverage)
35-
run: dart run coverage:test_with_coverage
35+
run: dart run coverage:test_with_coverage --function-coverage --branch-coverage
3636

3737
- name: Upload coverage report
3838
uses: codecov/codecov-action@v3

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# https://dart.dev/guides/libraries/private-files
22
# Created by `dart pub`
33
.dart_tool/
4+
dist/
45

56
# vscode settings
67
.vscode/

.pre-commit-config.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ repos:
1010
- id: check-added-large-files
1111
- id: mixed-line-ending
1212
args: [--fix=lf]
13-
- repo: https://github.com/fluttercommunity/import_sorter
14-
rev: "f350497a11b1285c695595049e95a420068e7a9f"
15-
hooks:
16-
- id: dart-import-sorter
13+
# - repo: https://github.com/fluttercommunity/import_sorter
14+
# rev: "f350497a11b1285c695595049e95a420068e7a9f"
15+
# hooks:
16+
# - id: dart-import-sorter

bin/cpp_linter_dart.dart

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ Future<int> main(List<String> arguments) async {
6868
files = listSourceFiles(extensions, ignored, notIgnored);
6969
}
7070
endLogGroup();
71+
7172
if (files.isEmpty) {
7273
return setExitCode(0);
7374
}
@@ -83,20 +84,21 @@ Future<int> main(List<String> arguments) async {
8384
);
8485

8586
startLogGroup('Posting comment(s)');
86-
var threadCommentsAllowed = true;
87-
if (githubEventPath.isNotEmpty) {
88-
var repoInfo = ghEventPayload['repository'] as Map<String, Object>?;
89-
if (repoInfo != null && repoInfo.keys.contains('private')) {
90-
threadCommentsAllowed = repoInfo['private'] as bool == false;
91-
}
92-
}
9387
final commentBody = makeComment(formatAdvice, tidyNotes, linesChangedOnly);
9488
final commentPreamble = '<!-- cpp linter action -->\n# Cpp-Linter Report ';
9589
final commentPs = '\n\nHave any feedback or feature suggestions? [Share it '
9690
'here.](https://github.com/cpp-linter/cpp-linter-action/issues)';
9791
final lgtm = '$commentPreamble:heavy_check_mark:\nNo problems need attention.'
9892
'$commentPs';
9993
final fullComment = '$commentPreamble$commentBody$commentPs';
94+
95+
var threadCommentsAllowed = true;
96+
if (githubEventPath.isNotEmpty) {
97+
var repoInfo = ghEventPayload['repository'] as Map<String, Object>?;
98+
if (repoInfo != null && repoInfo.keys.contains('private')) {
99+
threadCommentsAllowed = repoInfo['private'] as bool == false;
100+
}
101+
}
100102
if (args['thread-comments'] != 'false' && threadCommentsAllowed) {
101103
bool updateOnly = args['thread-comments'] == 'update';
102104
if (args['lgtm'] && commentBody.isEmpty) {
@@ -111,16 +113,14 @@ Future<int> main(List<String> arguments) async {
111113
mode: FileMode.append,
112114
);
113115
}
114-
setExitCode(
115-
makeAnnotations(
116-
formatAdvice,
117-
tidyNotes,
118-
args['file-annotations'],
119-
args['style'],
120-
linesChangedOnly,
121-
),
116+
var exitCode = makeAnnotations(
117+
formatAdvice,
118+
tidyNotes,
119+
args['file-annotations'],
120+
args['style'],
121+
linesChangedOnly,
122122
);
123123
endLogGroup();
124124

125-
return setExitCode(0);
125+
return setExitCode(exitCode);
126126
}

lib/clang_format.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ class FormatFix {
8787
}
8888

8989
/// NOTE: This is currently broken and needs much improvement!
90+
// coverage:ignore-start
9091
List<String> getSuggestions({bool lineChangesOnly = false}) {
9192
List<int>? linesChanged;
9293
if (lineChangesOnly) {
@@ -136,7 +137,7 @@ class FormatFix {
136137
);
137138
}
138139
return result;
139-
}
140+
} // coverage:ignore-end
140141
}
141142

142143
/// Parse the [xmlOut] from running clang-format on a single [file].

lib/clang_tidy.dart

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import 'package:yaml/yaml.dart';
1010
import 'common.dart';
1111
import 'logger.dart';
1212

13+
// coverage:ignore-start
1314
class TidyReplacement {
1415
int rmLength;
1516
int line;
@@ -158,6 +159,7 @@ TidyAdvice parseYmlAdvice(FileObj file, {bool lineChangesOnly = false}) {
158159
}
159160
return yamlAdvice;
160161
}
162+
// coverage:ignore-end
161163

162164
/// A class to represent clang-tidy notifications (parsed from the stdout of a
163165
/// dry run).
@@ -204,6 +206,7 @@ class TidyNotification {
204206

205207
List<TidyNotification> parseTidyOutput(FileObj file, String output) {
206208
var notifications = <TidyNotification>[];
209+
if (output.isEmpty) return notifications;
207210
for (final line in output.split('\n')) {
208211
var match = RegExp(r"^(.+):(\d+):(\d+):\s(\w+):(.*)\[([a-zA-Z\d\-\.]+)\]$")
209212
.matchAsPrefix(line);
@@ -226,8 +229,9 @@ List<TidyNotification> parseTidyOutput(FileObj file, String output) {
226229
),
227230
);
228231
} else {
229-
assert(notifications.isNotEmpty);
230-
notifications.last.srcLines.add(line);
232+
if (notifications.isNotEmpty) {
233+
notifications.last.srcLines.add(line);
234+
}
231235
}
232236
}
233237
return notifications;
@@ -253,7 +257,11 @@ Future<List<TidyNotification>> runClangTidy(
253257
if (checks.isNotEmpty) args.add("--checks='$checks'");
254258
if (database.isNotEmpty) {
255259
args.addAll(
256-
['-p', p.isRelative(database) ? p.absolute(database) : database]);
260+
[
261+
'-p',
262+
p.normalize(p.isRelative(database) ? p.absolute(database) : database),
263+
],
264+
);
257265
}
258266
var ranges = file.linesAdded;
259267
if (ranges.isNotEmpty) {
@@ -265,7 +273,7 @@ Future<List<TidyNotification>> runClangTidy(
265273
}
266274
if (extraArgs != null && extraArgs.isNotEmpty) {
267275
for (var arg in extraArgs) {
268-
args.add('--extra-args=$arg');
276+
args.add("--extra-arg='$arg'");
269277
}
270278
}
271279
args.add(file.name.replaceAll('\\', '/'));

lib/common.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ String makeClangToolExeVersion(String tool, String version) {
111111
return '$tool-$version$suffix';
112112
}
113113
// treat version as an explicit path
114-
var versionPath = p.absolute(version);
114+
var versionPath = p.absolute(p.normalize(version));
115115
var possibles = [
116116
File('$versionPath/bin/$tool$suffix'),
117117
File('$versionPath/$tool$suffix'),

lib/git.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Future<String> getSha({int parent = 1}) async {
1616
return subprocessRun('git', args: ["log", "-$parent", "--format=%H"]);
1717
}
1818

19+
// coverage:ignore-start
1920
/// Get the diff for the currently staged files or the current commit if no
2021
/// changes were made.
2122
Future<String> getDiff(bool debug) async {
@@ -41,7 +42,7 @@ Future<String> getDiff(bool debug) async {
4142
);
4243
}
4344
return diff;
44-
}
45+
} // coverage:ignore-end
4546

4647
/// Parses a file's name from the diff chunk's front matter. Binary files are
4748
/// ignored (returns `null`).

lib/run.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ List<FileObj> listSourceFiles(
123123
}
124124

125125
var relPath = p.relative(path.path);
126-
var file = FileObj(relPath);
126+
var file = FileObj(relPath.replaceAll(p.separator, '/'));
127127
var ignore = isFileInSet(file, ignored);
128128
if (ignore && isFileInSet(file, notIgnored)) {
129129
ignore = true;

pubspec.lock

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@ packages:
55
dependency: transitive
66
description:
77
name: _fe_analyzer_shared
8-
sha256: eb376e9acf6938204f90eb3b1f00b578640d3188b4c8a8ec054f9f479af8d051
8+
sha256: "36a321c3d2cbe01cbcb3540a87b8843846e0206df3e691fa7b23e19e78de6d49"
99
url: "https://pub.dev"
1010
source: hosted
11-
version: "64.0.0"
11+
version: "65.0.0"
1212
analyzer:
1313
dependency: transitive
1414
description:
1515
name: analyzer
16-
sha256: "69f54f967773f6c26c7dcb13e93d7ccee8b17a641689da39e878d5cf13b06893"
16+
sha256: dfe03b90ec022450e22513b5e5ca1f01c0c01de9c3fba2f7fd233cb57a6b9a07
1717
url: "https://pub.dev"
1818
source: hosted
19-
version: "6.2.0"
19+
version: "6.3.0"
2020
args:
2121
dependency: "direct main"
2222
description:
@@ -41,14 +41,6 @@ packages:
4141
url: "https://pub.dev"
4242
source: hosted
4343
version: "2.1.1"
44-
charcode:
45-
dependency: transitive
46-
description:
47-
name: charcode
48-
sha256: fb98c0f6d12c920a02ee2d998da788bca066ca5f148492b7085ee23372b12306
49-
url: "https://pub.dev"
50-
source: hosted
51-
version: "1.3.1"
5244
collection:
5345
dependency: transitive
5446
description:
@@ -69,10 +61,10 @@ packages:
6961
dependency: "direct dev"
7062
description:
7163
name: coverage
72-
sha256: "2fb815080e44a09b85e0f2ca8a820b15053982b2e714b59267719e8a9ff17097"
64+
sha256: ac86d3abab0f165e4b8f561280ff4e066bceaac83c424dd19f1ae2c2fcd12ca9
7365
url: "https://pub.dev"
7466
source: hosted
75-
version: "1.6.3"
67+
version: "1.7.1"
7668
crypto:
7769
dependency: transitive
7870
description:
@@ -109,10 +101,10 @@ packages:
109101
dependency: "direct main"
110102
description:
111103
name: http
112-
sha256: "759d1a329847dd0f39226c688d3e06a6b8679668e350e2891a6474f8b4bb8525"
104+
sha256: d4872660c46d929f6b8a9ef4e7a7eff7e49bbf0c4ec3f385ee32df5119175139
113105
url: "https://pub.dev"
114106
source: hosted
115-
version: "1.1.0"
107+
version: "1.1.2"
116108
http_multi_server:
117109
dependency: transitive
118110
description:
@@ -189,10 +181,10 @@ packages:
189181
dependency: transitive
190182
description:
191183
name: meta
192-
sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3"
184+
sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04
193185
url: "https://pub.dev"
194186
source: hosted
195-
version: "1.9.1"
187+
version: "1.11.0"
196188
mime:
197189
dependency: transitive
198190
description:
@@ -221,18 +213,18 @@ packages:
221213
dependency: "direct main"
222214
description:
223215
name: path
224-
sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917"
216+
sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af"
225217
url: "https://pub.dev"
226218
source: hosted
227-
version: "1.8.3"
219+
version: "1.9.0"
228220
petitparser:
229221
dependency: transitive
230222
description:
231223
name: petitparser
232-
sha256: eeb2d1428ee7f4170e2bd498827296a18d4e7fc462b71727d111c0ac7707cfa6
224+
sha256: c15605cd28af66339f8eb6fbe0e541bfe2d1b72d5825efc6598f3e0a31b9ad27
233225
url: "https://pub.dev"
234226
source: hosted
235-
version: "6.0.1"
227+
version: "6.0.2"
236228
pool:
237229
dependency: transitive
238230
description:
@@ -245,10 +237,10 @@ packages:
245237
dependency: "direct main"
246238
description:
247239
name: process_run
248-
sha256: ceacfac6d566a36c895d64edc7e429efb2d6b6303b5e28d5c13bc59fe6e8974e
240+
sha256: "94413ec6bbd05dfe7c3002c379724f75f185ff7f0a5dfb1851a42473d84c956e"
249241
url: "https://pub.dev"
250242
source: hosted
251-
version: "0.13.1"
243+
version: "0.13.3"
252244
pub_semver:
253245
dependency: transitive
254246
description:
@@ -357,10 +349,10 @@ packages:
357349
dependency: "direct dev"
358350
description:
359351
name: test
360-
sha256: "9b0dd8e36af4a5b1569029949d50a52cb2a2a2fdaa20cebb96e6603b9ae241f9"
352+
sha256: a1f7595805820fcc05e5c52e3a231aedd0b72972cb333e8c738a8b1239448b6f
361353
url: "https://pub.dev"
362354
source: hosted
363-
version: "1.24.6"
355+
version: "1.24.9"
364356
test_api:
365357
dependency: transitive
366358
description:
@@ -373,10 +365,10 @@ packages:
373365
dependency: transitive
374366
description:
375367
name: test_core
376-
sha256: "4bef837e56375537055fdbbbf6dd458b1859881f4c7e6da936158f77d61ab265"
368+
sha256: a757b14fc47507060a162cc2530d9a4a2f92f5100a952c7443b5cad5ef5b106a
377369
url: "https://pub.dev"
378370
source: hosted
379-
version: "0.5.6"
371+
version: "0.5.9"
380372
tint:
381373
dependency: transitive
382374
description:
@@ -397,10 +389,10 @@ packages:
397389
dependency: transitive
398390
description:
399391
name: vm_service
400-
sha256: c538be99af830f478718b51630ec1b6bee5e74e52c8a802d328d9e71d35d2583
392+
sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957
401393
url: "https://pub.dev"
402394
source: hosted
403-
version: "11.10.0"
395+
version: "13.0.0"
404396
watcher:
405397
dependency: transitive
406398
description:
@@ -409,6 +401,14 @@ packages:
409401
url: "https://pub.dev"
410402
source: hosted
411403
version: "1.1.0"
404+
web:
405+
dependency: transitive
406+
description:
407+
name: web
408+
sha256: edc8a9573dd8c5a83a183dae1af2b6fd4131377404706ca4e5420474784906fa
409+
url: "https://pub.dev"
410+
source: hosted
411+
version: "0.4.0"
412412
web_socket_channel:
413413
dependency: transitive
414414
description:
@@ -421,18 +421,18 @@ packages:
421421
dependency: transitive
422422
description:
423423
name: webkit_inspection_protocol
424-
sha256: "67d3a8b6c79e1987d19d848b0892e582dbb0c66c57cc1fef58a177dd2aa2823d"
424+
sha256: "87d3f2333bb240704cd3f1c6b5b7acd8a10e7f0bc28c28dcf14e782014f4a572"
425425
url: "https://pub.dev"
426426
source: hosted
427-
version: "1.2.0"
427+
version: "1.2.1"
428428
xml:
429429
dependency: "direct main"
430430
description:
431431
name: xml
432-
sha256: af5e77e9b83f2f4adc5d3f0a4ece1c7f45a2467b695c2540381bac793e34e556
432+
sha256: b015a8ad1c488f66851d762d3090a21c600e479dc75e68328c52774040cf9226
433433
url: "https://pub.dev"
434434
source: hosted
435-
version: "6.4.2"
435+
version: "6.5.0"
436436
yaml:
437437
dependency: "direct main"
438438
description:
@@ -442,4 +442,4 @@ packages:
442442
source: hosted
443443
version: "3.1.2"
444444
sdks:
445-
dart: ">=3.0.6 <4.0.0"
445+
dart: ">=3.2.0 <4.0.0"

0 commit comments

Comments
 (0)