feat: initial Cutdex application
Add the Flutter video editing application with project management, media import, timeline editing, preview, AI assistance, diagnostics and settings. Include shared UI and native host packages, platform runners, application tests and release tooling. Provide usage and contribution guides, the MIT license and third-party notices. Exclude local credentials, build outputs and validation data.
This commit is contained in:
commit
27e77fff39
718 files changed
+183958
No files matched your search
@@ -0,0 +1,128 @@
|
||||
"""Build two disposable Flutter apps and verify updates through a Python HTTP server.
|
||||
|
||||
Uses Cutdex.Dev only. Tests checksum rejection, retry, install, relaunch and no-op
|
||||
checks. Requires Flutter, the pinned vpk tool and Windows. Never uploads releases.
|
||||
"""
|
||||
import argparse
|
||||
from functools import partial
|
||||
from http.server import SimpleHTTPRequestHandler, ThreadingHTTPServer
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import threading
|
||||
import time
|
||||
|
||||
from windows_updates import DESKUP_VERSION, ROOT, check_tool, pack_release, update_version, vpk_command
|
||||
|
||||
|
||||
class TestHandler(SimpleHTTPRequestHandler):
|
||||
corrupt = True
|
||||
|
||||
def do_GET(self):
|
||||
if self.path.endswith('.nupkg') and type(self).corrupt:
|
||||
type(self).corrupt = False
|
||||
file = Path(self.directory) / self.path.lstrip('/')
|
||||
payload = bytearray(file.read_bytes())
|
||||
payload[len(payload) // 2] ^= 1
|
||||
self.send_response(200)
|
||||
self.send_header('Content-Length', str(len(payload)))
|
||||
self.end_headers()
|
||||
self.wfile.write(payload)
|
||||
else:
|
||||
super().do_GET()
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('--vpk', type=Path, required=True)
|
||||
parser.add_argument('--flutter', default=shutil.which('flutter'))
|
||||
parser.add_argument('--work', type=Path, default=ROOT / '.local/windows-update-test')
|
||||
parser.add_argument('--port', type=int, default=8765)
|
||||
parser.add_argument('--offline', action='store_true', help='Use already cached Flutter packages')
|
||||
args = parser.parse_args()
|
||||
if sys.platform != 'win32':
|
||||
parser.error('This test requires Windows')
|
||||
work = args.work.resolve()
|
||||
if work.exists():
|
||||
parser.error('Use a new work directory so previous reports cannot pass this test')
|
||||
work.mkdir(parents=True)
|
||||
command = vpk_command(args.vpk)
|
||||
check_tool(command)
|
||||
definitions = work / 'defines.json'
|
||||
definitions.write_text(json.dumps({'CUTDEX_UPDATE_SMOKE_ROOT': work.as_posix()}), encoding='utf-8')
|
||||
environment = dict(os.environ, CUTDEX_WINDOWS_UPDATE_URL=f'http://127.0.0.1:{args.port}',
|
||||
CUTDEX_UPDATE_TEST_HTTP='1')
|
||||
# Isolate Flutter caches, generated runner files and output from live builds.
|
||||
source = work / 'source'
|
||||
source.mkdir()
|
||||
for name in ['windows']:
|
||||
shutil.copytree(ROOT / name, source / name,
|
||||
ignore=shutil.ignore_patterns('ephemeral', 'build', '__pycache__'))
|
||||
# Exercise the real Runner/update bridge with a small Flutter test entry.
|
||||
# Media processing is covered separately and need not be rebuilt here.
|
||||
(source / 'pubspec.yaml').write_text(
|
||||
'name: cutdex_update_smoke\nversion: 1.0.0+1\n'
|
||||
'environment:\n sdk: ^3.13.2\n'
|
||||
'dependencies:\n flutter:\n sdk: flutter\n'
|
||||
f' deskup: {DESKUP_VERSION}\n'
|
||||
'flutter:\n uses-material-design: true\n', encoding='utf-8')
|
||||
entry = source / 'tool/testing/windows_update_smoke.dart'
|
||||
entry.parent.mkdir(parents=True)
|
||||
shutil.copyfile(ROOT / 'tool/testing/windows_update_smoke.dart', entry)
|
||||
subprocess.run([args.flutter, 'pub', 'get'] + (['--offline'] if args.offline else []),
|
||||
cwd=source, env=environment, check=True)
|
||||
# Keep test packages separate from the app's normal release output.
|
||||
for build in [900001, 900002]:
|
||||
subprocess.run([args.flutter, 'build', 'windows', '--no-pub', '--release', '--flavor', 'development',
|
||||
'--target', 'tool/testing/windows_update_smoke.dart', '--build-name', '1.0.0',
|
||||
'--build-number', str(build), '--dart-define-from-file', str(definitions)],
|
||||
cwd=source, env=environment, check=True)
|
||||
app = source / 'build/windows/x64/development/runner/Release'
|
||||
release = work / ('baseline' if build == 900001 else 'public')
|
||||
pack_release(command, app=app, output=release, package_id='Cutdex.Dev',
|
||||
version=update_version('1.0.0', build), title='Cutdex update test')
|
||||
verify_update(work, args.port)
|
||||
|
||||
|
||||
def verify_update(work, port):
|
||||
reports = ['corrupt-rejected', 'before', 'after', 'failure']
|
||||
if any((work / f'{name}.json').exists() for name in reports):
|
||||
raise ValueError('Previous reports must not pass this test; use a fresh work directory')
|
||||
portable = next((work / 'baseline').glob('*Portable.zip'))
|
||||
if not (work / 'installed').exists():
|
||||
shutil.unpack_archive(portable, work / 'installed')
|
||||
TestHandler.corrupt = True
|
||||
server = ThreadingHTTPServer(('127.0.0.1', port),
|
||||
partial(TestHandler, directory=str(work / 'public')))
|
||||
thread = threading.Thread(target=server.serve_forever, daemon=True)
|
||||
thread.start()
|
||||
# Hide the helper process console; the test app itself shows its test window.
|
||||
app = work / 'installed/Cutdex update test.exe'
|
||||
process = None
|
||||
try:
|
||||
process = subprocess.Popen([str(app)], cwd=app.parent, creationflags=subprocess.CREATE_NO_WINDOW)
|
||||
deadline = time.monotonic() + 240
|
||||
while time.monotonic() < deadline:
|
||||
if (work / 'failure.json').exists():
|
||||
raise RuntimeError((work / 'failure.json').read_text())
|
||||
if (work / 'after.json').exists():
|
||||
break
|
||||
time.sleep(0.2)
|
||||
else:
|
||||
raise TimeoutError('Update did not relaunch within 240 seconds')
|
||||
for report in ['corrupt-rejected', 'before', 'after']:
|
||||
print(report + ': ' + (work / f'{report}.json').read_text())
|
||||
process.wait(timeout=20)
|
||||
print(f'Velopack end-to-end update passed: {work}')
|
||||
finally:
|
||||
if process is not None and process.poll() is None:
|
||||
process.terminate()
|
||||
server.shutdown()
|
||||
server.server_close()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Reference in new issue
Block a user