Reject incomplete install packages and exclude inherited guest disk
This commit is contained in:
1 parent
8088c1fbf6
commit
9b8e25d977
9 files changed
+277
-25
No files matched your search
@@ -6,7 +6,9 @@ Original test contributions: BSD-3-Clause; see LICENSES/.
|
||||
import hashlib
|
||||
import io
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import tarfile
|
||||
@@ -25,6 +27,48 @@ def digest(path):
|
||||
return hashlib.sha256(path.read_bytes()).hexdigest()
|
||||
|
||||
|
||||
class ActualRepositoryExportPolicy(unittest.TestCase):
|
||||
def test_actual_inherited_guest_disk_is_not_source(self):
|
||||
revision = subprocess.check_output(
|
||||
['git', 'rev-parse', 'HEAD'], cwd=REPOSITORY).decode().strip()
|
||||
tree = release.committed_tree(revision)
|
||||
# Inspect the real inherited Git object, not a fabricated .vhd filename.
|
||||
# changes.txt identifies boot.vhd as mounted/autorun guest software.
|
||||
self.assertIn('docs/Boot.vhd', tree)
|
||||
self.assertEqual(len(release.committed_blob(tree['docs/Boot.vhd'])), 224016)
|
||||
exported = {name for name in tree if release.source_member(name)}
|
||||
self.assertNotIn('docs/Boot.vhd', exported)
|
||||
self.assertEqual(release.SOURCE_SUFFIXES['docs'], {'.md'})
|
||||
self.assertIn('rtl/CPU09/cpu09_119.vhd', exported)
|
||||
|
||||
def test_powershell_wrapper_passes_selected_and_default_build(self):
|
||||
shell = shutil.which('pwsh') or shutil.which('powershell')
|
||||
if not shell:
|
||||
self.skipTest('PowerShell unavailable for native wrapper contract')
|
||||
with tempfile.TemporaryDirectory(dir=REPOSITORY / 'build') as folder:
|
||||
base = Path(folder)
|
||||
capture = base / 'capture.json'
|
||||
fake = base / 'capture-python.ps1'
|
||||
fake.write_text('$args | ConvertTo-Json -Compress | Set-Content -LiteralPath $env:COCO3PLUS_WRAPPER_CAPTURE\n$global:LASTEXITCODE=0\n')
|
||||
environment = os.environ.copy()
|
||||
environment['COCO3PLUS_WRAPPER_CAPTURE'] = str(capture)
|
||||
for selection in ([], ['-Build', 'build/fpga-qualified']):
|
||||
with self.subTest(selection=selection):
|
||||
subprocess.run(
|
||||
[shell, '-NoProfile', '-ExecutionPolicy', 'Bypass', '-File',
|
||||
str(REPOSITORY / 'windows/Package-Release.ps1'),
|
||||
'-Python', str(fake), '-Output', 'dist/qualified',
|
||||
'-PublicPackage', *selection], cwd=REPOSITORY,
|
||||
env=environment, check=True, capture_output=True)
|
||||
arguments = json.loads(capture.read_text(encoding='utf-8-sig'))
|
||||
index = arguments.index('--build')
|
||||
self.assertEqual(arguments[index + 1],
|
||||
selection[-1] if selection else 'build/fpga')
|
||||
self.assertIn('--public', arguments)
|
||||
self.assertEqual(arguments[arguments.index('--output') + 1],
|
||||
'dist/qualified')
|
||||
|
||||
|
||||
class SimulatorInstallGuards(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.temporary = tempfile.TemporaryDirectory(dir=REPOSITORY / 'build')
|
||||
|
||||
Reference in new issue
Block a user