Skip to content

Commit 8aa6f74

Browse files
test
1 parent 31ffce5 commit 8aa6f74

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/pysonar_scanner/__main__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242

4343

4444
def main():
45+
print(scan())
4546
exit(scan())
4647

4748

tests/unit/test_main.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
from pyfakefs import fake_filesystem_unittest as pyfakefs
2424

25-
from pysonar_scanner.__main__ import scan, check_version, create_jre
25+
from pysonar_scanner.__main__ import scan, main, check_version, create_jre
2626
from pysonar_scanner.api import SQVersion, SonarQubeApi
2727
from pysonar_scanner.cache import Cache
2828
from pysonar_scanner.configuration.configuration_loader import ConfigurationLoader
@@ -91,6 +91,12 @@ def test_scan_with_exception(self, load_mock):
9191
exitcode = scan()
9292
self.assertEqual(1, exitcode)
9393

94+
def test_main_with_exitcode_not_zero(self):
95+
patch('sonar_scanner_python.cli.scan', return_value=42)
96+
with self.assertRaises(SystemExit) as main_exit:
97+
main()
98+
main_exit.return_value = 42
99+
94100
def test_version_check_outdated_sonarqube(self):
95101
sq_cloud_api = sq_api_utils.get_sq_server()
96102
sq_cloud_api.get_analysis_version = Mock(return_value=SQVersion.from_str("9.9.9"))

0 commit comments

Comments
 (0)