1
0
mirror of https://gitlab.com/fdroid/fdroidserver.git synced 2024-11-16 11:50:10 +01:00
fdroidserver/tests/scanner.TestCase

50 lines
1.5 KiB
Plaintext
Raw Normal View History

2017-12-15 00:29:38 +01:00
#!/usr/bin/env python3
import glob
import inspect
import logging
2017-12-15 00:29:38 +01:00
import optparse
import os
import sys
import unittest
localmodule = os.path.realpath(
os.path.join(os.path.dirname(inspect.getfile(inspect.currentframe())), '..'))
print('localmodule: ' + localmodule)
if localmodule not in sys.path:
sys.path.insert(0, localmodule)
2017-12-15 00:29:38 +01:00
import fdroidserver.common
import fdroidserver.metadata
import fdroidserver.scanner
2017-12-15 00:29:38 +01:00
class ScannerTest(unittest.TestCase):
def setUp(self):
logging.basicConfig(level=logging.INFO)
self.basedir = os.path.join(localmodule, 'tests')
2017-12-15 00:29:38 +01:00
def test_scan_source_files(self):
source_files = os.path.join(self.basedir, 'source-files')
2017-12-15 00:29:38 +01:00
projects = {
'Zillode': 1,
'firebase-suspect': 1
}
for d in glob.glob(os.path.join(source_files, '*')):
build = fdroidserver.metadata.Build()
fatal_problems = fdroidserver.scanner.scan_source(d, build)
self.assertEqual(projects.get(os.path.basename(d), 0),
fatal_problems)
2017-12-15 00:29:38 +01:00
if __name__ == "__main__":
parser = optparse.OptionParser()
parser.add_option("-v", "--verbose", action="store_true", default=False,
help="Spew out even more information than normal")
(fdroidserver.common.options, args) = parser.parse_args(['--verbose'])
newSuite = unittest.TestSuite()
newSuite.addTest(unittest.makeSuite(ScannerTest))
unittest.main(failfast=False)