-
Notifications
You must be signed in to change notification settings - Fork 343
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
fix 6068:Make the test class dependencies fulfill all the tests. #6079
base: master
Are you sure you want to change the base?
Conversation
Steps to test
The current behavior is as expected
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #6079 +/- ##
===========================================
+ Coverage 54.32% 68.87% +14.55%
===========================================
Files 202 202
Lines 21892 21894 +2
===========================================
+ Hits 11892 15079 +3187
+ Misses 10000 6815 -3185 ☔ View full report in Codecov by Sentry. |
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.
Hi @wangp-h,
Thank you so much for investigating and fixing this issue. Given your findings, I've found that an easier fix is possible:
diff --git a/avocado/core/dependencies/dependency.py b/avocado/core/dependencies/dependency.py
index 2f77c5763..46473d6e3 100644
--- a/avocado/core/dependencies/dependency.py
+++ b/avocado/core/dependencies/dependency.py
@@ -58,7 +58,7 @@ class Dependency:
@classmethod
def from_dictionary(cls, dictionary):
return cls(
- dictionary.pop("type", None),
+ dictionary.get("type", None),
dictionary.pop("uri", None),
dictionary.pop("args", ()),
dictionary,
This reduces the amount of data that is copied, and I was not able to find any negative side-effects. Let me know what you think about this alternative.
Hi, @clebergnu, thank you for your comments and suggestions! Yes, your modification could solve the issue, but it would affect the values of the dictionary in the original logic. Although I haven't done further debugging, this might cause some other issues. Therefore, I believe my change is more appropriate. |
Hi @wangp-h, I did a good deal of investigation, and I'm quite sure that the dictionary is used only for the purpose of the requirements, so there's no harm in modifying it. It's really better than adding an extra copy given that the original won't be used for anything else. Also, the exact version of your changes has import style issues. And finally, there's a problem unrelated to this fix, but that get's hit only when a fix is applied. You can see some failures in the diff --git a/selftests/functional/serial/requirements.py b/selftests/functional/serial/requirements.py
index 6f6dbfb4e..f275f3263 100644
--- a/selftests/functional/serial/requirements.py
+++ b/selftests/functional/serial/requirements.py
@@ -131,11 +131,11 @@ DEPENDENCY_FILE = """
"""
DEPENDENCY_RECIPE_FMT = """
-{
+{{
"kind": "avocado-instrumented",
"uri": "{path}",
- "kwargs": {"dependencies": [{"type": "package", "name": "hello"}]}
-}
+ "kwargs": {{"dependencies": [{{"type": "package", "name": "hello"}}]}}
+}}
""" We should integrate that fix into the same PR, or in a previous PR, so that CI is happy at the merge time. |
Signed-off-by: wangpeng <wangpengb@uniontech.com>
Hello, @clebergnu, thank you for your investigation and for reviewing the code again. I've resubmitted the PR based on your review comments. Please help review it again. |
Cause of the Issue:
The cause of the issue is that the 'type' field is removed from the dependencies_dict (using pop('type')), which causes the 'type' field to no longer exist in the dictionary during subsequent operations. When trying to assign the value of 'type' to the kind attribute through the Dependency.from_dictionary method, the dictionary no longer contains the 'type' field, which results in kind being incorrectly set to None.
Solution:
By using deepcopy(dependencies_dict), a copy of dependencies_dict is created, so any changes made to the copy (new_dependencies_dict) do not affect the original dictionary. This ensures that the 'type' field remains intact in the copied dictionary, allowing the correct assignment of kind from the 'type' field when calling Dependency.from_dictionary(d), thus avoiding the issue caused by modifying the original dictionary.