Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

command/pr, command/list: List individual affected tests #38

Open
YakDriver opened this issue Jul 17, 2020 · 0 comments
Open

command/pr, command/list: List individual affected tests #38

YakDriver opened this issue Jul 17, 2020 · 0 comments

Comments

@YakDriver
Copy link

YakDriver commented Jul 17, 2020

Proposal

Add an option to automatically discover individual tests (rather than all tests in affected files) affected by a PR. (NOTE: This would only be practical for changes to _test.go files.)

Description

For broad PRs and PRs targetting files with many tests, the resulting number of tests to be run grows exponentially. It would be super-handy if an option allowed looking deeper at the actual changes to find specific individual tests affected rather than test families.

Current behavior (82 tests to be run)

% tctest list 194782
Discovering tests for pr #194782 (https://github.com/terraform-providers/terraform-provider-aws/pull/194782)...
    TestAccAWSInstance

Running make testacc TESTARGS='-run=TestAccAWSInstance' results in 82 tests run.

Proposed behavior (1 test to be run)

Perhaps use -i for individual test discovery.

% tctest list -i 194782
Discovering tests for pr #194782 (https://github.com/terraform-providers/terraform-provider-aws/pull/194782)...
    TestAccAWSInstance_RootBlockDevice_KmsKeyArn

Running make testacc TESTARGS='-run=TestAccAWSInstance_RootBlockDevice_KmsKeyArn' results in 1 test run.

Design thoughts

Basic process:

  1. Go through each changed line in the PR
  2. Given a changed line in a _test.go file:
    • Scan back until func declaration
    • If func is TestAcc, add to the list of individual tests
    • If func is anything else (e.g., testAcc...(), find...()), initially, revert to current behavior and add test family to list (this could be analyzed with some sort of magic to identify individual tests but that may not be feasible)
  3. Given a changed line in a file other than _test.go file, revert to current behavior and add corresponding test family(ies) to list
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant