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

[DEBUG] Add test for C++ exception error #234

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 5 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
6 changes: 6 additions & 0 deletions recipe/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,9 @@ if [[ ("$target_platform" != "linux-ppc64le") && \
# https://forum.hdfgroup.org/t/hdf5-1-10-long-double-conversions-tests-failed-in-ppc64le/4077
make check RUNPARALLEL="mpiexec -n 2"
fi

# test for hdf5 C++ exceptions
if [[ "${CONDA_BUILD_CROSS_COMPILATION:-}" != "1" || "${CROSSCOMPILING_EMULATOR}" != "" ]]; then
$CXX ${CXXFLAGS} $RECIPE_DIR/testhdf5exc.cpp -o testhdf5exc -L$PREFIX/lib -lhdf5_cpp -lhdf5 -I$PREFIX/include
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
$CXX ${CXXFLAGS} $RECIPE_DIR/testhdf5exc.cpp -o testhdf5exc -L$PREFIX/lib -lhdf5_cpp -lhdf5 -I$PREFIX/include
${CXX} ${CXXFLAGS} ${LDFLAGS} $RECIPE_DIR/testhdf5exc.cpp -o testhdf5exc -lhdf5_cpp -lhdf5 -I$PREFIX/include

You can also follow the style and add the test to the test section:
https://github.com/xylar/hdf5-feedstock/blob/add-exception-catch-test/recipe/run_test.sh#L23

Copy link
Author

Choose a reason for hiding this comment

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

Agreed, I will move it if we decide we want to keep the test.

./testhdf5exc
fi
30 changes: 30 additions & 0 deletions recipe/testhdf5exc.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

#include <iostream>
#include <H5Cpp.h>

int main()
{
H5::Exception::dontPrint();

H5::H5File *H5File = new H5::H5File("/tmp/test.hd5", H5F_ACC_TRUNC, H5::FileCreatPropList::DEFAULT);
H5File->createGroup("/HEADER");

H5::DataSet ds;
try
{
// should fail
ds = H5File->openDataSet("/HEADER/NUMBANDS");
std::cout << "Was able to open dataset\n";
return -1;
}
catch (const H5::Exception &e)
{
std::cout << "Failed to open dataset (expected)\n";
return 0;
}

return 0;
}



Loading