From ff570c3705e02a80c46435d5127222a2a380ab7e Mon Sep 17 00:00:00 2001 From: Andreas Herrmann Date: Tue, 24 Nov 2020 10:34:55 +0100 Subject: [PATCH] Test C and C++ compilation explicitly --- tests/BUILD.bazel | 5 +++++ tests/c-test.c | 7 +++++++ tests/cc-test.cc | 6 +++++- 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 tests/c-test.c diff --git a/tests/BUILD.bazel b/tests/BUILD.bazel index 077c0c845..6c80584fd 100644 --- a/tests/BUILD.bazel +++ b/tests/BUILD.bazel @@ -82,6 +82,11 @@ cc_binary( srcs = ["cc-test.cc"], ) +cc_binary( + name = "c-test", + srcs = ["c-test.c"], +) + # Test that nixpkgs_cc_configure is selected. cc_toolchain_test( name = "cc-toolchain", diff --git a/tests/c-test.c b/tests/c-test.c new file mode 100644 index 000000000..304d0d872 --- /dev/null +++ b/tests/c-test.c @@ -0,0 +1,7 @@ +#include "stdio.h" +int main() { + puts("Hello world\n"); + // Ensure that this is compiled as C, template is a keyword in C++. + int template = 0; + return template; +} diff --git a/tests/cc-test.cc b/tests/cc-test.cc index 76e819701..0e7f60bbd 100644 --- a/tests/cc-test.cc +++ b/tests/cc-test.cc @@ -1 +1,5 @@ -int main() { return 0; } +#include +int main() { + std::cout << "Hello world\n"; + return 0; +}