NREL / EnergyPlus

EnergyPlus™ is a whole building energy simulation program that engineers, architects, and researchers use to model both energy consumption and water use in buildings.
https://energyplus.net
Other
1.13k stars 389 forks source link

Spurious unit test failure #10197

Closed Myoldmopar closed 1 year ago

Myoldmopar commented 1 year ago

Issue overview

There is an occasional unit test failure like this, where it is complaining it can't operate on {build_folder}/tst/EnergyPlus/unit/in.epw because it is in use. I think the problem comes down to some code around this line, where it is trying to setup the in.idf and in.epw for CLI testing. I guess if you run things in a bunch of threads, they can stomp on each other. Could we give each individual test its own IDF/EPW so there is no conflict?

What's even weirder is that it's like the unit test....passes...but also doesn't? I feel like it is getting the exception raised, which signals the test failed, but because the file already exists from a different test, it goes ahead and passes. Here's the output from that link:

Note: Google Test filter = CommandLineInterfaceFixture.IdfOnly
[==========] Running 1 test from 1 test suite.
[----------] Global test environment set-up.
[----------] 1 test from CommandLineInterfaceFixture
unknown file: error: C++ exception with description "copy_file: The process cannot access the file because it is being used by another process.: "C:/ci/runs/clone_branch\weather/USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw", "C:\ci\runs\clone_branch\build\tst\EnergyPlus\unit\in.epw"" thrown in SetUpTestSuite().
[ RUN ] CommandLineInterfaceFixture.IdfOnly
[ OK ] CommandLineInterfaceFixture.IdfOnly (362 ms)
[----------] 1 test from CommandLineInterfaceFixture (362 ms total)

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

0 FAILED TESTS
[ FAILED ] CommandLineInterfaceFixture: SetUpTestSuite or TearDownTestSuite

1 FAILED TEST SUITE

What do you think @jmarrec ?

jmarrec commented 1 year ago

@Myoldmopar sorry about that. I think it may work by checking if the file exists first before trying to copy.

But the safest thing is to just move the copy operation inside cmake via file(COPY) / configure_file(COPYONLY), so it's done once at cmake generation time. Edit: Depending on whether you run via ctest or via the exe directly, the current directory isn't the same though...

And yes, the C++ exception happens in SetupTestCase. The Test passes, the Suite fails.