pactest: treat arguments as files instead of globs

glob() returns an empty list if input does not match any files, causing
non-existent test files to be silently skipped.  Treating arguments as
files causes pactest to immediately bail out with an appropriate error
message on non-existent files.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
Andrew Gregory 2014-04-06 19:20:55 -04:00 committed by Allan McRae
parent 80d3709e65
commit 00fbdabc55
1 changed files with 8 additions and 7 deletions

View File

@ -18,7 +18,6 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import glob
from optparse import OptionParser
import os
import shutil
@ -100,16 +99,18 @@ def create_parser():
env.pacman["scriptlet-shell"] = opts.scriptletshell
env.pacman["ldconfig"] = opts.ldconfig
opts.testcases = []
for path in args:
opts.testcases += glob.glob(path)
if opts.testcases is None or len(opts.testcases) == 0:
if args is None or len(args) == 0:
tap.bail("no tests defined, nothing to do")
os.rmdir(root_path)
sys.exit(2)
for i in opts.testcases:
env.addtest(i)
try:
for i in args:
env.addtest(i)
except Exception as e:
tap.bail(e)
os.rmdir(root_path)
sys.exit(2)
# run tests
env.run()