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

HPWH Equipment Sequence Number Error to Warning #5124

Merged
merged 18 commits into from Sep 9, 2015

Conversation

nmerket
Copy link
Member

@nmerket nmerket commented Aug 19, 2015

fixes #4695

Todo:

  • Unit test

@nmerket nmerket self-assigned this Aug 19, 2015
@nmerket
Copy link
Member Author

nmerket commented Aug 19, 2015

Okay, I know I'm asking something that is sacrilege around here, but can I not do a unit test for this? The only change was to alter the text of an error message so it is more clear and turn that error into a warning. I'm not sure adding a unit test adds value here.
@Myoldmopar @mbadams5

@nmerket
Copy link
Member Author

nmerket commented Aug 20, 2015

@Myoldmopar you never answered my question: Is this okay without a unit test?

@Myoldmopar
Copy link
Member

So....it is quite fair to say that if it is literally just a typo in a string or such that it does not need a unit test. Your change does slightly more than that though. You don't trip the ErrorsFound flag anymore, which does change the functionality of the program, not just the error message. So, in general, I would say that this does require a unit test to verify that.

How about changing that function from a void to a bool. Then at the end of the function, just return the value of ErrorsFound. This shouldn't interfere with other callers of the function, since they would have been expecting a void, and it can verify that with prescribed inputs, that function does pass through successfully now.

(hindsight) From a test-driven development perspective, it probably would have been wise to change the function to a bool return first, set up the unit test to call that function, and given the those inputs, the test would have failed with a false return value. Then with your fix, you get the unit test to pass with a true return value. That sounds ideal. 😉

@nmerket
Copy link
Member Author

nmerket commented Aug 20, 2015

@Myoldmopar Right, it is a little backwards for test driven development. Sorry. The problem is that if ErrorsFound == true, then GetWaterThermalTankInput dies before completing. So, either it returns false if everything went okay or it dies by way of ShowFatalError, there is no way to get a true return value from that function without refactoring things even more.

@Myoldmopar
Copy link
Member

Inside GetWaterThermalTankInput:

return ErrorsFound;

Inside your unit test:

expect_false(GetWaterThermalTankInput());

Right?

@Myoldmopar
Copy link
Member

Because then you could also test expected failures in input processing just by providing the bad input idf snippet and using expect_true.

@nmerket
Copy link
Member Author

nmerket commented Aug 20, 2015

The problem is it does this several times in GetWaterThermalTankInput before it's done. To make that work, I'd have to change all of those to return true; and then any time GetWaterThermalTankInput is called look for that and throw a fatal error if it's true.

@Myoldmopar
Copy link
Member

OK, fair. So we won't try to trap for the bad cases anytime soon. But you should be able to check for a successful run with the expect_false I mentioned before. If you give it valid inputs, and get input processes it successfully, the code makes it all the way through the function, so it will return a false value of ErrorsFound.

@nmerket
Copy link
Member Author

nmerket commented Aug 20, 2015

Okay. I'll take a crack at a unit test then.

@Myoldmopar
Copy link
Member

Thanks @nmerket. If it was literally just the string change, it would be easier to justify. But it shouldn't take long to set this unit test up. Just the idf snippet, process_idf, and expect_false.

EXPECT_FALSE( WaterThermalTanks::GetWaterThermalTankInput() );
}

TEST_F( HVACFixture, HPWHWrappedDummyNodeConfig )
Copy link
Member Author

Choose a reason for hiding this comment

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

Merging in this other unit test from develop caused me some problems. It's failing now because the state isn't being cleared for water heaters. @EnergyArchmage is there a implementation of clear_state for WaterThermalTanks in that branch you're maintaining? I would have looked myself, but @Myoldmopar didn't mention the branch name in the email so I thought it would be easier to just ask you.

@nmerket
Copy link
Member Author

nmerket commented Aug 21, 2015

@Myoldmopar @mbadams5 The unit test I wrote for this works, but it's not reading the error message to make sure it comes out right. I tried for a bit to create another test fixture that combined HVACFixture and SQLiteFixture using multiple inheritance, but it fell apart quickly, so I abandoned the effort. Hope that's okay.

@Myoldmopar Myoldmopar added the Defect Includes code to repair a defect in EnergyPlus label Aug 25, 2015
@nmerket
Copy link
Member Author

nmerket commented Aug 28, 2015

I think this is ready. It's been like whack-a-mole for something that should have been really simple. In my debug build in Xcode, energyplus_test runs fine. However, when I do a release build on my mac with makefiles, it segfaults at HVACFixture.VRFTest. Maybe I need to run cmake again. Either way. I'm hoping the CI machines catch it if there's something wrong.
@mbadams5 Can you check this out and make sure I didn't do something really stupid?

@nmerket
Copy link
Member Author

nmerket commented Aug 28, 2015

Okay, I just re-ran cmake on my xcode build and it picked up that test. It's an array out of bounds assertion error.
Wait a minute. The HVACFixture.VRFTest is causing the same error on develop too. This isn't my fault! Yay!
@Myoldmopar @mbadams5

@mjwitte
Copy link
Contributor

mjwitte commented Aug 28, 2015

@nmerket Interesting. That test HVACFixture.VRFTest was passing over in #5135
FYI @EnergyArchmage @rraustad

@rraustad
Copy link
Contributor

There are still issues with clear_state in some modules. Working on it, but it's a snails pace.

@nmerket
Copy link
Member Author

nmerket commented Aug 28, 2015

@mjwitte @rraustad Yeah, as you can see the CI machines don't seem to catch this, but when I run energyplus_tests on a clean build of develop I hit it.

[ RUN      ] mHVACFixture.VRFTest
Assertion failed: (contains( i )), function operator(), file /Users/nmerket/energyplus/gitrepo/third_party/ObjexxFCL/src/ObjexxFCL/Array1.hh, line 1236.

@mjwitte
Copy link
Contributor

mjwitte commented Aug 28, 2015

@nmerket The CI machines run the tests individually that's why it's different. When you energyplus_tests is runs them serially, so that's why it can turn out differently. If you filter just that test it will probably run OK on your local machine. --gtest_filter=*VRFTest

@nmerket
Copy link
Member Author

nmerket commented Aug 28, 2015

So, if that's the requirement--each test can be run individually, but not necessarily all together--then this is good to go pending a favorable CI result.

…95_hpwh_equip_seq_num

Conflicts:
	tst/EnergyPlus/unit/WaterThermalTanks.unit.cc
@mbadams5
Copy link
Contributor

@nmerket I just updated this also with some more changes.

As an aside, you can remove tests from the local testing using --gtest_filter

energyplus_tests --gtest_filter=-*VRFTest*

That will run all tests except ones that match *VRFTest*. The - is the key part.

@nmerket
Copy link
Member Author

nmerket commented Aug 28, 2015

@mbadams5 Thank you for figuring out the clear_state mess. I guess I did comment out that VRFTest, sorry.

@mbadams5
Copy link
Contributor

@nmerket The VRFTest still fails for me locally, but I don't think that is due to this branch.

@nmerket
Copy link
Member Author

nmerket commented Sep 2, 2015

Just merged develop back into this branch and did some clean up. Unit tests are all working. Should be ready to merge. @Myoldmopar do I change the assignee to you?

@Myoldmopar
Copy link
Member

Feel free to; I'll take a look with the other bugs after the new features are wrapped up this week.

@nmerket nmerket assigned Myoldmopar and unassigned nmerket Sep 2, 2015
…equip_seq_num

Conflicts:
	tst/EnergyPlus/unit/Fixtures/EnergyPlusFixture.cc
	tst/EnergyPlus/unit/Fixtures/HVACFixture.hh
@mjwitte
Copy link
Contributor

mjwitte commented Sep 8, 2015

@nmerket I've merged in develop, resolved conflicts, then fixed a couple of things. Not sure if git got confused or I just didn't to the conflict resolution correctly. In any case, please review the diffs to be sure it looks correct. If CI comes back OK, then this can go in.

@mjwitte
Copy link
Contributor

mjwitte commented Sep 8, 2015

@nmerket I already see some mistakes - will update one more time.

@mjwitte
Copy link
Contributor

mjwitte commented Sep 8, 2015

@nmerket That's better. Now ready for your review.

@nmerket
Copy link
Member Author

nmerket commented Sep 9, 2015

@mjwitte Looks good to me. Should I press the big, green button or should you? Or should @Myoldmopar? I never know the protocol.

@mjwitte
Copy link
Contributor

mjwitte commented Sep 9, 2015

@nmerket I will. It's considered bad form to merge your own pull request. One rare occasions, maybe.

mjwitte added a commit that referenced this pull request Sep 9, 2015
HPWH Equipment Sequence Number Error to Warning
@mjwitte mjwitte merged commit 4ecbf49 into develop Sep 9, 2015
@mjwitte mjwitte deleted the 4695_hpwh_equip_seq_num branch September 9, 2015 19:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Defect Includes code to repair a defect in EnergyPlus
Projects
None yet
Development

Successfully merging this pull request may close these issues.

WaterHeater:HeatPump misleading error message about priority
6 participants