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

Make tests support empty SPDLOG_EOL #1414

Merged
merged 2 commits into from Feb 10, 2020

Conversation

emmenlau
Copy link
Contributor

@emmenlau emmenlau commented Feb 5, 2020

This PR is currently a demo only. It is created against tag v1.5.0. It should show-case how one could add support for empty SPDLOG_EOL in the tests. This seems a "relatively" common request amongst users so it may be nice if the tests can support it.

Closes #1413 .

@gabime
Copy link
Owner

gabime commented Feb 5, 2020

I think it could be cleaner if a new “count_messages()” function was introduced with all the logic in it..

@emmenlau
Copy link
Contributor Author

emmenlau commented Feb 5, 2020

I think it could be cleaner if a new “count_messages()” function was introduced with all the logic in it..

Yes, you are right. I'll take a look at it. Do you have a preferred source file where this method would go, since its used in multiple tests?

@gabime
Copy link
Owner

gabime commented Feb 5, 2020

tests/utils.cpp is the most suitable for this

@emmenlau
Copy link
Contributor Author

emmenlau commented Feb 7, 2020

Dear @gabime thanks for the constructive feedback. I've adapted the tests and indeed the code comes out much better. Do you think this is reasonable to add?

@gabime
Copy link
Owner

gabime commented Feb 7, 2020

sure, but they fail

@emmenlau
Copy link
Contributor Author

emmenlau commented Feb 7, 2020

The travis build works except an installation problem with g++7. The Appveyor build is something else, that may be related with newlines on MSVC. That brings up a question. It fails in places where I changed

"Test message 2\n"

to

"Test message 2" + std::string(spdlog::details::os::default_eol)

Its actually interesting how this worked before, because AFAIK on MSVC the SPDLOG_EOL was defined as \r\n. So why was the test expecting only \n? Or am I on the wrong track?

@gabime
Copy link
Owner

gabime commented Feb 7, 2020

That's because file_contents(filename) open the file in text mode so the \r\n got converted to \n

tests/test_file_logging.cpp Outdated Show resolved Hide resolved
@emmenlau
Copy link
Contributor Author

emmenlau commented Feb 7, 2020

That's because file_contents(filename) open the file in text mode so the \r\n got converted to \n

How should I best solve this? Or can you help? I personally would change the behavior of file_contents() to open in binary mode, but will that change many other tests?

@gabime
Copy link
Owner

gabime commented Feb 7, 2020

Open in binary mode is better, I agree. I am not sure how it would affect the windows tests, if any. You can try and see

@emmenlau
Copy link
Contributor Author

emmenlau commented Feb 8, 2020

Seems I was lucky with this change, the tests now all work? Could you consider this for merging?

@gabime
Copy link
Owner

gabime commented Feb 8, 2020

Sure, but I would appreciate if you first added the changes I requested.

@gabime gabime merged commit 12f36de into gabime:v1.x Feb 10, 2020
@gabime
Copy link
Owner

gabime commented Feb 10, 2020

Thanks @emmenlau . Merged.

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.

Changing tweakme.h breaks tests, should this be improved upon?
2 participants