Skip to content

Commit

Permalink
Add possibility to run tests for runexec with sudo
Browse files Browse the repository at this point in the history
with a different user account.
  • Loading branch information
PhilippWendler committed Dec 3, 2015
1 parent 7ff4904 commit 7344fb0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ install:
- if [ "$TRAVIS_PYTHON_VERSION" == "3.2" ]; then travis_retry pip install coverage==3.7.1; else travis_retry pip install coverage; fi
- travis_retry pip install -e git+https://github.com/codacy/python-codacy-coverage.git#egg=codacy
before_script:
- sudo ./.travis-setup.sh "$USER" benchmarks
- sudo ./.travis-setup.sh "$USER" "$BENCHEXEC_TEST_USER"
- printf 'import coverage\ncoverage.process_startup()\n' > "/home/travis/virtualenv/python${TRAVIS_PYTHON_VERSION}/lib/python${TRAVIS_PYTHON_VERSION}/sitecustomize.py"
env:
- COVERAGE_PROCESS_START=.coveragerc
- BENCHEXEC_TEST_USER=benchmarks COVERAGE_PROCESS_START=.coveragerc
script:
- coverage run setup.py test
after_success:
Expand Down
6 changes: 4 additions & 2 deletions benchexec/test_runexecutor.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,8 +393,10 @@ class TestRunExecutorWithSudo(TestRunExecutor):
would not be good, either.
"""

# sudo allows refering to numerical uids with '#'
user = '#' + str(os.getuid())
# Use user name defined in environment variable if present,
# or fall back to current user (sudo always allows this).
# sudo allows refering to numerical uids with '#'.
user = os.environ.get('BENCHEXEC_TEST_USER', '#' + str(os.getuid()))

def setUp(self):
try:
Expand Down

0 comments on commit 7344fb0

Please sign in to comment.