ILXL / ILXL/cppaudit

Macros to execute compiled program don't force it to quit when test exits

Open
#40 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
1
Forks
1
PR merge metrics
No merged PRs in 30d

Description

If main has an infinite loop, it'll just keep running as a process in the background even after the test has failed.

This became obvious in Paint Milestone 4 tests when a window was displayed. Here's how I solved it (although in this case I was looking for a timeout):

TEST(PaintProgramTest, StartShowsImage) {
std::chrono::time_point start, end;
start = std::chrono::system_clock::now();
system("timeout 1s ./main");
end = std::chrono::system_clock::now();
std::chrono::duration elapsed_seconds = end - start;
std::chrono::milliseconds ms =
std::chrono::duration_cast(elapsed_seconds);
if (ms.count() <= 900) {
FAIL() << " main() should call PaintProgram::Start() which calls "
"Image::ShowUntilClosed().";
}
}

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by locating the test macros that execute compiled programs and the TEST case shown in the report. Reproduce the failure with a program whose main has an infinite loop, then inspect how the macro launches and observes that process. Done means a failed or exiting test does not leave the compiled program running in the background.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
testing-qa
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.