test: use flags instead of env variables for skipping tests #1591
No reviewers
Labels
No labels
FreeBSD
Kind/Breaking
Kind/Bug
Kind/Chore
Kind/DependencyUpdate
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status
Need More Info
Windows
linux-powerpc64le
linux-riscv64
linux-s390x
run-end-to-end-tests
run-forgejo-tests
run-multi-platform-tests
No milestone
No assignees
4 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
forgejo/runner!1591
Loading…
Reference in a new issue
No description provided.
Delete branch "aahlenst/runner:test-feature-flags"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
#1585 introduced the environment variable
TEST_FEATURESfor switching tests related to particular feature on and off. For example, withTEST_FEATURES="", tests that require Docker would be skipped. Unfortunately, that technique has multiple problems. Environment variables might not be passed on to child processes without it being clearly visible. Also, the usage differs by platform. On top of that, informational messages that are only related to testing were printed by the release binary.Instead of the environment variable
TEST_FEATURES, the command line flag-featuresis introduced:That runs all tests that require the presence of Docker and LXC. It is also the default.
If tests that require Docker should be skipped, run:
To exclude all tests that require the presence of a particular feature, run:
At the moment,
-featurescannot be controlled when using make targets. That means thatmake integration-testruns all tests that require Docker or LXC.Supersedes #1588.
f7542086c661c9a0a985WIP: test: use flags instead of env variables for skipping teststo test: use flags instead of env variables for skipping tests@ -25,3 +25,3 @@ctx := context.Background()cmd := createRunnerFileCmd(ctx, &configFile)output, _, _, err := executeCommand(ctx, t, cmd)output, _, _, err := executeCommand(ctx, t, cmd, "--connect")Unrelated change?
Actually not.
executeCommand()explicitly passes arguments to Cobra so that it uses those instead ofos.Args. But Cobra doesn't care if the arguments areniland continues looking atos.Args. But then it complains about the presence of-features.@ -302,3 +302,3 @@run: |run0 -u forgejo --chdir=/home/forgejo/runner \bash --login -c 'make integration-test'bash --login -c 'go test -race -v -timeout 30m ./... -args -features docker'are we skipping lxc now? or did they never run here before? 🤔
@viceice wrote in #1591 (comment):
That's the Podman job. It never ran LXC tests before because LXC wasn't installed and the LXC tests were skipped if
lxc-createwasn't onPATH. They are already run once by each Docker job (twice in total).thanks for confirming 🤗
@Crown0815 The environment variable turned out to be too brittle. There's now a test flag for controlling which features to test. Apologies for causing churn.
@aahlenst, thanks for the update. What is the flag name?
@Crown0815 It's called
-features, but you also need-argsforgoto enable it. Example usage:go test ./... -args -features "-".@aahlenst got it. Thanks a lot 🙏