community.general icon indicating copy to clipboard operation
community.general copied to clipboard

fix test helper handling of rc

Open russoz opened this issue 1 year ago • 1 comments
trafficstars

SUMMARY

Handle rc != 0 when check_rc = True

ISSUE TYPE
  • Test Pull Request
COMPONENT NAME
ADDITIONAL INFORMATION

russoz avatar May 19 '24 12:05 russoz

Hmm, there are a lot of failing unit tests. TypeError: side_effect() takes 0 positional arguments but 1 was given seems to indicate that side_effect() should accept the self parameter.

Looking at it again, I'm also not sure this really does what you think it does. My guess is that for every time someone calls module.run_command(), side_effect() is called once (and thus now returns a generator instead of the actual results).

felixfontein avatar May 19 '24 18:05 felixfontein

The test ansible-test sanity --test pylint [explain] failed with 1 error:

tests/unit/plugins/modules/helper.py:85:12: use-yield-from: Use 'yield from' directly instead of yielding each element one by one

The test ansible-test sanity --test pylint [explain] failed with 1 error:

tests/unit/plugins/modules/helper.py:85:12: use-yield-from: Use 'yield from' directly instead of yielding each element one by one

click here for bot help

ansibullbot avatar May 22 '24 10:05 ansibullbot

Regarding the pylint errors, use test/sanity/ignore-2.1[78].txt to ignore them like in some other cases:

tests/sanity/ignore-2.18.txt:plugins/module_utils/univention_umc.py pylint:use-yield-from  # suggested construct does not work with Python 2
tests/sanity/ignore-2.18.txt:tests/unit/compat/mock.py pylint:use-yield-from  # suggested construct does not work with Python 2
tests/sanity/ignore-2.17.txt:plugins/module_utils/univention_umc.py pylint:use-yield-from  # suggested construct does not work with Python 2
tests/sanity/ignore-2.17.txt:tests/unit/compat/mock.py pylint:use-yield-from  # suggested construct does not work with Python 2

felixfontein avatar May 22 '24 19:05 felixfontein

The test ansible-test sanity --test ignores [explain] failed with 1 error:

tests/sanity/ignore-2.17.txt:14:38: Sanity test 'yield-from' does not exist

The test ansible-test sanity --test ignores [explain] failed with 1 error:

tests/sanity/ignore-2.18.txt:14:38: Sanity test 'yield-from' does not exist

The test ansible-test sanity --test pylint [explain] failed with 1 error:

tests/unit/plugins/modules/helper.py:84:12: use-yield-from: Use 'yield from' directly instead of yielding each element one by one

The test ansible-test sanity --test pylint [explain] failed with 1 error:

tests/unit/plugins/modules/helper.py:84:12: use-yield-from: Use 'yield from' directly instead of yielding each element one by one

click here for bot help

ansibullbot avatar May 23 '24 08:05 ansibullbot

Backport to stable-8: 💔 cherry-picking failed — conflicts found

❌ Failed to cleanly apply da2c87ce0d3546edc068137d0a1279605bc377a4 on top of patchback/backports/stable-8/da2c87ce0d3546edc068137d0a1279605bc377a4/pr-8387

Backporting merged PR #8387 into main

  1. Ensure you have a local repo clone of your fork. Unless you cloned it from the upstream, this would be your origin remote.
  2. Make sure you have an upstream repo added as a remote too. In these instructions you'll refer to it by the name upstream. If you don't have it, here's how you can add it:
    $ git remote add upstream https://github.com/ansible-collections/community.general.git
    
  3. Ensure you have the latest copy of upstream and prepare a branch that will hold the backported code:
    $ git fetch upstream
    $ git checkout -b patchback/backports/stable-8/da2c87ce0d3546edc068137d0a1279605bc377a4/pr-8387 upstream/stable-8
    
  4. Now, cherry-pick PR #8387 contents into that branch:
    $ git cherry-pick -x da2c87ce0d3546edc068137d0a1279605bc377a4
    
    If it'll yell at you with something like fatal: Commit da2c87ce0d3546edc068137d0a1279605bc377a4 is a merge but no -m option was given., add -m 1 as follows instead:
    $ git cherry-pick -m1 -x da2c87ce0d3546edc068137d0a1279605bc377a4
    
  5. At this point, you'll probably encounter some merge conflicts. You must resolve them in to preserve the patch from PR #8387 as close to the original as possible.
  6. Push this branch to your fork on GitHub:
    $ git push origin patchback/backports/stable-8/da2c87ce0d3546edc068137d0a1279605bc377a4/pr-8387
    
  7. Create a PR, ensure that the CI is green. If it's not — update it so that the tests and any other checks pass. This is it! Now relax and wait for the maintainers to process your pull request when they have some cycles to do reviews. Don't worry — they'll tell you if any improvements are necessary when the time comes!

🤖 @patchback I'm built with octomachinery and my source is open — https://github.com/sanitizers/patchback-github-app.

patchback[bot] avatar May 24 '24 19:05 patchback[bot]

Backport to stable-9: 💚 backport PR created

✅ Backport PR branch: patchback/backports/stable-9/da2c87ce0d3546edc068137d0a1279605bc377a4/pr-8387

Backported as https://github.com/ansible-collections/community.general/pull/8414

🤖 @patchback I'm built with octomachinery and my source is open — https://github.com/sanitizers/patchback-github-app.

patchback[bot] avatar May 24 '24 19:05 patchback[bot]

@russoz thanks for implementing this!

felixfontein avatar May 24 '24 19:05 felixfontein