Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[testing] output failed diffs (image or text) to a common dir #1839

Merged

Conversation

pmolodo
Copy link
Contributor

@pmolodo pmolodo commented Apr 20, 2022

Description of Change(s)

Diagnosing issues with failed diffs (particularly image diffs) can be
difficult because the generated output files are in a randomly named
temporary directory, which can be difficult to locate.

With this change, for each failed diff, these files are created:

${CMAKE_BINARY_DIR}/Testing/Failed-Diffs/${TEST_NAME}/${filename}.result.${ext}
${CMAKE_BINARY_DIR}/Testing/Failed-Diffs/${TEST_NAME}/${filename}.baseline.${ext}
  • I have submitted a signed Contributor License Agreement

@jilliene
Copy link

Filed as internal issue #USD-7338

Copy link
Contributor

@tallytalwar tallytalwar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @pmolodo for the PR.

This generally looks fine to us. Could you please address few notes I am posting here from our internal review?

We also feel it will make sense to augment BUILDING.md to mention about where outputs from failed tests will be written.

@@ -24,6 +24,9 @@
option(PXR_STRICT_BUILD_MODE "Turn on additional warnings. Enforce all warnings as errors." OFF)
option(PXR_VALIDATE_GENERATED_CODE "Validate script generated code" OFF)
option(PXR_HEADLESS_TEST_MODE "Disallow GUI based tests, useful for running under headless CI systems." OFF)
option(PXR_OUTPUT_FAILED_TEST_DIFFS
"Copy failed diff/image diff tests into \${CMAKE_BINARY_DIR}/Testing/Failed-Diffs/<PXR_CTEST_RUN_ID>/\${TEST_NAME}. <PXR_CTEST_RUN_ID> is automatically set per ctest-invocation, or read from an environment variable of the same name if set."
OFF)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a particular reason we wouldn't want to have this on all the time? We think it make sense to turn this on all the time for simplicity?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I'm all for that! The only argument against having it on by default is the it means the build directory might grow over time - each test run with a failed image diff will result in a new directory in ${CMAKE_BINARY_DIR}/Testing/Failed-Diffs. However, that's no different (and much less than) the filesystem usage growth that already occurs in the temp directories (it's just more easily visible / discoverable). But I think the pros outweigh the cons - ideally you won't have failed tests too often, and only more "advanced" users are probably running the tests a lot anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

os.makedirs(failuresDir)

shutil.copy(baselineFile, baselineOutpath)
shutil.copy(resultFile, resultOutpath)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sunya noticed that it WBN to print out some kind of message here saying where the diff results are being copied to. That way someone looking at the test output can see the exact path they need to go to to look for more info.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Absolutely, will do!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -379,9 +408,14 @@ def _runCommand(raw_command, stdout_redir, stderr_redir, env,

# If desired, diff the provided file(s) (must be generated by the test somehow)
# with a file of the same name in the baseline directory
failuresDir = None
if args.failures_dir:
failuresDir = args.failures_dir.replace('<PXR_CTEST_RUN_ID>',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If PXR_CTEST_RUN_ID isn't set in the environment this will generate an invalid path with "<", ">" in it. It was recommended to just drop "<", ">"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Diagnosing issues with failed diffs (particularly image diffs) can be
difficult because the generated output files are in a randomly named
temporary directory, which can be difficult to locate.

With this change, for each failed diff, these files are created:

${CMAKE_BINARY_DIR}/Testing/Failed-Diffs/${TEST_NAME}/${filename}.result.${ext}
${CMAKE_BINARY_DIR}/Testing/Failed-Diffs/${TEST_NAME}/${filename}.baseline.${ext}
pmolodo added a commit to pmolodo/OpenUSD that referenced this pull request Jun 15, 2022
@pmolodo
Copy link
Contributor Author

pmolodo commented Jun 15, 2022

Responded to the code review notes, and pushed. To see just the incremental changes, look here:

pmolodo@53df647

@pixar-oss pixar-oss merged commit dd208d3 into PixarAnimationStudios:dev Jun 25, 2022
@pmolodo pmolodo deleted the pr/failed_diff_output_dir branch August 9, 2023 18:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants