Merge pull request #47172 from dwoz/cover_without_admin

Allow non admin name based runs on windows
This commit is contained in:
Daniel Wozniak 2018-04-19 10:26:41 -07:00 committed by GitHub
commit 1a600bb9a4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -10,6 +10,7 @@ from __future__ import absolute_import, print_function
import os
import sys
import time
import warnings
TESTS_DIR = os.path.dirname(os.path.normpath(os.path.abspath(__file__)))
if os.name == 'nt':
@ -476,20 +477,26 @@ class SaltTestsuiteParser(SaltCoverageTestingParser):
is_admin = True
else:
is_admin = salt.utils.win_functions.is_admin(current_user)
if self.options.coverage and any((
self.options.name,
not is_admin,
not self.options.run_destructive)) \
and self._check_enabled_suites(include_unit=True):
warnings.warn("Test suite not running with elevated priviledges")
else:
is_admin = os.geteuid() == 0
if self.options.coverage and any((
self.options.name,
not is_admin,
not self.options.run_destructive)) \
and self._check_enabled_suites(include_unit=True):
self.error(
'No sense in generating the tests coverage report when '
'not running the full test suite, including the '
'destructive tests, as \'root\'. It would only produce '
'incorrect results.'
)
if self.options.coverage and any((
self.options.name,
not is_admin,
not self.options.run_destructive)) \
and self._check_enabled_suites(include_unit=True):
self.error(
'No sense in generating the tests coverage report when '
'not running the full test suite, including the '
'destructive tests, as \'root\'. It would only produce '
'incorrect results.'
)
# When no tests are specifically enumerated on the command line, setup
# a default run: +unit -cloud_provider