Skip to content

Commit 285c255

Browse files
committed
differantiate if options allow shared engine and preinitialized context and log more in tests
1 parent c05f2f7 commit 285c255

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/PythonLanguage.java

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -157,21 +157,26 @@ protected void finalizeContext(PythonContext context) {
157157

158158
@Override
159159
protected boolean areOptionsCompatible(OptionValues firstOptions, OptionValues newOptions) {
160-
// Buffered IO was applied during context initialization
161-
return (firstOptions.get(PythonOptions.UnbufferedIO).equals(newOptions.get(PythonOptions.UnbufferedIO)) &&
162-
// internal sources were marked during context initialization
163-
firstOptions.get(PythonOptions.ExposeInternalSources).equals(newOptions.get(PythonOptions.ExposeInternalSources)) &&
160+
// internal sources were marked during context initialization
161+
return (firstOptions.get(PythonOptions.ExposeInternalSources).equals(newOptions.get(PythonOptions.ExposeInternalSources)) &&
164162
// we cache CatchAllExceptions hard on TryExceptNode
165-
firstOptions.get(PythonOptions.CatchAllExceptions).equals(newOptions.get(PythonOptions.CatchAllExceptions)) &&
166-
// we statically cache WithThread in SysConfigModuleBuiltins
163+
firstOptions.get(PythonOptions.CatchAllExceptions).equals(newOptions.get(PythonOptions.CatchAllExceptions)));
164+
}
165+
166+
private boolean areOptionsCompatibleWithPreinitializedContext(OptionValues firstOptions, OptionValues newOptions) {
167+
// Buffered IO was applied during context initialization
168+
return (areOptionsCompatible(firstOptions, newOptions) &&
169+
firstOptions.get(PythonOptions.UnbufferedIO).equals(newOptions.get(PythonOptions.UnbufferedIO)) &&
170+
// we cache WithThread in SysConfigModuleBuiltins
167171
firstOptions.get(PythonOptions.WithThread).equals(newOptions.get(PythonOptions.WithThread)) &&
168172
// disabling TRegex has an effect on the _sre Python code that is created
169173
firstOptions.get(PythonOptions.WithTRegex).equals(newOptions.get(PythonOptions.WithTRegex)));
170174
}
171175

172176
@Override
173177
protected boolean patchContext(PythonContext context, Env newEnv) {
174-
if (!areOptionsCompatible(context.getEnv().getOptions(), newEnv.getOptions())) {
178+
if (!areOptionsCompatibleWithPreinitializedContext(context.getEnv().getOptions(), newEnv.getOptions())) {
179+
PythonCore.writeInfo("Cannot use preinitialized context.");
175180
return false;
176181
}
177182
ensureHomeInOptions(newEnv);

mx.graalpython/mx_graalpython.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -389,22 +389,22 @@ def graalpython_gate_runner(args, tasks):
389389
svm_image = python_svm(["--version"])
390390
benchmark = os.path.join(PATH_MESO, "image-magix.py")
391391
out = mx.OutputCapture()
392-
mx.run([svm_image, benchmark], nonZeroIsFatal=True, out=mx.TeeOutputCapture(out))
392+
mx.run([svm_image, "-v", "-S", "--log.python.level=FINEST", benchmark], nonZeroIsFatal=True, out=mx.TeeOutputCapture(out))
393393
success = "\n".join([
394394
"[0, 0, 0, 0, 0, 0, 10, 10, 10, 0, 0, 10, 3, 10, 0, 0, 10, 10, 10, 0, 0, 0, 0, 0, 0]",
395395
])
396396
if success not in out.data:
397397
mx.abort('Output from generated SVM image "' + svm_image + '" did not match success pattern:\n' + success)
398398
# Test that stdlib paths are not cached on packages
399399
out = mx.OutputCapture()
400-
mx.run([svm_image, "-S", "--python.StdLibHome=/foobar", "-c", "import encodings; print(encodings.__path__)"], out=mx.TeeOutputCapture(out))
400+
mx.run([svm_image, "-v", "-S", "--log.python.level=FINEST", "--python.StdLibHome=/foobar", "-c", "import encodings; print(encodings.__path__)"], out=mx.TeeOutputCapture(out))
401401
if "/foobar" not in out.data:
402-
mx.abort('Output from generated SVM image "' + svm_image + '" did not have patched std lib path "/foobar", got:\n' + out.data)
402+
mx.abort('Output from generated SVM image "' + svm_image + '" did not have patched std lib path "/foobar"')
403403
# Test that stdlib paths are not cached on modules
404404
out = mx.OutputCapture()
405-
mx.run([svm_image, "-S", "--python.StdLibHome=/foobar", "-c", "import encodings; print(encodings.__file__)"], out=mx.TeeOutputCapture(out))
405+
mx.run([svm_image, "-v", "-S", "--log.python.level=FINEST", "--python.StdLibHome=/foobar", "-c", "import encodings; print(encodings.__file__)"], out=mx.TeeOutputCapture(out))
406406
if "/foobar" not in out.data:
407-
mx.abort('Output from generated SVM image "' + svm_image + '" did not have patched std lib path "/foobar", got:\n' + out.data)
407+
mx.abort('Output from generated SVM image "' + svm_image + '" did not have patched std lib path "/foobar"')
408408
# Finally, test that we can start even if the graalvm was moved
409409
out = mx.OutputCapture()
410410
graalvm_home = svm_image.replace(os.path.sep.join(["", "bin", "graalpython"]), "")

0 commit comments

Comments
 (0)