mirror of
https://gitlab.com/fdroid/fdroidserver.git
synced 2024-11-20 13:50:12 +01:00
Merge branch 'scanner-safe_path_test' into 'master'
scanner: add test with abs/rel paths as run from `fdroid build` See merge request fdroid/fdroidserver!768
This commit is contained in:
commit
0b4112f743
@ -105,9 +105,17 @@ class ScannerTest(unittest.TestCase):
|
|||||||
self.assertEqual(2, count, 'there should be this many errors')
|
self.assertEqual(2, count, 'there should be this many errors')
|
||||||
|
|
||||||
def test_scan_source_file_types(self):
|
def test_scan_source_file_types(self):
|
||||||
"""Build product files are not allowed, test they are detected"""
|
"""Build product files are not allowed, test they are detected
|
||||||
|
|
||||||
|
This test runs as if `fdroid build` running to test the
|
||||||
|
difference between absolute and relative paths.
|
||||||
|
|
||||||
|
"""
|
||||||
testdir = tempfile.mkdtemp(prefix=inspect.currentframe().f_code.co_name, dir=self.tmpdir)
|
testdir = tempfile.mkdtemp(prefix=inspect.currentframe().f_code.co_name, dir=self.tmpdir)
|
||||||
os.chdir(testdir)
|
build_dir = os.path.join('build', 'fake.app')
|
||||||
|
abs_build_dir = os.path.join(testdir, build_dir)
|
||||||
|
os.makedirs(abs_build_dir, exist_ok=True)
|
||||||
|
os.chdir(abs_build_dir)
|
||||||
|
|
||||||
fdroidserver.scanner.config = None
|
fdroidserver.scanner.config = None
|
||||||
fdroidserver.scanner.options = mock.Mock()
|
fdroidserver.scanner.options = mock.Mock()
|
||||||
@ -151,8 +159,11 @@ class ScannerTest(unittest.TestCase):
|
|||||||
os.chmod('snippet.png', 0o755)
|
os.chmod('snippet.png', 0o755)
|
||||||
os.system('ls -l fake.png')
|
os.system('ls -l fake.png')
|
||||||
|
|
||||||
count = fdroidserver.scanner.scan_source(testdir)
|
# run scanner as if from `fdroid build`
|
||||||
|
os.chdir(testdir)
|
||||||
|
count = fdroidserver.scanner.scan_source(build_dir)
|
||||||
self.assertEqual(6, count, 'there should be this many errors')
|
self.assertEqual(6, count, 'there should be this many errors')
|
||||||
|
os.chdir(build_dir)
|
||||||
|
|
||||||
for f in keep + binaries:
|
for f in keep + binaries:
|
||||||
self.assertTrue(os.path.exists(f), f + ' should still be there')
|
self.assertTrue(os.path.exists(f), f + ' should still be there')
|
||||||
|
Loading…
Reference in New Issue
Block a user