Skip to content

clang-tidy: Major clang-tidy fixes#297

Draft
LecrisUT wants to merge 10 commits intospglib:developfrom
LecrisUT:clang-tidy/major-fix
Draft

clang-tidy: Major clang-tidy fixes#297
LecrisUT wants to merge 10 commits intospglib:developfrom
LecrisUT:clang-tidy/major-fix

Conversation

@LecrisUT
Copy link
Copy Markdown
Collaborator

@LecrisUT LecrisUT commented Jun 16, 2023

Manually fix various clang-tidy fixes

This PR concerns the commit 3a01389. This should be reviewed carefully. If I have the energy I might split them off at some point.

Basically what this commit does is:

  • Moved initializers to outside of if statement 0725ad1
    (Prone to initialization errors)
  • Moved loop variables initialization inside
  • Removed conditional initializations
  • Made a few static const arrays const
  • Reduced goto statements
  • Added missing assertion checks
  • Resolved some memory leaks

I'll pull up some examples in the commit to show some of the changes

@LecrisUT LecrisUT force-pushed the clang-tidy/major-fix branch from 5c545de to 3a01389 Compare June 16, 2023 22:26
@LecrisUT
Copy link
Copy Markdown
Collaborator Author

LecrisUT commented Jun 16, 2023

Main errors right now appear to be with the address sanitizer, which is to be expected with these many changes. Yep, some mistakes on my part.

Hmm, now the pytests are failing 🤔 I would have thought that these would pass if the ctests were passing.

@LecrisUT LecrisUT force-pushed the clang-tidy/major-fix branch from 3a01389 to 9f84b0d Compare June 16, 2023 23:03
LecrisUT added a commit to LecrisUT/spglib that referenced this pull request Jun 16, 2023
@atztogo
Copy link
Copy Markdown
Collaborator

atztogo commented Jun 17, 2023

Hmm, now the pytests are failing 🤔 I would have thought that these would pass if the ctests were passing.

There are many naively distorted crystal structures with respect to ideal symmetry. ctests covers very basis ones, but pytest does more cases. It results in entering specific routines to recover from detailed different symptoms.

I feel this PR is dangerous. It would be helpful to divide into small commits.

@LecrisUT
Copy link
Copy Markdown
Collaborator Author

I feel this PR is dangerous. It would be helpful to divide into small commits.

Indeed that would be ideal, but it will take a bit of time yo detangle them. At least the safe ones we have it in the other 2 commits.

There are many naively distorted crystal structures with respect to ideal symmetry. ctests covers very basis ones, but pytest does more cases. It results in entering specific routines to recover from detailed different symptoms.

Hmm I think we should address #291 and its equivalent googletest to actually report the specifics of how it fails. It should be possible to map the pytests 1-to-1 onto the ctests, but it would require a bit of organization, mainly split the unit-tests from the functional tests. All of the python and fortran api tests are only functional ones, and those should be identically covered and use a common set of inputs that we synchronize through a file. For this testpytests should be moved to /tests folder which we then split logically as well.

When to label a test as a unit-test or functional test

unit test

  • runs a single self-contained internal function, e.g. constructing and destructing the lattice object
  • it does not touch any physical aspects
  • used to debug compilation, segmentation issues etc.
  • the main thing to investigate in codecov

functional test

  • runs the full calculation as the user would be doing
  • requires input data
  • tests the physical aspects of the library

integration test (yes, there's one more technically)

  • middle step between unit and functional test. Runs multiple fumctions covered by unit tests or the higher level functions
  • tests if the data is transfered correctly between the functions, mainly for segmentation faults and unexpected crashes in the manipulation of data

@LecrisUT LecrisUT force-pushed the clang-tidy/major-fix branch 3 times, most recently from 5c0ca04 to 32ffcb6 Compare June 19, 2023 13:57
@LecrisUT LecrisUT mentioned this pull request Jun 20, 2023
1 task
@LecrisUT LecrisUT self-assigned this Jun 20, 2023
@LecrisUT LecrisUT force-pushed the clang-tidy/major-fix branch 4 times, most recently from 50288e0 to 0725ad1 Compare June 20, 2023 18:12
@LecrisUT LecrisUT force-pushed the clang-tidy/major-fix branch from 80c3e5f to 5e7c295 Compare June 20, 2023 18:46
LecrisUT added 2 commits June 20, 2023 20:48
- Moved loop variables initialization inside
- Removed conditional initializations
- Made a few static const arrays const
- Reduced goto statements
- Added missing assertion checks
- Resolved some memory leaks

Signed-off-by: Cristian Le <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: WIP

Development

Successfully merging this pull request may close these issues.

2 participants