mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-24 23:36:04 +00:00
test: verify dependency installation fails closed
This commit is contained in:
1 parent
74d5daaa5d
commit
fcf4c09c50
1 file changed
+23
@@ -2,6 +2,7 @@ import itertools
|
|||||||
import os
|
import os
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import tempfile
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
import yaml
|
import yaml
|
||||||
@@ -11,6 +12,28 @@ ROOT = Path(__file__).resolve().parents[2]
|
|||||||
|
|
||||||
|
|
||||||
class CiChecksTest(unittest.TestCase):
|
class CiChecksTest(unittest.TestCase):
|
||||||
|
def test_dependency_update_errors_block_installation(self):
|
||||||
|
with tempfile.TemporaryDirectory() as directory:
|
||||||
|
root = Path(directory)
|
||||||
|
sudo = root / 'sudo'
|
||||||
|
sudo.write_text('#!/bin/bash\nprintf "%s\\n" "$*" >> "$APT_LOG"\nexit "${APT_RESULT:-0}"\n')
|
||||||
|
sudo.chmod(0o755)
|
||||||
|
log = root / 'apt.log'
|
||||||
|
env = dict(os.environ, PATH=str(root) + os.pathsep + os.environ['PATH'], APT_LOG=str(log))
|
||||||
|
installer = ROOT / 'tools/ci/install-ubuntu-packages.sh'
|
||||||
|
result = subprocess.run(['bash', str(installer), 'qemu-user'], env=dict(env, APT_RESULT='17'))
|
||||||
|
self.assertEqual(result.returncode, 17)
|
||||||
|
self.assertEqual(len(log.read_text().splitlines()), 1)
|
||||||
|
log.unlink()
|
||||||
|
subprocess.run(['bash', str(installer), 'qemu-user'], env=env, check=True)
|
||||||
|
update, install = log.read_text().splitlines()
|
||||||
|
for command in (update, install):
|
||||||
|
self.assertIn('Dir::Etc::sourceparts=-', command)
|
||||||
|
self.assertIn('Acquire::https::Timeout=30', command)
|
||||||
|
self.assertIn('Acquire::Retries=3', command)
|
||||||
|
self.assertIn('APT::Update::Error-Mode=any', update)
|
||||||
|
self.assertIn('install -y -qq --no-install-recommends qemu-user', install)
|
||||||
|
|
||||||
def test_required_status_rejects_failed_cancelled_or_skipped_test_jobs(self):
|
def test_required_status_rejects_failed_cancelled_or_skipped_test_jobs(self):
|
||||||
jobs = yaml.safe_load((ROOT / '.github/workflows/build.yml').read_text())['jobs']
|
jobs = yaml.safe_load((ROOT / '.github/workflows/build.yml').read_text())['jobs']
|
||||||
gate = jobs['checks']
|
gate = jobs['checks']
|
||||||
|
|||||||
Reference in new issue
Block a user