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

Build tests with warnings as errors enabled #2245

Closed

Conversation

t-b
Copy link
Contributor

@t-b t-b commented Jul 6, 2020

I'm trying to resurrect #1900.

Close #1798.

@t-b t-b requested a review from nlohmann as a code owner July 6, 2020 20:45
@nlohmann
Copy link
Owner

nlohmann commented Jul 6, 2020

FYI: These are the flags I check regularly: https://github.com/nlohmann/json/blob/develop/Makefile#L93.

@coveralls
Copy link

coveralls commented Jul 7, 2020

Coverage Status

Coverage remained the same at 100.0% when pulling e226460 on t-b:feature/build_tests_with_warnings_as_errors into d9843fc on nlohmann:develop.

@t-b t-b force-pushed the feature/build_tests_with_warnings_as_errors branch 2 times, most recently from 1ad4d1a to 08f93bd Compare July 14, 2020 12:11
@t-b t-b force-pushed the feature/build_tests_with_warnings_as_errors branch 2 times, most recently from 727d993 to 49844f2 Compare August 5, 2020 14:39
@t-b t-b force-pushed the feature/build_tests_with_warnings_as_errors branch 4 times, most recently from 14d56b7 to 1d15d7c Compare September 1, 2020 10:20
t-b and others added 7 commits September 1, 2020 13:22
GCC 7.0 and higher complain when compiled in release mode about the
unused result of parse-like functions. This makes totally sense as these
are marked with JSON_HEDLEY_WARN_UNUSED_RESULT.

Store the result in a json object named _ to silence that warning.
Co-authored-by: James Moore <james.moore@veracityuk.com>
Clang on Windows comes in two flavours, one which pretens to be like GCC
and one which pretends to be like MSVC. We need to distinguish these two
so that we can pass the correct compiler flags.

Co-authored-by: James Moore <james.moore@veracityuk.com>
This currently produces

 In file included from C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.27.29110\include\ciso646:9:
 In file included from C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.27.29110\include\yvals.h:9:
 C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.27.29110\include\yvals_core.h:494:2: error: STL1000: Unexpected compiler version, expected Clang 10.0.0 or newer.
  #error STL1000: Unexpected compiler version, expected Clang 10.0.0 or newer.

and that is very likely due to the new -pedantic flag when compiling.

Let's remove this compiler as it clearly is not meant to be used with
these MSVC headers.
@t-b t-b force-pushed the feature/build_tests_with_warnings_as_errors branch from 1d15d7c to e226460 Compare September 1, 2020 11:48
@t-b t-b requested a review from nlohmann September 1, 2020 11:49
@t-b
Copy link
Contributor Author

t-b commented Sep 1, 2020

@nlohmann Ready.

@@ -15,20 +15,6 @@ jobs:
- name: test
run: cd build ; ctest -j 10 -C Debug --exclude-regex "test-unicode" --output-on-failure

clang9:
Copy link
Owner

Choose a reason for hiding this comment

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

Why did you remove Clang 9?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The commit message explains why, see e226460.

Copy link
Contributor

Choose a reason for hiding this comment

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

Could the problem be that windows-latest doesn't remain the same? Newer versions of Visual studio's standard c++ library also require newer versions of clang, so when testing llvm on windows, a fixed version of clang should probably be paired with a fixed version of the VS toolchain.

@@ -29,6 +29,10 @@ SOFTWARE.

#include "doctest_compatibility.h"

#if DOCTEST_CLANG && DOCTEST_CLANG >= DOCTEST_COMPILER(3, 6, 0)
DOCTEST_CLANG_SUPPRESS_WARNING("-Wkeyword-macro")
Copy link
Owner

Choose a reason for hiding this comment

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

Do you still need this after JSON_TESTS_PRIVATE was introduced?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll have a look if I find time.

@stale
Copy link

stale bot commented Oct 4, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the state: stale the issue has not been updated in a while and will be closed automatically soon unless it is updated label Oct 4, 2020
@nlohmann nlohmann removed the state: stale the issue has not been updated in a while and will be closed automatically soon unless it is updated label Oct 5, 2020
@MBalszun
Copy link
Contributor

Is it possible to override this?
E.g. when I want to compile the tests with a new compiler (with new warnings) on ci or my local computer.

@t-b
Copy link
Contributor Author

t-b commented Nov 19, 2020

@MBalszun Not as of now. But a patch is welcome to add a cmake option JSON_WARNINGS_AS_ERRORS defaulting to ON.

@stale
Copy link

stale bot commented Dec 25, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added state: stale the issue has not been updated in a while and will be closed automatically soon unless it is updated and removed state: stale the issue has not been updated in a while and will be closed automatically soon unless it is updated labels Dec 25, 2020
@MBalszun
Copy link
Contributor

So, what is the state here? Can this be merged? I see there is a merge conflict, but github doesn't show me what it is.

@nlohmann
Copy link
Owner

I am currently overworking the targets for the CI. The goal is to move everything from the individual Travis/AppVeyor/GitHub Actions files as well as the project's Makefile into some CMake-based targets. This includes the warning flags for GCC and Clang I linked in #2245 (comment). Then I think we only need to add a similar target for MSVC.

I will open a PR to make the proposal visible. It is not done yet, but I think it will tackle most issues described here (apart of MSVC).

@nlohmann nlohmann mentioned this pull request Dec 30, 2020
@nlohmann
Copy link
Owner

See #2561.

@MBalszun
Copy link
Contributor

Thanks for the update. I wasn't aware that all the warning flags for gcc and clang are set in a separate make file.

That aside: You are aware tha travis.org is being shut down and that travis.com won't provide unlimited CI time for open source projects anymore right? Or have you negotiated a deal with them?

@nlohmann
Copy link
Owner

I have no deal with travis. If they stop working the way they used to, I will rely on AppVeyor and GitHub Actions. In the meantime, I see whether I can get a self-hosted runner to work so that I can automate as many system-independent tests as possible.

@nlohmann nlohmann closed this Jan 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Always compile tests with all warnings enabled and error out on warnings
5 participants