GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — reduced usage of mutable `Settings` objects in tests by firewave · Pull Request #4798 · cppcheck-opensource/cppcheck

Conversation

@firewave

@firewave firewave commented Feb 16, 2023

Copy link
Copy Markdown
Collaborator

Currently the Settings objects in the tests are all mutable. This might cause some tests to modify the settings as they also contain run-time information which will be used by subsequent tests using the same object.

We should make sure that they are const if possible. Otherwise we need to make sure the tests will always be run on a a fixed configuration.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@firewave

firewave commented Feb 16, 2023

Copy link
Copy Markdown
Collaborator Author

This is to gain initial feedback on the approach. I will adjust all test then. I also have other PRs which need to be merged first to avoid conflicts.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@firewave firewave mentioned this pull request Feb 16, 2023
some Tokenizer construction and related other cleanups #4799
Merged
@firewave
firewave force-pushed the settings branch 2 times, most recently from 6ca74d2 to ab0b8d0 Compare February 16, 2023 13:41
@firewave firewave changed the title reduce usage of mutable Settings objects in tests reduced usage of mutable Settings objects in tests Feb 16, 2023
@firewave
firewave force-pushed the settings branch 2 times, most recently from 7555687 to 9575e90 Compare February 16, 2023 22:42
@firewave firewave mentioned this pull request Feb 17, 2023
improved library loading in tests #4806
Merged
@firewave
firewave force-pushed the settings branch from 9575e90 to 1c14327 Compare February 17, 2023 22:04
@firewave

firewave commented Feb 17, 2023

Copy link
Copy Markdown
Collaborator Author

This needs many other PRs merge first and we also need to adapt #4785 as a const Settings object still appears to be mutable since a lot of tests fail when I make those static. I wouldn't rule out some const_cast occurrences either.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@firewave

firewave commented Feb 18, 2023

Copy link
Copy Markdown
Collaborator Author

Turns out they are not mutable. I accidentally made objects static which should not.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@firewave
firewave force-pushed the settings branch 4 times, most recently from 348cb67 to 24c5953 Compare February 19, 2023 14:04
@firewave
firewave marked this pull request as ready for review February 19, 2023 14:53
@firewave
firewave force-pushed the settings branch 2 times, most recently from ed69e1c to e7a8c98 Compare March 2, 2023 20:37
@firewave
firewave force-pushed the settings branch 3 times, most recently from 761c51b to 28ad381 Compare March 7, 2023 12:21
@firewave firewave mentioned this pull request Mar 9, 2023
Preprocessor: provide suppressions separately from settings #4878
Merged
@firewave
firewave force-pushed the settings branch 3 times, most recently from 7bc59be to edb0174 Compare March 12, 2023 16:25
danmar
danmar reviewed Mar 12, 2023
View reviewed changes
Comment thread test/fixture.cpp Resolved

Uh oh!

There was an error while loading. Please reload this page.

@firewave
firewave force-pushed the settings branch from edb0174 to 0a6373f Compare March 12, 2023 19:16
@danmar

danmar commented Mar 13, 2023

Copy link
Copy Markdown
Collaborator

you are making various Settings objects static. Why?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@firewave

firewave commented Mar 13, 2023

Copy link
Copy Markdown
Collaborator Author

you are making various Settings objects static. Why?

So they are not instantiated on each test case but only once. Especially if library loading (or copying) is involved that is consuming unnecessary CPU.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@danmar

danmar commented Mar 13, 2023 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Collaborator

I would not make local objects static just to save a few cpu cycles. Can we please stop with all these micro optimisations that only saves a few cpu cycles. It's more important with readability.

Also these objects will then use some mutexes to make these objects threadsafe that has a penalty also.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@firewave
firewave force-pushed the settings branch from 0702340 to 6147dfa Compare April 8, 2023 10:16
@danmar

danmar commented Apr 9, 2023

Copy link
Copy Markdown
Collaborator

Could you show some stats. With static or without static. I wonder if you can test that:

time ./testrunner TestOther
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@firewave

firewave commented Apr 13, 2023

Copy link
Copy Markdown
Collaborator Author

Could you show some stats. With static or without static. I wonder if you can test that:

time ./testrunner TestOther

I will give it a spin. It is quite possible this PR is not showing the gains yet and is even showing a slight regression since I introduced several copies which weren't there before and won't be removed until I have applied all changes. I could add the follow-up changes to this PR as well but I would prefer not to make this even bigger than it already is.

There's also some general change to the way we provide the settings to the common check() wrapper which I haven't done yet which might also improve things and get rid of the need of inline/non-static configurations. It's quite incremental and at the end things will be much cleaner and more explicit.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@firewave
firewave force-pushed the settings branch from 6147dfa to bcaa6c7 Compare April 15, 2023 09:43
@firewave

firewave commented Apr 15, 2023

Copy link
Copy Markdown
Collaborator Author

Doing tests I am getting some inconsistent results which is strange. So I will drop the static for now so this can proceed and will do some profiling again after I am done with all changes.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@firewave
firewave force-pushed the settings branch from 770de30 to efb0ba4 Compare April 21, 2023 13:11
@danmar

danmar commented Apr 30, 2023

Copy link
Copy Markdown
Collaborator

Doing tests I am getting some inconsistent results which is strange. So I will drop the static for now so this can proceed and will do some profiling again after I am done with all changes.

ok thanks as far as I remember that was my biggest concern. There is now some conflict..

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@firewave
firewave force-pushed the settings branch from efb0ba4 to 56ddf75 Compare April 30, 2023 20:23
firewave added 18 commits April 30, 2023 22:54
@firewave
TestFixture: immediately bail out when library could not be loaded
36b62ad
@firewave
TestFixture: added SettingsBuilder to allow inline initialization o…
944cce5
…f objects
@firewave
made some Settings objects in tests const
de94a7d
@firewave
first round of SettingsBuilder usage in tests
8b88e70
@firewave
moved givenACodeSampleToTokenize::settings instance to proper file
5783bed
@firewave
made some local const Settings objects in test static
b8079ac
@firewave
TestBufferOverrun: added TODO about missing settings reset
8109781
@firewave
added TODO about exename not yet being set in `TestFixture::Setting…
d46fcc8
…sBuilder::library()`
@firewave
small test classes initialization cleanup
fedf569
@firewave
TestIO: fixed performance regression
67009a2
@firewave
testclass.cpp: adjustments after Preprocessor was added by another PR
efa8945
@firewave
testtokenlist.cpp: fixed functionConst selfcheck warning
61338a6
@firewave
teststl.cpp: removed const to fix compilation after changes in anot…
7f50516
…her merge
@firewave
testtokenlist.cpp: fixed functionConst selfcheck warnings
a0a0acf
@firewave
do not use static const settings in tests
935755f
@firewave
testthreadexecutor.cpp: removed const to fix compilation after chan…
cea46ae
…ges in another merge
@firewave
dmake
dde6eea
@firewave
fixed helpers.cpp compilation without precompiled headers
aaecc8c
@firewave
firewave force-pushed the settings branch from 56ddf75 to aaecc8c Compare April 30, 2023 20:55
@danmar
danmar merged commit 2935c85 into cppcheck-opensource:main May 2, 2023
@firewave
firewave deleted the settings branch May 2, 2023 09:55
pfultz2 added a commit to pfultz2/cppcheck that referenced this pull request May 15, 2023
@pfultz2
Revert reduced usage of mutable Settings objects in tests (cppcheck…
a28c21f
…-opensource#4798)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@danmar danmar danmar left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@firewave @danmar
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.