-
Notifications
You must be signed in to change notification settings - Fork 95
refactor(Makefile): Consolidate go test commands in check_gotest #556
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
base: master
Are you sure you want to change the base?
Conversation
- Replaces 8 separate 'go test' invocations with a single, consolidated 'go test ./...' command. - Takes the union of all flags (-race, -timeout 20m, etc.) and environment variables to create a single, unified test run. - Simplifies the coverage processing logic by removing the loop and merge step, as only one 'coverage.txt' file is now generated. - This makes the 'check_gotest' target significantly cleaner and easier to maintain. Signed-off-by: Dawei Huang <daweihuang@microsoft.com>
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR refactors the check_gotest target in the Makefile to consolidate multiple separate go test invocations into a single command, simplifying the test execution and coverage processing logic.
- Replaces 8 individual
go testcommands (one per package) with a singlego test ./...command - Consolidates test flags (-race, -timeout, -covermode, etc.) into one unified test execution
- Simplifies coverage processing by eliminating the merge loop for multiple coverage files
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Makefile
Outdated
| sudo CGO_LDFLAGS="$(CGO_LDFLAGS)" CGO_CXXFLAGS="$(CGO_CXXFLAGS)" $(TESTENV) \ | ||
| $(GO) test -race -v -mod=vendor -timeout 20m \ | ||
| -covermode=atomic -coverprofile=coverage.txt -coverpkg=./... \ | ||
| $(BLD_FLAGS) \ | ||
| ./... |
Copilot
AI
Dec 17, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The consolidation removes the conditional execution of dialout tests based on ENABLE_DIALOUT_VALUE. The original code only ran dialout tests when ENABLE_DIALOUT_VALUE != 0, but the new consolidated command runs all tests unconditionally. This means dialout tests will now run even when dialout is disabled (ENABLE_DIALOUT=n), which may cause test failures or incorrect behavior when the dialout feature is not enabled.
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Adds the '//go:build !test' build constraint to the pyang client generator template (main.j2). This prevents the flag definitions in the generated 'main' packages from being included in test builds, which resolves the 'flag redefined' panic when running 'go test ./...'. This change unblocks the consolidation of the test commands in the Makefile. Signed-off-by: Dawei Huang <daweihuang@microsoft.com>
This commit refactors the main test target ('check_gotest') to be
more scalable and robust, enabled by a fix to the code generator.
- **fix(pyang):** Adds a '//go:build !test' build constraint to the
pyang client generator template (main.j2). This prevents flag
definition conflicts when testing, unblocking test consolidation.
- **refactor(Makefile):** Replaces the 8 separate 'go test' commands
in 'check_gotest' with a single 'go test ./...' command. It also
simplifies the coverage processing logic to handle the single
coverage profile generated by the unified test run.
Signed-off-by: Dawei Huang <daweihuang@microsoft.com>
ed7965c to
54a20ee
Compare
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
- Replaces the hardcoded 'go test ./...' with a dynamically generated list of packages. - Excludes known 'main' packages (executables like generated gNOI clients, gnmi_server, telemetry, etc.) that cause 'flag redefined' panics when tested together in a single 'go test' invocation. - This ensures test consolidation is viable by testing only library packages together, while respecting the project's architecture. Signed-off-by: Dawei Huang <daweihuang@microsoft.com>
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
- Wraps the 'go list | grep' pipeline in a '' function. - This fixes a syntax error where the command string itself was being passed as an argument to 'go test', instead of the command's output. - The command now correctly generates a list of packages and passes them to the test runner, enabling the consolidated test approach. Signed-off-by: Dawei Huang <daweihuang@microsoft.com>
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
The INTEGRATION_PKGS variable calculation was failing because the $(space) variable wasn't defined, causing $(subst $(space),|,$(PURE_PKGS)) to not work properly. This resulted in an empty package list being passed to go test. Added the standard GNU make space variable definition to fix the package filtering and ensure all 15 integration packages are properly included in check_gotest. Signed-off-by: Dawei Huang <daweihuang@microsoft.com>
Replace the complex package filtering approach with an explicit list of integration packages based on the master branch's check_gotest target. This approach is cleaner because: - Single source of truth (no duplication with pure.mk) - Explicit and maintainable package list - Based on proven implementation from master - Eliminates complex shell filtering and space variable issues Integration packages: telemetry, sonic_db_config, gnmi_server, dialout_client, sonic_data_client, sonic_service_client, transl_utils, gnoi_client/system. Signed-off-by: Dawei Huang <daweihuang@microsoft.com>
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Add a new `check_junit` target that demonstrates individual test results in Azure DevOps pipeline UI using JUnit XML format. Changes: - New `check_junit` Makefile target that uses gotestsum to generate JUnit XML files from Go test output - Tests two pure packages (pkg/gnoi/debug, internal/hash) to show variety of test results including subtests and fuzz tests - Integrated into azure-pipelines.yml with PublishTestResults@2 task - Generates both test results and coverage files per package - Results stored in build/bin/test-results/ directory This enables the "Tests" tab in Azure DevOps to show: - Individual test case results with timing - Test failure details and stack traces - Test trend analysis over time - Ability to filter and search specific tests Total of 91 test cases across the two packages demonstrate the detailed reporting capability. Signed-off-by: Dawei Huang <daweihuang@microsoft.com>
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Comment out check_gotest and check_memleak steps in azure-pipelines.yml to make pipeline runs faster while demonstrating JUnit XML test reporting. The focus is now on: - Fast pure package tests (make -f pure.mk azure-coverage) - JUnit XML generation (make check_junit) - Test results publishing (PublishTestResults@2) This provides a quick pipeline run that demonstrates the individual test result reporting in Azure DevOps without the long integration test execution time. Signed-off-by: Dawei Huang <daweihuang@microsoft.com>
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Why I did it
How I did it
How to verify it
Which release branch to backport (provide reason below if selected)
Description for the changelog
Link to config_db schema for YANG module changes
A picture of a cute animal (not mandatory but encouraged)