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

Process --run and --skip in the envtool itself #3969

Closed
AlekSi opened this issue Jan 12, 2024 · 4 comments · Fixed by #3999 or #4101
Closed

Process --run and --skip in the envtool itself #3969

AlekSi opened this issue Jan 12, 2024 · 4 comments · Fixed by #3999 or #4101
Assignees
Labels
code/chore Code maintenance improvements
Milestone

Comments

@AlekSi
Copy link
Member

AlekSi commented Jan 12, 2024

What should be done?

Currently, when envtool tests run is invoked with --run and/or --skip flags, we just pass those values to go test's -run and -skip, skip tests listing and sharding. That makes the output less useful: there is no known number of total tests, the progress indicator is worse, etc.

Let's get a list of tests as usual, then apply --run and --skip's regular expressions ourselves, then shard the resulting list.

Where?

// testsRun runs tests specified by the shard index and total or by the run regex
// using `go test` with given extra args.
func testsRun(ctx context.Context, index, total uint, run, skip string, args []string, logger *zap.SugaredLogger) error {
logger.Debugf("testsRun: index=%d, total=%d, run=%q, args=%q", index, total, run, args)
var totalTest int
if run == "" {
if index == 0 || total == 0 {
return fmt.Errorf("--shard-index and --shard-total must be specified when --run is not")
}
all, err := listTestFuncs("")
if err != nil {
return lazyerrors.Error(err)
}
shard, err := shardTestFuncs(index, total, all)
if err != nil {
return lazyerrors.Error(err)
}
run = "^("
for i, t := range shard {
run += t
if i != len(shard)-1 {
run += "|"
}
}
totalTest = len(shard)
run += ")$"
}
if skip != "" {
totalTest = 0
args = append(args, "-run="+run, "-skip="+skip)
} else {
args = append(args, "-run="+run)
}
return runGoTest(ctx, args, totalTest, true, logger)
}

Definition of Done

  • envtool code updated;
  • envtool's unit tests added/updated;
  • spot refactorings done.
@AlekSi AlekSi added code/chore Code maintenance improvements not ready Issues that are not ready to be worked on; PRs that should skip CI labels Jan 12, 2024
@AlekSi AlekSi assigned ferretdb-bot and unassigned ferretdb-bot Jan 12, 2024
@AlekSi AlekSi added good first issue Good issues for new external contributors and removed not ready Issues that are not ready to be worked on; PRs that should skip CI labels Jan 12, 2024
@korzio korzio mentioned this issue Jan 22, 2024
9 tasks
@fadyat
Copy link
Contributor

fadyat commented Jan 22, 2024

@korzio Hi, I see we have a conflict here 😢
I've done everything, you can chill

@korzio
Copy link

korzio commented Jan 22, 2024

@fadyat ah I see thx. Well, next time for me than 😢

@AlekSi
Copy link
Member Author

AlekSi commented Jan 23, 2024

That's exactly why we ask contributors to leave a comment on the issue before starting working on it (https://github.com/FerretDB/FerretDB/blob/main/CONTRIBUTING.md#finding-something-to-work-on)

@AlekSi AlekSi self-assigned this Jan 23, 2024
@AlekSi AlekSi added community Issues and PRs assigned to community members and removed good first issue Good issues for new external contributors labels Jan 24, 2024
@AlekSi AlekSi reopened this Feb 8, 2024
@AlekSi AlekSi removed their assignment Feb 8, 2024
@AlekSi AlekSi removed the community Issues and PRs assigned to community members label Feb 8, 2024
@noisersup noisersup mentioned this issue Feb 9, 2024
9 tasks
@AlekSi AlekSi assigned henvic and unassigned noisersup Feb 15, 2024
@henvic henvic modified the milestone: Next Feb 23, 2024
@AlekSi
Copy link
Member Author

AlekSi commented Feb 27, 2024

#4101 (review) Anyway, not important right now.

@AlekSi AlekSi reopened this Feb 27, 2024
@AlekSi AlekSi closed this as completed Feb 27, 2024
@AlekSi AlekSi added this to the Next milestone Mar 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment