Skip to content

Commit

Permalink
Counts custom package specific test runners folder as tests
Browse files Browse the repository at this point in the history
  • Loading branch information
chunhtai committed Aug 2, 2023
1 parent 8cae078 commit 34371a8
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -423,13 +423,14 @@ class GithubWebhookSubscription extends SubscriptionHandler {
// for the purposes of testing a change that otherwise needs tests,
// but since they are the driver for tests they don't need test
// coverage.
!filename.endsWith('tool/run_tests.dart') &&
!filename.endsWith('run_tests.sh')) {
needsTests = !_allChangesAreCodeComments(file);
}
// See https://github.com/flutter/flutter/wiki/Plugin-Tests for discussion
// of various plugin test types and locations.
if (filename.endsWith('_test.dart') ||
// Test files in custom package-specific test folders.
filename.contains(RegExp('packages/packages/[^/]+/tool/')) ||
// Native iOS/macOS tests.
filename.contains('RunnerTests/') ||
filename.contains('RunnerUITests/') ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1692,13 +1692,15 @@ void foo() {
),
);
});

test('Packages does not comment if Pigeon native tests', () async {
const int issueNumber = 123;

tester.message = generateGithubWebhookMessage(
action: 'opened',
number: issueNumber,
slug: Config.packagesSlug,
baseRef: Config.defaultBranch(Config.packagesSlug),
);
when(pullRequestsService.listFiles(Config.packagesSlug, issueNumber)).thenAnswer(
(_) => Stream<PullRequestFile>.fromIterable(<PullRequestFile>[
Expand All @@ -1719,6 +1721,37 @@ void foo() {
);
});

test('Packages does not comment if editing test files in tool/', () async {
const int issueNumber = 123;

tester.message = generateGithubWebhookMessage(
action: 'opened',
number: issueNumber,
slug: Config.packagesSlug,
baseRef: Config.defaultBranch(Config.packagesSlug),
);
when(pullRequestsService.listFiles(Config.packagesSlug, issueNumber)).thenAnswer(
(_) => Stream<PullRequestFile>.fromIterable(<PullRequestFile>[
PullRequestFile()
..filename = 'packages/packages/go_router/tool/test_fixes/go_router.dart'
..additionsCount = 10,
PullRequestFile()
..filename = 'packages/packages/go_router/lib/fix_data.yaml'
..additionsCount = 10,
]),
);

await tester.post(webhook);

verifyNever(
issuesService.createComment(
Config.packagesSlug,
issueNumber,
argThat(contains(config.missingTestsPullRequestMessageValue)),
),
);
});

test('Packages comments and labels if no tests', () async {
const int issueNumber = 123;

Expand Down

0 comments on commit 34371a8

Please sign in to comment.