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.
2
2
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3
3
#
4
4
# The Universal Permissive License (UPL), Version 1.0
@@ -60,16 +60,20 @@ def test_native_executable_one_file():
60
60
f .write ("import sys\n " )
61
61
f .write ("print('hello world, argv[1:]:', sys.argv[1:])" )
62
62
63
+ log = util .Logger ()
64
+
63
65
target_file = os .path .join (tmpdir , "hello" )
64
66
cmd = [graalpy , "-m" , "standalone" , "--verbose" , "native" , "-ce" , "-m" , source_file , "-o" , target_file ]
65
67
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 )
69
72
70
73
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 )
73
77
74
78
@unittest .skipUnless (is_enabled , "ENABLE_STANDALONE_UNITTESTS is not true" )
75
79
def test_native_executable_venv_and_one_file ():
@@ -89,24 +93,30 @@ def test_native_executable_venv_and_one_file():
89
93
f .write ('d = ujson.loads("""{"key": "value"}""")\n ' )
90
94
f .write ("print('key=' + d['key'])\n " )
91
95
96
+ log = util .Logger ()
97
+
92
98
venv_dir = os .path .join (target_dir , "venv" )
93
99
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
95
102
96
103
venv_python = os .path .join (venv_dir , "Scripts" , "python.exe" ) if os .name == "nt" else os .path .join (venv_dir , "bin" , "python" )
97
104
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
99
107
100
108
target_file = os .path .join (target_dir , "hello" )
101
109
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 )
105
114
106
115
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 )
110
120
111
121
@unittest .skipUnless (is_enabled , "ENABLE_STANDALONE_UNITTESTS is not true" )
112
122
def test_native_executable_module ():
@@ -131,12 +141,16 @@ def test_native_executable_module():
131
141
f .write ("import hello\n " )
132
142
f .write ("hello.print_hello()\n " )
133
143
144
+ log = util .Logger ()
145
+
134
146
target_file = os .path .join (tmp_dir , "hello" )
135
147
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 )
139
152
140
153
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