Skip to content

Add some unit tests and refactor to support tests #326

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

Merged
merged 16 commits into from
May 3, 2025
Merged

Conversation

harp-intel
Copy link
Contributor

No description provided.

…sts for CPU list expansion

Signed-off-by: Harper, Jason M <[email protected]>
@harp-intel harp-intel requested a review from Copilot April 30, 2025 12:42
Copy link
Contributor

@Copilot Copilot AI left a 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 introduces new unit tests for utility functions while refactoring hex‐string conversion and related helper methods to improve testability. Key changes include:

  • Adding tests for IsValidHex, HexToIntList, IntRangeToIntList, and SelectiveIntRangeToIntList in internal/util/util_test.go.
  • Refactoring hex conversion functions in internal/util/util.go and updating downstream callers in table_helpers.go and table_defs.go.
  • Adding additional unit tests in target, report, and common directories to increase overall coverage.

Reviewed Changes

Copilot reviewed 10 out of 12 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
internal/util/util_test.go New tests for hex validation and conversion functions
internal/util/util.go Introduction of IsValidHex and HexToIntList functions for hex string handling
internal/target/local_target_test.go Added tests to verify GetUserPath behavior based on environment variables
internal/report/table_helpers_test.go Tests for getFrequenciesFromMSR, getBucketSizesFromMSR and expandTurboFrequencies functions
internal/report/table_helpers_benchmarking.go Removal of obsolete frequencyBucketsToFrequencies function
internal/report/table_helpers.go Refactoring to replace convertHexStringToDecimals with new helper functions and update ISA frequency expansion
internal/report/table_defs.go Updated to use the new expandTurboFrequencies helper
internal/common/targets_test.go Added tests for df field extraction and mount output parsing
Files not reviewed (2)
  • go.mod: Language not supported
  • scripts/copyright_go.sh: Language not supported

@harp-intel harp-intel requested a review from Copilot May 3, 2025 19:02
Copy link
Contributor

@Copilot Copilot AI left a 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 “Add some unit tests and refactor to support tests” introduces new unit tests for hex‐string validations, range parsing and target methods while refactoring several utility and report helper functions. Key changes include:

  • Adding new test cases for functions such as IsValidHex, HexToIntList, IntRangeToIntList, and SelectiveIntRangeToIntList.
  • Refactoring util and report helper functions to use new helper methods like getFrequenciesFromHex and expandTurboFrequencies.
  • Enhancing flag validations and target setup error messages.

Reviewed Changes

Copilot reviewed 18 out of 20 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
internal/util/util_test.go Added unit tests for hex validations and integer list conversion functions.
internal/util/util.go New implementations for IsValidHex, HexToIntList, IntRangeToIntList, etc.
internal/report/table_helpers.go Refactored functions for parsing and merging report sections and frequency buckets.
internal/common/targets.go Updated target temp directory creation and noexec file system check error messaging.
cmd/telemetry/telemetry.go & cmd/lock/lock.go Added additional flag validations (interval and frequency).
cmd/config/* files New flag definition and flag groups tests added for configuration command validation.
Files not reviewed (2)
  • go.mod: Language not supported
  • scripts/copyright_go.sh: Language not supported

@harp-intel harp-intel merged commit d633312 into main May 3, 2025
4 checks passed
@harp-intel harp-intel deleted the unittest branch May 3, 2025 23:56
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

Successfully merging this pull request may close these issues.

2 participants