Skip to content
Snippets Groups Projects

Draft: Integration test for smcv's pending branches

Open Simon McVittie requested to merge wip/smcv/staging into main
Compare and
2 files
+ 91
23
Compare changes
  • Side-by-side
  • Inline
Files
2
+ 41
19
@@ -477,6 +477,7 @@ class Gui:
def __init__(self):
# type: (...) -> None
self.command_line_fd = -1
self.steam_runtime_env = {} # type: typing.Dict[str, str]
self.failed = False
self.home = GLib.get_home_dir()
@@ -897,6 +898,11 @@ class Gui:
):
# type: (...) -> None
parser = argparse.ArgumentParser()
parser.add_argument(
'--command-line-fd',
type=int,
default=-1,
)
parser.add_argument(
'--compatible-with',
choices=COMPAT_TARGETS + ['auto', 'any'],
@@ -911,6 +917,8 @@ class Gui:
parser.add_argument('command', nargs='+')
args = parser.parse_args()
self.command_line_fd = int(args.command_line_fd)
for token in args.steam_runtime_env:
if '=' not in token:
parser.error('--steam-runtime-env requires VAR=VALUE argument')
@@ -1643,22 +1651,30 @@ class Gui:
def run_cb(self, _ignored=None):
# type: (typing.Any) -> None
argv, environ = self.build_argv()
try:
os.execvpe(argv[0], argv, environ)
except OSError:
logger.error('Unable to run: %s', to_shell(argv))
shell, argv, environ = self.build_argv()
if self.command_line_fd >= 0:
with open(self.command_line_fd, 'w') as writer:
writer.write(shell)
Gtk.main_quit()
self.failed = True
raise
else:
try:
os.execvpe(argv[0], argv, environ)
except OSError:
logger.error('Unable to run: %s', to_shell(argv))
Gtk.main_quit()
self.failed = True
raise
def build_argv(self):
# type: (...) -> typing.Tuple[typing.List[str], typing.Dict[str, str]]
# type: (...) -> typing.Tuple[str, typing.List[str], typing.Dict[str, str]]
lines = [] # type: typing.List[str]
argv = [] # type: typing.List[str]
environ = {} # type: typing.Dict[str, str]
unsetenv = set() # type: typing.Set[str]
components = [] # type: typing.List[Component]
container = None # type: typing.Optional[Component]
@@ -1849,28 +1865,34 @@ class Gui:
argv.extend(self.app.argv)
lines.append(to_shell(self.app.argv))
env_lines = [] # type: typing.List[str]
# The older pressure-vessel-test-ui would be redundant here,
# so disable it.
unsetenv.add('PRESSURE_VESSEL_WRAP_GUI')
env_lines = ['env']
for var in sorted(unsetenv):
if var in os.environ:
env_lines.append('-u {}'.format(to_shell(var)))
for var, value in sorted(environ.items()):
if value != os.environ.get(var):
env_lines.append('{}={}'.format(var, to_shell([value])))
env_lines.append(to_shell(['{}={}'.format(var, value)]))
lines = env_lines + lines
self.final_command_view.get_buffer().set_text(
' \\\n'.join(lines), -1,
)
final_env = {} # type: typing.Dict[str, str]
final_env.update(os.environ)
for var in unsetenv:
final_env.pop(var, None)
final_env.update(environ)
# The older pressure-vessel-test-ui would be redundant here,
# so disable it.
if 'PRESSURE_VESSEL_WRAP_GUI' in final_env:
del final_env['PRESSURE_VESSEL_WRAP_GUI']
shell = ' \\\n'.join(lines)
self.final_command_view.get_buffer().set_text(shell, -1)
return argv, final_env
return shell, argv, final_env
def run(self):
# type: (...) -> None
Loading