fix windows test failures related to temp file creation by ODK Validate #541
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves Windows test failure issue mentioned in #540
The error says something like "Access denied" (examples below) when ODK Validate tries to create a temp file for the purpose of processing external CSV references. The Java traceback refers to a CreateTempFile call in validate/StubReference. Test failures were constrained to those in
pyxform/tests_v1/test_external_instances_for_selects.py
.Side notes: the temp file created by ODK Validate does not seem to be deleted on exit. Presumably it gets cleaned up by the OS when a user reboots or does a disk clean. Also, because of the ODK Validate error cleaning in pyxform, it wasn't obvious what the problem was, since the cleaning removes Java traceback info.
Example of the error a user sees
Example full traceback
Why is this the best possible solution? Were any other approaches considered?
Not actually sure why this works, but I have seen issues before (other projects) where not passing in certain magic env vars to a python subprocess call results in bugs or errors. Another approach is to tell Java about the temp directory with the launch argument
-Djava.io.tmpdir=C:/WINDOWS/Temp
.It might be that if Java doesn't know about the temp directory at startup, it doesn't give itself adequate permissions to create files there. Maybe there is then some fall-back logic later on in CreateTempFile that tries to write to the
C:/WINDOWS/Temp
if the tmpdir isn't set and then that fails.What are the regression risks?
Probably none. The fix is in a code branch that is Windows-specific (
os.name == "nt"
). If it causes an issue for users, they could try setting one ofTMP
,TEMP
orTMPDIR
environment variables before launching pyxform. However, in normal circumstances these variables are already set.Does this change require updates to documentation? If so, please file an issue here and include the link below.
I would only mention it in the docs if there is a report of this causing an issue for users. It is a bit obscure.
Before submitting this PR, please make sure you have:
tests_v1
nosetests
and verified all tests passblack pyxform
to format code