mirror of
https://gitlab.com/fdroid/fdroidserver.git
synced 2024-10-03 17:50:11 +02:00
scanner: fix tests so they work on all tested platforms
The standard test configuration is needed to make the tests reliably. Also, these tests used some odd yield logic. Who knows what exactly failed, but these tests should be reliable. * https://gitlab.com/fdroid/fdroidserver/-/jobs/44984595 * https://gitlab.com/fdroid/fdroidserver/-/jobs/44984596 * https://travis-ci.org/f-droid/fdroidserver/builds/318071369
This commit is contained in:
parent
86c5598307
commit
39b76b0eda
@ -1,25 +1,41 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
import unittest
|
import glob
|
||||||
|
import inspect
|
||||||
|
import logging
|
||||||
import optparse
|
import optparse
|
||||||
from pathlib import Path
|
import os
|
||||||
from os.path import basename, dirname, realpath
|
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)
|
||||||
|
|
||||||
from fdroidserver import scanner
|
|
||||||
from fdroidserver.metadata import Build
|
|
||||||
import fdroidserver.common
|
import fdroidserver.common
|
||||||
|
import fdroidserver.metadata
|
||||||
|
import fdroidserver.scanner
|
||||||
|
|
||||||
|
|
||||||
class ScannerTest(unittest.TestCase):
|
class ScannerTest(unittest.TestCase):
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
logging.basicConfig(level=logging.INFO)
|
||||||
|
self.basedir = os.path.join(localmodule, 'tests')
|
||||||
|
|
||||||
def test_scan_source_files(self):
|
def test_scan_source_files(self):
|
||||||
source_files = Path(dirname(realpath(__file__)), 'source-files')
|
source_files = os.path.join(self.basedir, 'source-files')
|
||||||
projects = {
|
projects = {
|
||||||
'Zillode': 1,
|
'Zillode': 1,
|
||||||
'firebase-suspect': 1
|
'firebase-suspect': 1
|
||||||
}
|
}
|
||||||
for d in (str(p) for p in source_files.iterdir()):
|
for d in glob.glob(os.path.join(source_files, '*')):
|
||||||
fatal_problems = scanner.scan_source(d, Build())
|
build = fdroidserver.metadata.Build()
|
||||||
self.assertEqual(projects.get(basename(d), 0), fatal_problems)
|
fatal_problems = fdroidserver.scanner.scan_source(d, build)
|
||||||
|
self.assertEqual(projects.get(os.path.basename(d), 0),
|
||||||
|
fatal_problems)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
Loading…
Reference in New Issue
Block a user