Skip to content

Commit

Permalink
add test for noscripts option
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverkurth committed Apr 6, 2021
1 parent d26b490 commit a32dc52
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 1 deletion.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ Makefile.in
*.status
*.log
*.pc
*.spec
*.patch
*.diff

Expand Down
38 changes: 38 additions & 0 deletions pytests/repo/tdnf-bad-pre.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#
# tdnf-bad-pre spec file
#
Summary: basic install test file.
Name: tdnf-bad-pre
Version: 1.0.0
Release: 1
Vendor: VMware, Inc.
Distribution: Photon
License: VMware
Url: http://www.vmware.com
Group: Applications/tdnftest

%description
Part of tdnf test spec. Test bad install scripts.

%prep

%build

%install
mkdir -p %_topdir/%buildroot/usr/bin
cat << EOF >> %_topdir/%buildroot/usr/bin/bad-pre.sh
#!/bin/sh
# dummy script. Return false because we are bad.
/bin/false
EOF

%pre
# fail intentionally
/bin/false

%files
/usr/bin/bad-pre.sh

%changelog
* Fri Apr 2 2021 Oliver Kurth <[email protected]> 1.0.0-1
initial package to test '--setopt=tsflags=noscripts'
34 changes: 34 additions & 0 deletions pytests/tests/test_noscripts.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#
# Copyright (C) 2019 - 2020 VMware, Inc. All Rights Reserved.
#
# Licensed under the GNU General Public License v2 (the "License");
# you may not use this file except in compliance with the License. The terms
# of the License are located in the COPYING file of this distribution.
#
# Author: Oliver Kurth <[email protected]>

import os
import tempfile
import pytest

@pytest.fixture(scope='module', autouse=True)
def setup_test(utils):
yield
teardown_test(utils)

def teardown_test(utils):
pkgname = 'tdnf-bad-pre'
utils.run(['tdnf', 'erase', '-y', pkgname])

# Verify that the package is really bad:
def test_install_normal(utils):
pkgname = 'tdnf-bad-pre'
ret = utils.run([ 'tdnf', 'install' ,'-y', '--nogpgcheck', pkgname])
assert(ret['retval'] == 1525)

def test_install_noscripts(utils):
pkgname = 'tdnf-bad-pre'
ret = utils.run([ 'tdnf', 'install' ,'-y', '--nogpgcheck',
'--setopt=tsflags=noscripts', pkgname])
assert(ret['retval'] == 0)

0 comments on commit a32dc52

Please sign in to comment.