Skip to content

Conversation

@furtib
Copy link
Contributor

@furtib furtib commented Oct 13, 2025

Why:
We want to test our solutions for making remote workers' absolute paths into locally usable relative paths. We should add a test for it.

What:
Adds a new test to run on pre-created remote worker paths.

Addresses:
#65

@furtib furtib requested a review from Szelethus October 13, 2025 09:13
@furtib furtib self-assigned this Oct 13, 2025
@furtib furtib added the test ☑️ Adding or refactoring tests label Oct 13, 2025
@furtib furtib force-pushed the test-plist-resolution-regex branch from d3dfa6b to 761121e Compare October 13, 2025 09:18
Copy link
Contributor

@Szelethus Szelethus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with creating/removing the tmp directory with a class level setup/teardown, but by having a global PATH_RESOLUTION, you practically do 90% of the test in those methods. In fact, I'm not even sure the way you are testing there is a need for creating any files. I recommend that you simply test the string replace, which is all that really matters here.

""" Remove Bazel leading paths in all files """
stage("Fix CodeChecker output:")
folder = CODECHECKER_FILES
folder = CODECHECKER_FILES if not pth else pth
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a very intrusive test. You are not testing the entirety of this function, only this part:

data = data_file.read()
for pattern, replace in BAZEL_PATHS.items():
    data = re.sub(pattern, replace, data)

Lets just create a separate function that takes some string and returns with a substituted one. One something like that. That way you won't need to add an intrusive parameter just for testing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could just import the list of regexes from here, to not be so intrusive.

@furtib furtib requested a review from Szelethus October 13, 2025 12:46
@furtib furtib force-pushed the test-plist-resolution-regex branch from bea98fe to 7d4745a Compare October 14, 2025 11:08
Copy link
Contributor

@Szelethus Szelethus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, this is what I wanted to see! I have some nits, but otherwise this is a great PR.

Comment on lines 27 to 34
PATH_RESOLUTION: Dict[str, str] = {
# {Remote execution absolute path}: {project relative path}
"/worker/build/5d2c60d87885b089/root/test/unit/legacy/src/lib.cc": "test/unit/legacy/src/lib.cc",
"/worker/build/a0ed5e04f7c3b444/root/test/unit/legacy/src/ctu.cc": "test/unit/legacy/src/ctu.cc",
"/worker/build/a0ed5e04f7c3b444/root/test/unit/legacy/src/fail.cc": "test/unit/legacy/src/fail.cc",
# This resolution is impossible, because "test_inc" => "inc" cannot be resolved
# "/worker/build/28e82627f5078a2d/root/bazel-out/k8-fastbuild/bin/test/unit/virtual_include/_virtual_includes/test_inc/zeroDiv.h": "test/unit/virtual_include/inc/zeroDiv.h"
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this global variable? We could just pass each of these as an argument.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought it would be easier to test other methods we might add in the future, this way.

@furtib furtib requested a review from Szelethus October 20, 2025 13:07
@furtib furtib force-pushed the test-plist-resolution-regex branch from 1a9a825 to 5d312a2 Compare November 24, 2025 12:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test ☑️ Adding or refactoring tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants