Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ Please add only the labels required to work on your feature, in order to avoid u

F3D continuous integration will also check the coverage as it is a good way to evaluate if new features are being tested or not.
When adding code to F3D, always try to cover it by adding/modifying [tests](doc/dev/06-TESTING.md).
Only if no coverage is possible, use `// LCOV_EXCL_START` and `// LCOV_EXCL_STOP` comments to exclude unreachable lines,
and add another comment to explain why it cannot be reached by the coverage CI.

F3D continuous integration also checks formatting using clang-format and other tools and will inform you if changes needs to be made.
Some [formatting rules](doc/dev/09-CODING_STYLE.md) are not enforced by clang-format and will be checked during the review process.
Expand Down
14 changes: 10 additions & 4 deletions application/F3DStarter.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -337,12 +337,13 @@ class F3DStarter::F3DInternals
return F3DInternals::ParseStatefileContent(
stream, {}, outOptions, outFiles, outFileGroups, outWindowSize);
}
// LCOV_EXCL_START
catch (const f3d::engine::statefile_exception& ex)
{
// Unreachable in testing
f3d::log::error(ex.what());
return false;
}
// LCOV_EXCL_STOP
}

/* Add the app-specific `file_groups` entry (all file groups, including the ones not currently
Expand Down Expand Up @@ -2259,14 +2260,16 @@ void F3DStarter::SaveStatefile(const std::string& filenameTemplate)
std::optional<std::string> file = f3d::utils::getEnv("CTEST_SAVE_STATEFILE_DIALOG_FILE");
if (!file.has_value())
{
// Unreachable in testing
// We cannot test dialogs in the CI
// LCOV_EXCL_START
const char* pattern = "*.json";
char* ptr =
tinyfd_saveFileDialog("Save Statefile", "f3d_state.json", 1, &pattern, "Statefiles");
if (ptr)
{
file = ptr;
}
// LCOV_EXCL_STOP
}
if (file.has_value() && !file.value().empty())
{
Expand Down Expand Up @@ -2339,11 +2342,12 @@ void F3DStarter::SaveStatefileToClipboard()
state.toClipboard();
f3d::log::info("Statefile copied to the clipboard");
}
// LCOV_EXCL_START
catch (const f3d::engine::statefile_exception& ex)
{
// Unreachable in testing
f3d::log::error(ex.what());
}
// LCOV_EXCL_STOP
}

//----------------------------------------------------------------------------
Expand All @@ -2356,14 +2360,16 @@ void F3DStarter::LoadStatefile(const std::string& source)
std::optional<std::string> file = f3d::utils::getEnv("CTEST_LOAD_STATEFILE_DIALOG_FILE");
if (!file.has_value())
{
// Unreachable in testing
// We cannot test dialogs in the CI
// LCOV_EXCL_START
const char* pattern = "*.json";
char* ptr =
tinyfd_openFileDialog("Load Statefile", nullptr, 1, &pattern, "Statefiles", false);
if (ptr)
{
file = ptr;
}
// LCOV_EXCL_STOP
}
if (file.has_value() && !file.value().empty())
{
Expand Down
12 changes: 8 additions & 4 deletions library/src/engine.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -396,15 +396,17 @@ engine::state engine::state::fromClipboard()
{
if (!clip::get_text(content))
{
// Unreachable in testing
// LCOV_EXCL_START

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@noclone can you remind me why these lines couldn't be covered?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

it only happens in case of clipboard manager failure, which we can't produce in the CI

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

but it can fail in real use case?

throw engine::statefile_exception("Could not read a state from the clipboard");
// LCOV_EXCL_STOP
}
}
// LCOV_EXCL_START
catch (const clip::clip_exception& ex)
{
// Unreachable in testing
throw engine::statefile_exception(std::string("Could not use clip: ") + ex.what());
}
// LCOV_EXCL_STOP
return engine::state::fromString(content);
#else
throw engine::statefile_exception(
Expand Down Expand Up @@ -448,14 +450,16 @@ void engine::state::toClipboard() const
{
if (!clip::set_text(this->Content))
{
// Unreachable in testing
// LCOV_EXCL_START
throw engine::statefile_exception("Could not copy the state to the clipboard");
// LCOV_EXCL_STOP
}
}
catch (const clip::clip_exception& ex)
{
// Unreachable in testing
// LCOV_EXCL_START
throw engine::statefile_exception(std::string("Could not use clip: ") + ex.what());
// LCOV_EXCL_STOP
}

#else
Expand Down
6 changes: 4 additions & 2 deletions library/src/interactor_impl.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1361,11 +1361,12 @@ interactor& interactor_impl::initCommands()
f3d::engine::state::fromString(content).toClipboard();
log::info("Statefile copied to the clipboard");
}
// LCOV_EXCL_START
catch (const f3d::engine::statefile_exception& ex)
{
// Unreachable in testing
log::error(ex.what());
}
// LCOV_EXCL_STOP
},
command_documentation_t{
"save_statefile_to_clipboard", "save the current state into the system clipboard" });
Expand All @@ -1382,11 +1383,12 @@ interactor& interactor_impl::initCommands()
this->Internals->Scene, this->Internals->Window, this->Internals->Options, st.toString());
log::info("Statefile loaded from the clipboard");
}
// LCOV_EXCL_START
catch (const f3d::engine::statefile_exception& ex)
{
// Unreachable in testing
log::error(ex.what());
}
// LCOV_EXCL_STOP
},
command_documentation_t{
"load_statefile_from_clipboard", "restore the state from the system clipboard" });
Expand Down
Loading