Skip to content

Commit 0daeae5

Browse files
committed
Add more logging to test standalone
1 parent 62e1e11 commit 0daeae5

File tree

1 file changed

+33
-19
lines changed

1 file changed

+33
-19
lines changed

graalpython/com.oracle.graal.python.test/src/tests/standalone/test_standalone.py

Lines changed: 33 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved.
22
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
33
#
44
# The Universal Permissive License (UPL), Version 1.0
@@ -60,16 +60,20 @@ def test_native_executable_one_file():
6060
f.write("import sys\n")
6161
f.write("print('hello world, argv[1:]:', sys.argv[1:])")
6262

63+
log = util.Logger()
64+
6365
target_file = os.path.join(tmpdir, "hello")
6466
cmd = [graalpy, "-m", "standalone", "--verbose", "native", "-ce", "-m", source_file, "-o", target_file]
6567

66-
out, return_code = util.run_cmd(cmd, env, print_out=True)
67-
util.check_ouput("Bundling Python resources into", out)
68-
util.check_ouput("Finished generating 'hello' in", out)
68+
out, return_code = util.run_cmd(cmd, env, print_out=True, logger=log)
69+
assert return_code == 0, log
70+
util.check_ouput("Bundling Python resources into", out, logger=log)
71+
util.check_ouput("Finished generating 'hello' in", out, logger=log)
6972

7073
cmd = [target_file, "arg1", "arg2"]
71-
out, return_code = util.run_cmd(cmd, env)
72-
util.check_ouput("hello world, argv[1:]: " + str(cmd[1:]), out)
74+
out, return_code = util.run_cmd(cmd, env, logger=log)
75+
assert return_code == 0, log
76+
util.check_ouput("hello world, argv[1:]: " + str(cmd[1:]), out, logger=log)
7377

7478
@unittest.skipUnless(is_enabled, "ENABLE_STANDALONE_UNITTESTS is not true")
7579
def test_native_executable_venv_and_one_file():
@@ -89,24 +93,30 @@ def test_native_executable_venv_and_one_file():
8993
f.write('d = ujson.loads("""{"key": "value"}""")\n')
9094
f.write("print('key=' + d['key'])\n")
9195

96+
log = util.Logger()
97+
9298
venv_dir = os.path.join(target_dir, "venv")
9399
cmd = [graalpy, "-m", "venv", venv_dir]
94-
out, return_code = util.run_cmd(cmd, env)
100+
out, return_code = util.run_cmd(cmd, env, logger=log)
101+
assert return_code == 0, log
95102

96103
venv_python = os.path.join(venv_dir, "Scripts", "python.exe") if os.name == "nt" else os.path.join(venv_dir, "bin", "python")
97104
cmd = [venv_python, "-m", "pip", "install", "termcolor", "ujson"]
98-
out, return_code = util.run_cmd(cmd, env)
105+
_, return_code = util.run_cmd(cmd, env, logger=log)
106+
assert return_code == 0, log
99107

100108
target_file = os.path.join(target_dir, "hello")
101109
cmd = [graalpy, "-m", "standalone", "--verbose", "native", "-ce", "-Os", "-m", source_file, "--venv", venv_dir, "-o", target_file]
102-
out, return_code = util.run_cmd(cmd, env)
103-
util.check_ouput("Bundling Python resources into", out)
104-
util.check_ouput("Finished generating 'hello' in", out)
110+
out, return_code = util.run_cmd(cmd, env, logger=log)
111+
assert return_code == 0, log
112+
util.check_ouput("Bundling Python resources into", out, logger=log)
113+
util.check_ouput("Finished generating 'hello' in", out, logger=log)
105114

106115
cmd = [target_file]
107-
out, return_code = util.run_cmd(cmd, env)
108-
util.check_ouput("hello standalone world", out)
109-
util.check_ouput("key=value", out)
116+
out, return_code = util.run_cmd(cmd, env, logger=log)
117+
assert return_code == 0, log
118+
util.check_ouput("hello standalone world", out, logger=log)
119+
util.check_ouput("key=value", out, logger=log)
110120

111121
@unittest.skipUnless(is_enabled, "ENABLE_STANDALONE_UNITTESTS is not true")
112122
def test_native_executable_module():
@@ -131,12 +141,16 @@ def test_native_executable_module():
131141
f.write("import hello\n")
132142
f.write("hello.print_hello()\n")
133143

144+
log = util.Logger()
145+
134146
target_file = os.path.join(tmp_dir, "hello")
135147
cmd = [graalpy, "-m", "standalone", "--verbose", "native", "-ce", "-Os", "-m", module_dir, "-o", target_file]
136-
out, return_code = util.run_cmd(cmd, env)
137-
util.check_ouput("Bundling Python resources into", out)
138-
util.check_ouput("Finished generating 'hello' in", out)
148+
out, return_code = util.run_cmd(cmd, env, logger=log)
149+
assert return_code == 0, log
150+
util.check_ouput("Bundling Python resources into", out, logger=log)
151+
util.check_ouput("Finished generating 'hello' in", out, logger=log)
139152

140153
cmd = [target_file]
141-
out, return_code = util.run_cmd(cmd, env)
142-
util.check_ouput("hello standalone world", out)
154+
out, return_code = util.run_cmd(cmd, env, logger=log)
155+
assert return_code == 0, log
156+
util.check_ouput("hello standalone world", out, logger=log)

0 commit comments

Comments
 (0)