You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 460df03
Browse filesBrowse the repository at this point in the historyBrowse files
selection: list commit message names in the cmd, warn on rejected lines, exact CloudSlow bypass (#7548)
## Changes
Follow-up to [#7524](#7524),
addressing the review comments that came in after it merged:
- **`CloudSlow` bypass needs an exact name.** Only a name that is the
test dir itself, or one of its variants, lifts `CloudSlow`. A path above
the dir (e.g. `cloud: TestAccept/bundle`) or a bare `TestAccept` still
selects the whole subtree, but its `CloudSlow` tests stay skipped under
`-short`, which keeps the PR run inside `cloud-select`'s 2h timeout. To
support this, `selection.Named` now records per dir whether a name was
exact (`Named.Exact`).
- **Rejected lines are logged.** A line with a cloud prefix that is not
read as test names, because some word does not start with `Test` (``aws:
`TestAccept/x` ``, a trailing word, prose), now gets a `WARNING:
ignoring "<line>" ...` in the test log, next to the existing warning for
unmatched names. `ParseCommitMessage` returns these lines, and
`FromCommitMessage` now returns a `CommitSelection` with `Summary()` and
`Warnings()`, shared by the test runner and the cmd.
- **The selection cmd lists named tests.** `go run
./acceptance/internal/selection/cmd [-cloud aws|azure|gcp]` prints,
after the changed tests, the tests the last commit message names for
that run (empty `-cloud` means a local run) as `go test -run` patterns,
plus the warnings. It does this only in git mode, and only when the
message names something or has a warning, so the output for ordinary
commits is unchanged. With paths as arguments it does not read the
message.
- **Test helper reuse.** `TestLastCommitMessage` uses `runSelectionGit`,
which now returns git's output. `commit_test.go` moves to `package
selection_test` to share it.
- `acceptance/README.md` updated.
## Why
Review comments from a code owner on
[#7524](#7524) that auto-merge
landed before they were addressed.
## Tests
- Unit tests: rejected lines (backticks, prose) are returned trimmed,
and empty `aws:` or unknown prefixes are not reported. `Exact` is set
for a dir name and for a variant name, unset for a prefix name and for
bare `TestAccept`, and an exact name wins over a prefix name for the
same dir. `Warnings()` text.
- `acceptance/selftest/selection_exclusions` gets a case that commits a
message with names, covering the cmd's local and `-cloud gcp` output and
both warnings.
- Local, with a commit naming `aws: TestAccept/cmd/fs/cp/file-to-file`,
`cloud: TestAccept/bundle/validate/enum/DMS=true TestAccept/nope` and
``gcp: `TestAccept/cmd/fs/cp/dir-to-dir` ``:
- `DATABRICKS_TEST_SELECT_CHANGED=50 go test ./acceptance -run
'^TestAccept$' -v` ran the two named tests and logged both warnings.
- `go run ./acceptance/internal/selection/cmd` printed
`^bundle$/^validate$/^enum$/^DMS=true$` and
`^cmd$/^fs$/^cp$/^file-to-file$` plus the warnings. With `-cloud gcp` it
printed only the `cloud:` test.
This pull request and its description were written by Isaac.
---------
Co-authored-by: Isaac <no-reply@databricks.com>
-`aws:`, `azure:`, `gcp:` run the test on that cloud only; `cloud:` runs it on every cloud. Prefixes are lowercase and must start the line (surrounding whitespace is ignored). Lines with any other prefix are ignored, and so is a line with a word that does not start with `Test` (so `aws: fix flaky TestAccept retries` is prose, not a request to run the suite).
30
+
-`aws:`, `azure:`, `gcp:` run the test on that cloud only; `cloud:` runs it on every cloud. Prefixes are lowercase and must start the line (surrounding whitespace is ignored). Lines with any other prefix are ignored. A line with a word that does not start with `Test`is not read either (so `aws: fix flaky TestAccept retries` is prose, not a request to run the suite), and is logged as a warning, as is ``aws: `TestAccept/x` ``.
31
31
- Every named test is also selected for the local (testserver) runs, whatever its prefix.
32
32
-`TestAccept/<path>` selects every test dir that is `<path>` or under `<path>/`, with all its variants. `TestAccept/<dir>/KEY=value[/KEY=value...]` selects only the matching variants of test dir `<dir>`, as `go test` names them; each `KEY=value` must be in one of the dir's variants (per its `out.test.toml`). `TestAccept` alone selects every test. A name that matches no acceptance test (including non-acceptance test names) is logged as a warning and otherwise ignored.
33
33
- The named tests are added to the changed-test selection (`DATABRICKS_TEST_SELECT_CHANGED`, used by the PR cloud run and `./task local-select`) and to the windows/macOS PR subset (`TESTS_SELECT_SUBSET_PCT`), without counting toward their limits. Runs with neither selection (Linux PR cell, nightly) do not read the commit message: they run every test.
34
-
- On cloud, a named test still needs `Cloud = true` (and a matching `CloudEnvs`), but it runs even if it is `CloudSlow` (naming any variant of a dir lifts this for the dir).
34
+
- On cloud, a named test still needs `Cloud = true` (and a matching `CloudEnvs`), but it runs even if it is `CloudSlow`when it is named by its own dir or variant name (naming any variant of a dir lifts this for the dir). A path above the dir (or a bare `TestAccept`) does not lift `CloudSlow`, so a whole subtree stays within the PR run's `-short` budget.
35
35
- On pull requests, such a line makes `tools/testmask` select the tests and the cloud run even if the changed files alone would not. The merge queue ignores it.
36
36
- On the merge commit GitHub creates for a PR (`refs/pull/N/merge`), the message of the PR's head commit is used. The parser is in `acceptance/internal/selection/commit.go`.
37
+
- To see what a commit message selects without running the suite: `go run ./acceptance/internal/selection/cmd [-cloud aws|azure|gcp]` prints the named tests and the warnings after the changed ones.
// CommitSelection is what the last commit message selects for one run.
224
+
typeCommitSelectionstruct {
225
+
// Named holds the selected test dirs.
226
+
NamedNamed
227
+
228
+
// Matched lists the names that selected a test, Unmatched the ones that selected none.
229
+
Matched []string
230
+
Unmatched []string
231
+
232
+
// Rejected lists the lines with a cloud prefix that were not read as test names (see
233
+
// ParseCommitMessage).
234
+
Rejected []string
235
+
236
+
// Where is the cloud the selection is for, or "local".
237
+
Wherestring
238
+
}
239
+
240
+
// Summary is the selection on one line, for the test log.
241
+
func (cCommitSelection) Summary() string {
242
+
returnfmt.Sprintf("Selected %d test dirs named in the last commit message (%s): %s", len(c.Named), c.Where, strings.Join(c.Matched, " "))
243
+
}
244
+
245
+
// Warnings returns one line per name that selected nothing and per rejected line, so a
246
+
// request that is not honored is visible in the test log.
247
+
func (cCommitSelection) Warnings() []string {
248
+
varwarnings []string
249
+
for_, name:=rangec.Unmatched {
250
+
warnings=append(warnings, fmt.Sprintf("%q in the last commit message matches no acceptance test", name))
251
+
}
252
+
for_, line:=rangec.Rejected {
253
+
warnings=append(warnings, fmt.Sprintf("ignoring %q in the last commit message: every word after the cloud prefix must be a test name such as TestAccept/<path>", line))
254
+
}
255
+
returnwarnings
256
+
}
257
+
189
258
// FromCommitMessage selects among testDirs the tests the last commit message names for cloud
190
-
// (empty for a local run, see NamesForCloud). root is the acceptance directory. It returns the
191
-
// selection, a one-line summary of the names that matched for the test log, and the names that
0 commit comments