From db85c4ee71d2a2ee7a1f6ceb87ec66e37d62aad5 Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Sun, 31 Jan 2021 09:48:06 -0800 Subject: [PATCH] add a test of PACKAGE_VERSION Related to !1706. --- rtest/check-package-version.c | 21 ++++++++++++++++++++ rtest/test_regression.py | 37 +++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 rtest/check-package-version.c diff --git a/rtest/check-package-version.c b/rtest/check-package-version.c new file mode 100644 index 000000000..ce44c9ba1 --- /dev/null +++ b/rtest/check-package-version.c @@ -0,0 +1,21 @@ +// test that the Graphviz version header has a non-empty PACKAGE_VERSION + +// force assertions on +#ifdef NDEBUG + #undef NDEBUG +#endif + +#include +#include +#include +#include + +#ifndef PACKAGE_VERSION +#error PACKAGE_VERSION missing from graphviz_version.h +#endif + +int main(void) { + assert(strcmp(PACKAGE_VERSION, "") != 0 && + "invalid PACKAGE_VERSION (" PACKAGE_VERSION ") in graphviz_version.h"); + return EXIT_SUCCESS; +} diff --git a/rtest/test_regression.py b/rtest/test_regression.py index 8f920259a..15f691f11 100644 --- a/rtest/test_regression.py +++ b/rtest/test_regression.py @@ -749,3 +749,40 @@ def test_1931(): assert 'line 1\nline 2\n' in xdot assert 'line 3\nline 4' in xdot assert 'line 5\nline 6' in xdot + +def test_package_version(): + ''' + The graphviz_version.h header should define a non-empty PACKAGE_VERSION + ''' + + # FIXME: Remove skip when + # https://gitlab.com/graphviz/graphviz/-/issues/1777 is fixed + if os.getenv('build_system') == 'msbuild': + pytest.skip('Windows MSBuild release does not contain any header files (#1777)') + + # find co-located test source + c_src = (Path(__file__).parent / 'check-package-version.c').resolve() + assert c_src.exists(), 'missing test case' + + # create some scratch space to work in + with tempfile.TemporaryDirectory() as tmp: + + # compile our test code + exe = Path(tmp) / 'a.exe' + rt_lib_option = '-MDd' if os.environ.get('configuration') == 'Debug' else '-MD' + + if platform.system() == 'Windows': + subprocess.check_call(['cl', c_src, '-Fe:', exe, '-nologo', + rt_lib_option]) + else: + cc = os.environ.get('CC', 'cc') + subprocess.check_call([cc, '-std=c99', c_src, '-o', exe]) + + # run the test + ret = subprocess.call([exe]) + + # FIXME: this is currently broken in the CMake build + if os.getenv('build_system') == 'cmake': + assert ret != 0 + else: + assert ret == 0 -- 2.49.0