-
Notifications
You must be signed in to change notification settings - Fork 13
Improve Cross-Platform Compatibility in Tests and Refactor Path Handling #259
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
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Updated file path construction to use Path.GetFullPath and Path.Combine methods instead of string concatenation with backslashes. This change enhances platform-independence and reduces errors by ensuring the correct directory separator is used. Affected multiple test files across namespaces: ArtifactoryUploader.UTest, LCT.PackageIdentifier.UTest, and LCT.SW360PackageCreator.UTest.
Correct the casing of the environment variable name from "unknown" to "Unknown" in `RuntimeEnvironmentTests.cs` to ensure compatibility with case-sensitive systems.
Updated file path construction to use `Path.GetFullPath` and `Path.Combine` instead of string concatenation with backslashes. This change enhances the robustness and platform independence of the code. - Updated paths in `PackageUploadHelperTest.cs`, `CycloneBomProcessorTests.cs`, `DebianParserTests.cs`, `DisplayInformationTests.cs`, `MavenParserTests.cs`, `NPMParserTests.cs`, `NugetParserTests.cs`, and `ScannerTests.cs`. - Changed `ProjectName` from "test" to "Test" in `PackageUploaderTest.cs`.
Updated `CycloneBomProcessorTests.cs`: - Removed trailing backslash from `sourcePath`. - Used `Path.GetFullPath` and `Path.Combine` for `output.json` path. Updated `CreatorHelperTest.cs`: - Appended `Path.DirectorySeparatorChar` to `localPathforDownload`.
Changed ReleaseId in AttachReport from "invalid-url" to "http://invalid-url" to ensure it is recognized as an HTTP URL. This modification is necessary for testing purposes to verify that the system correctly identifies and handles invalid URLs.
The test method `SW360Apicommunication_AttachComponentSourceToSW360_ThrowsUriFormatException` has been commented out. This method was originally designed to test if the `AttachComponentSourceToSW360` method throws a `UriFormatException` when provided with an invalid URL. The code within the method has been commented out, effectively disabling the test without removing it entirely.
The `[Test]` attribute has been commented out, effectively disabling the test method `SW360Apicommunication_AttachComponentSourceToSW360_ThrowsUriFormatException`. This change ensures that this particular test will not be executed during the test suite run.
Updated using directives to include System.Runtime.InteropServices and System.Security. Uncommented and modified SW360Apicommunication_AttachComponentSourceToSW360_ThrowsUriFormatException to include OS-specific exception handling: UriFormatException for Windows and InvalidCastException for other platforms. No changes to SW360Apicommunication_GetProjects_ReturnsInvalidOperationException.
crvreddy
approved these changes
Mar 25, 2025
Collaborator
crvreddy
left a comment
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.
Approved
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Importance Low
Minor Impact
Refactoring
Improving code structure, readability, and maintainability without changing functionality
Under Review
Under Review
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR enhances cross-platform compatibility by refining file path construction and updating test cases to handle platform-specific behavior.
Key Changes:
Refactored Path Handling:
Fixed Environment Variable Casing:
Updated SW360 API Test for Platform-Specific Behavior:
These changes ensure that the tests run reliably across different operating systems while maintaining clarity and robustness. 🚀