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

Fix #5076 - /tmp/xmlvalidation directories not cleaned up for factory methods bclXMLValidator & gbxmlValidator #5079

Merged
merged 2 commits into from
Jan 16, 2024

Conversation

jmarrec
Copy link
Collaborator

@jmarrec jmarrec commented Jan 16, 2024

Pull request overview

Pull Request Author

  • Model API Changes / Additions
  • Any new or modified fields have been implemented in the EnergyPlus ForwardTranslator (and ReverseTranslator as appropriate)
  • Model API methods are tested (in src/model/test)
  • EnergyPlus ForwardTranslator Tests (in src/energyplus/Test)
  • If a new object or method, added a test in NREL/OpenStudio-resources: Add Link
  • If needed, added VersionTranslation rules for the objects (src/osversion/VersionTranslator.cpp)
  • Verified that C# bindings built fine on Windows, partial classes used as needed, etc.
  • All new and existing tests passes
  • If methods have been deprecated, update rest of code to use the new methods

Labels:

  • If change to an IDD file, add the label IDDChange
  • If breaking existing API, add the label APIChange
  • If deemed ready, add label Pull Request - Ready for CI so that CI builds your PR

Review Checklist

This will not be exhaustively relevant to every PR.

  • Perform a Code Review on GitHub
  • Code Style, strip trailing whitespace, etc.
  • All related changes have been implemented: model changes, model tests, FT changes, FT tests, VersionTranslation, OS App
  • Labeling is ok
  • If defect, verify by running develop branch and reproducing defect, then running PR and reproducing fix
  • If feature, test running new feature, try creative ways to break it
  • CI status: all green or justified

@jmarrec jmarrec added component - Utilities Other Pull Request - Ready for CI This pull request if finalized and is ready for continuous integration verification prior to merge. labels Jan 16, 2024
@jmarrec jmarrec self-assigned this Jan 16, 2024
@jmarrec jmarrec force-pushed the 5076-Fix-static-XMLValidator-factories-temp-dir branch from 3d93ea5 to c103518 Compare January 16, 2024 16:03
@jmarrec
Copy link
Collaborator Author

jmarrec commented Jan 16, 2024

Ok tests fail before fix, work with fix

Before:

[==========] Running 1 test from 1 test suite.
[----------] Global test environment set-up.
[----------] 1 test from XMLValidatorFixture
[ RUN      ] XMLValidatorFixture.XMLValidator_bclXMLValidator_Cleanup
/Users/julien/Software/Others/OpenStudio2/src/utilities/xml/Test/XMLValidator_GTest.cpp:171: Failure
Value of: openstudio::filesystem::exists(tmpDir)
  Actual: true
Expected: false
Expected tmpDir to be deleted: "/var/folders/bz/sgrc10ls2d9fz7418xw3wgym0000gn/T/xmlvalidation-fac0-5db6-68ba-39e5-1705421114-0"
[  FAILED  ] XMLValidatorFixture.XMLValidator_bclXMLValidator_Cleanup (0 ms)
[----------] 1 test from XMLValidatorFixture (0 ms total)

[----------] Global test environment tear-down
[==========] 1 test from 1 test suite ran. (1 ms total)
[  PASSED  ] 0 tests.
[  FAILED  ] 1 test, listed below:
[  FAILED  ] XMLValidatorFixture.XMLValidator_bclXMLValidator_Cleanup

 1 FAILED TEST

    Start 185: XMLValidatorFixture.XMLValidator_gbxmlValidator_Cleanup
2/2 Test #185: XMLValidatorFixture.XMLValidator_gbxmlValidator_Cleanup ....***Failed    0.01 sec
Running main() from /Users/julien/.conan/data/gtest/1.11.0/_/_/build/dbd8bc9563b5a1f4052cc1968e26d22031450443/source_subfolder/googletest/src/gtest_main.cc
Note: Google Test filter = XMLValidatorFixture.XMLValidator_gbxmlValidator_Cleanup
[==========] Running 1 test from 1 test suite.
[----------] Global test environment set-up.
[----------] 1 test from XMLValidatorFixture
[ RUN      ] XMLValidatorFixture.XMLValidator_gbxmlValidator_Cleanup
/Users/julien/Software/Others/OpenStudio2/src/utilities/xml/Test/XMLValidator_GTest.cpp:183: Failure
Value of: openstudio::filesystem::exists(tmpDir)
  Actual: true
Expected: false
Expected tmpDir to be deleted: "/var/folders/bz/sgrc10ls2d9fz7418xw3wgym0000gn/T/xmlvalidation-6495-53c1-ddfb-bb6b-1705421114-0"
[  FAILED  ] XMLValidatorFixture.XMLValidator_gbxmlValidator_Cleanup (1 ms)
[----------] 1 test from XMLValidatorFixture (1 ms total)

[----------] Global test environment tear-down
[==========] 1 test from 1 test suite ran. (1 ms total)
[  PASSED  ] 0 tests.
[  FAILED  ] 1 test, listed below:
[  FAILED  ] XMLValidatorFixture.XMLValidator_gbxmlValidator_Cleanup

 1 FAILED TEST


0% tests passed, 2 tests failed out of 2

Total Test time (real) =   0.14 sec

The following tests FAILED:
        184 - XMLValidatorFixture.XMLValidator_bclXMLValidator_Cleanup (Failed)
        185 - XMLValidatorFixture.XMLValidator_gbxmlValidator_Cleanup (Failed)

Copy link
Contributor

@kbenne kbenne left a comment

Choose a reason for hiding this comment

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

It fixes the issue so I support this, but maybe we could rethink the interface a little bit.

@@ -478,7 +478,9 @@ XMLValidator XMLValidator::gbxmlValidator() {
}
const bool quiet = true;
::openstudio::embedded_files::extractFile(":/xml/resources/GreenBuildingXML_Ver7.03.xsd", openstudio::toString(tmpDir), quiet);
return XMLValidator(tmpDir / "GreenBuildingXML_Ver7.03.xsd");
auto validator = XMLValidator(tmpDir / "GreenBuildingXML_Ver7.03.xsd");
validator.m_tempDir = tmpDir;
Copy link
Contributor

Choose a reason for hiding this comment

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

It feels awkward and potentially error prone to need to make this assignment. Maybe we could use a temp directory class like Spawn uses https://github.com/NREL/Spawn/blob/develop/util/temp_directory.hpp and perhaps also move the construction of the temp directory into the construction of the XMLValidator. I understand there might be cases where you don't want XMLValidator to use a temp directory, but perhaps if that is a requirement we could design on overload or something.

@jmarrec jmarrec merged commit 777fba9 into develop Jan 16, 2024
4 of 6 checks passed
@jmarrec jmarrec deleted the 5076-Fix-static-XMLValidator-factories-temp-dir branch January 16, 2024 19:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component - Utilities Other Pull Request - Ready for CI This pull request if finalized and is ready for continuous integration verification prior to merge.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

/tmp/xmlvalidation directories
5 participants