mirror of
https://github.com/openSUSE/osc.git
synced 2025-01-11 16:36:14 +01:00
Propagate exit code from the run() and do_() commandline methods
This commit is contained in:
parent
dabefbb913
commit
6322e2f9aa
3
.github/workflows/tests.yaml
vendored
3
.github/workflows/tests.yaml
vendored
@ -103,8 +103,9 @@ jobs:
|
||||
steps:
|
||||
- name: "Install packages"
|
||||
run: |
|
||||
sudo sh -c '. /etc/os-release; echo "deb [trusted=yes] http://download.opensuse.org/repositories/openSUSE:Tools/xUbuntu_${VERSION_ID} ./" > /etc/apt/sources.list.d/openSUSE-Tools.list'
|
||||
sudo apt-get -y update
|
||||
sudo apt-get -y --no-install-recommends install python3-behave diffstat diffutils python3 python3-cryptography python3-pip python3-rpm python3-setuptools python3-urllib3
|
||||
sudo apt-get -y --no-install-recommends install python3-behave diffstat diffutils python3 python3-cryptography python3-pip python3-rpm python3-setuptools python3-urllib3 obs-build obs-service-set-version
|
||||
|
||||
- name: "Checkout sources"
|
||||
uses: actions/checkout@v3
|
||||
|
@ -54,6 +54,12 @@ $ podman stop|kill obs-server
|
||||
$ podman rmi obs-server
|
||||
```
|
||||
|
||||
Install test dependencies
|
||||
-------------------------
|
||||
```
|
||||
$ zypper install python3-behave diffstat diffutils obs-service-replace_using_env python3 python3-cryptography python3-pip python3-rpm python3-setuptools python3-urllib3 build obs-service-set_version
|
||||
```
|
||||
|
||||
Run tests
|
||||
---------
|
||||
|
||||
|
11
behave/features/service.feature
Normal file
11
behave/features/service.feature
Normal file
@ -0,0 +1,11 @@
|
||||
Feature: `osc service` command
|
||||
|
||||
|
||||
Scenario: Run `osc service manualrun`
|
||||
Given I set working directory to "{context.osc.temp}"
|
||||
And I execute osc with args "checkout test:factory test-pkgA"
|
||||
And I set working directory to "{context.osc.temp}/test:factory/test-pkgA"
|
||||
And I copy file "{context.fixtures}/pac/_service-set_version-invalid" to "{context.osc.temp}/test:factory/test-pkgA/_service"
|
||||
When I execute osc with args "service manualrun"
|
||||
Then stdout contains "Aborting: service call failed"
|
||||
And the exit code is 255
|
5
behave/fixtures/pac/_service-set_version-invalid
Normal file
5
behave/fixtures/pac/_service-set_version-invalid
Normal file
@ -0,0 +1,5 @@
|
||||
<services>
|
||||
<service name="set_version" mode="manual">
|
||||
<param name="fromfile">invalid</param>
|
||||
</service>
|
||||
</services>
|
@ -245,7 +245,7 @@ class MainCommand(Command):
|
||||
if not cmd:
|
||||
self.parser.error("Please specify a command")
|
||||
self.post_parse_args(args)
|
||||
cmd.run(args)
|
||||
return cmd.run(args)
|
||||
|
||||
def load_command(self, cls, module_prefix):
|
||||
mod_cls_name = f"{module_prefix}.{cls.__name__}"
|
||||
@ -502,10 +502,10 @@ class OscMainCommand(MainCommand):
|
||||
# handler doesn't take positional args via *args
|
||||
if args.positional_args:
|
||||
self.parser.error(f"unrecognized arguments: " + " ".join(args.positional_args))
|
||||
self.func(args.command, args)
|
||||
return self.func(args.command, args)
|
||||
else:
|
||||
# handler takes positional args via *args
|
||||
self.func(args.command, args, *args.positional_args)
|
||||
return self.func(args.command, args, *args.positional_args)
|
||||
|
||||
return LegacyCommandWrapper
|
||||
|
||||
@ -561,7 +561,8 @@ class OscMainCommand(MainCommand):
|
||||
cmd.load_legacy_commands()
|
||||
if run:
|
||||
args = cmd.parse_args(args=argv)
|
||||
cmd.run(args)
|
||||
exit_code = cmd.run(args)
|
||||
sys.exit(exit_code)
|
||||
else:
|
||||
args = None
|
||||
return cmd, args
|
||||
|
Loading…
Reference in New Issue
Block a user