Skip to content

Build out scaffolds for future unit tests#9506

Merged
dareumnam merged 14 commits intodevelopfrom
IncreaseUnitTestCoverage
Jun 30, 2022
Merged

Build out scaffolds for future unit tests#9506
dareumnam merged 14 commits intodevelopfrom
IncreaseUnitTestCoverage

Conversation

@Myoldmopar
Copy link
Member

Pull request overview

One of the burdens to improving unit test coverage is that there is a (sometimes quite large) initial effort to create the basic unit test scaffold for a source file or class. This PR simply builds out some scaffolds for files that have zero or minimal unit test coverage, to allow for higher test coverage to be added and the objects to be tested more thoroughly with minimal effort. Some other cleanups happened along the way, including removing the unused internal timing calculations. Note that the EnergyPlus elapsed time is still kept, just moved to UtilityRoutines. And the internal function call counting is still left in place for now.

@Myoldmopar Myoldmopar added the DoNotPublish Includes changes that shouldn't be reported in the changelog label Jun 24, 2022
@Myoldmopar
Copy link
Member Author

Windows CI failure is because it couldn't delete a temporary file, nothing to do with this. Linux release CI is the unrelated solar shading GPU diff. CI is fully happy here.

Copy link
Member Author

@Myoldmopar Myoldmopar left a comment

Choose a reason for hiding this comment

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

OK, this PR is hopefully ready to go in. It is not making functional changes, just scaffolding out and fleshing out unit tests for source files which were especially desperate for unit test coverage.

DataSurfaces.hh
DataSystemVariables.cc
DataSystemVariables.hh
DataTimings.cc
Copy link
Member Author

Choose a reason for hiding this comment

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

Removed the internal timing sampling code -- left the elapsed time calculation as-is, for now. There is an opportunity to strip out some more Objexx and use c++ chrono built in to do that calculation instead, but I left that for later.

build_type: Debug
cmake_extra_flags: -DLINK_WITH_PYTHON:BOOL=ON -DPython_REQUIRED_VERSION:STRING=3.8 -DPython_ROOT_DIR:PATH=~/.pyenv/versions/3.8.12/ -DBUILD_FORTRAN:BOOL=ON -DBUILD_TESTING:BOOL=ON -DENABLE_REGRESSION_TESTING:BOOL=OFF -DCOMMIT_SHA:STRING=$COMMIT_SHA -DENABLE_COVERAGE:BOOL=ON -DENABLE_GTEST_DEBUG_MODE:BOOL=OFF -DENABLE_PCH:BOOL=OFF
coverage_enabled: truec
coverage_enabled: true
Copy link
Member Author

Choose a reason for hiding this comment

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

Typo fix.

const char *fluidNameSteam = "STEAM";

PlantComponent *BoilerSpecs::factory(EnergyPlusData &state, std::string const &objectName)
BoilerSpecs *BoilerSpecs::factory(EnergyPlusData &state, std::string const &objectName)
Copy link
Member Author

Choose a reason for hiding this comment

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

The factory methods should return the concrete type. The plant structure will store a PlantComponent*, but this conversion should happen when the conversion is needed, not as this function exits. By returning the concrete type, a caller of the factory can use the concrete type without requiring a cast back to the concrete type. This has no functional effect on EnergyPlus itself.

ThermalEN673Calc.hh
ThermalISO15099Calc.cc
ThermalISO15099Calc.hh
Timer.h
Copy link
Member Author

Choose a reason for hiding this comment

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

Removed the internal timing stuff per some discussion here: #9468. Note that this does not affect the user-facing runtime tracking that shows up in the output files. This is merely removing the compiler-define-dependent, manual, internal time tracking, that is not necessary given modern profiling tools.


PlantComponent *EvapFluidCoolerSpecs::factory(EnergyPlusData &state, DataPlant::PlantEquipmentType objectType, std::string const &objectName)
EvapFluidCoolerSpecs *
EvapFluidCoolerSpecs::factory(EnergyPlusData &state, DataPlant::PlantEquipmentType objectType, std::string const &objectName)
Copy link
Member Author

Choose a reason for hiding this comment

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

Again just return the concrete type pointer so that we can call the factory methods and get a meaningful return value rather than just a nebulous PlantComponent*.

return FuelTypeErrorsFound;
}

Real64 epElapsedTime()
Copy link
Member Author

Choose a reason for hiding this comment

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

Moved the epElapsedTime function to UtilityRoutines. I think this is worth a second pass to clean up the Objexx timing functions, which could lead to trimming down the Objexx library even further. But that would muddy this PR up, so that can just be 📌

}

void progressHandler(EnergyPlusState state, int const progress)
void progressHandler(int const progress)
Copy link
Member Author

Choose a reason for hiding this comment

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

Cleaned up this runtime test script, fixing some things along the way and adding test coverage for the runtime.cc file.

@@ -0,0 +1,101 @@
// EnergyPlus, Copyright (c) 1996-2022, The Board of Trustees of the University of Illinois,
Copy link
Member Author

Choose a reason for hiding this comment

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

Several new and fleshed out unit test files here. Note that the purpose of this PR is to scaffold out the unit tests, which should make it easier for developers to add targeted checks while they are doing normal development for defects and features.


namespace EnergyPlus {

TEST_F(EnergyPlusFixture, ExerciseBaseboardElectric)
Copy link
Member Author

Choose a reason for hiding this comment

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

Wherever possible I tried to avoid and/or minimize the IDF input strings in the unit test. Long term it would be amazing to just be able to operate on the objects themselves and not require input strings in the unit tests.

Copy link
Collaborator

@dareumnam dareumnam left a comment

Choose a reason for hiding this comment

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

This looks all great to me. I built it locally and ran tests successfully and CI is all happy here. This one looks fully clean and ready to go. I think this PR makes our life easier with unit testing. Thanks! @Myoldmopar

@dareumnam dareumnam merged commit 09f351d into develop Jun 30, 2022
@dareumnam dareumnam deleted the IncreaseUnitTestCoverage branch June 30, 2022 04:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

DoNotPublish Includes changes that shouldn't be reported in the changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants