import pathlib, subprocess, sys, os
checkout = pathlib.Path(sys.argv[1]).resolve()
fixture = pathlib.Path(sys.argv[2]).resolve()
base = '7f694ec917d72b3126801cd7bcbc66149ec9b177'
head = 'da0e261e7761a1fc643ad9b8378f59146877c70d'
os.environ['T3CODE_DEV_SEED']='0'
os.environ['T3_SCENARIO_INHERIT_ENV']='AZURE_DEVOPS_*,T3CODE_DEV_SEED'
with (fixture/'media-server.log').open('w') as server_log:
 server = subprocess.Popen([sys.executable, '-m', 'http.server', '18421', '--bind', '127.0.0.1', '--directory', str(fixture)], stdout=server_log, stderr=server_log)
 try:
  with (fixture/'proof-with-fixture.log').open('w') as proof_log:
   result = subprocess.run(['vp','run','scenarios:prove','scripts/scenarios/pr-media-parentheses.e2e.ts','--base',base,'--head',head,'--upload-command','ghdrop upload'],cwd=checkout,stdout=proof_log,stderr=subprocess.STDOUT)
  sys.exit(result.returncode)
 finally:
  server.terminate()
  server.wait()
