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

Move clib-demo to samples #1454

Merged
merged 4 commits into from
Mar 10, 2023
Merged

Move clib-demo to samples #1454

merged 4 commits into from
Mar 10, 2023

Conversation

ischoegl
Copy link
Member

@ischoegl ischoegl commented Mar 10, 2023

Changes proposed in this pull request

Detailed tests included in clib_test.c are superseded by the gtest clib suite. Nevertheless, the original file contains a useful example. This PR moves a slightly updated example to samples/clib while retaining the output file comparison.

If applicable, provide an example illustrating new features this pull request is introducing

The behavior of

scons test-clib-demo

is unchanged, but the source code is now compiled from samples/clib/demo.c.

Checklist

  • The pull request includes a clear description of this code change
  • Commit messages have short titles and reference relevant issues
  • Build passes (scons build & scons test) and unit tests address code coverage
  • Style & formatting of contributed code follows contributing guidelines
  • The pull request is ready for review

@codecov
Copy link

codecov bot commented Mar 10, 2023

Codecov Report

Merging #1454 (549a1b0) into main (5d247d0) will increase coverage by 0.00%.
The diff coverage is 97.67%.

❗ Current head 549a1b0 differs from pull request most recent head 4f519b8. Consider uploading reports for the commit 4f519b8 to get more accurate results

@@           Coverage Diff           @@
##             main    #1454   +/-   ##
=======================================
  Coverage   69.63%   69.64%           
=======================================
  Files         373      374    +1     
  Lines       55769    55812   +43     
  Branches    18295    18298    +3     
=======================================
+ Hits        38833    38868   +35     
- Misses      14480    14487    +7     
- Partials     2456     2457    +1     
Impacted Files Coverage Δ
samples/clib/demo.c 97.67% <97.67%> (ø)

... and 1 file with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@ischoegl ischoegl force-pushed the move-clib-demo branch 3 times, most recently from 293ea14 to f9d45ff Compare March 10, 2023 13:12
@ischoegl ischoegl marked this pull request as ready for review March 10, 2023 13:34
@ischoegl
Copy link
Member Author

ischoegl commented Mar 10, 2023

The updated unit test works, but I'm not sure why the substituted *.in files aren't copied over to build/samples/clib (working on macOS/Apple Silicon).

@speth
Copy link
Member

speth commented Mar 10, 2023

The updated unit test works, but I'm not sure why the substituted *.in files aren't copied over to build/samples/clib (working on macOS/Apple Silicon).

I tested this, and they do get generated when you run the install command. I think it's because the intermediate files aren't added to the build target, but the final installed location is added to the install target. The same is true for the sample build scripts for other interfaces, so I don't think there's anything that needs to be changed here.

Copy link
Member

@speth speth left a comment

Choose a reason for hiding this comment

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

Thanks, @ischoegl. I think this change generally makes sense, and installing a pure clib example is useful.

One thing that's lost here is what was described at the top of clib_test.c:

// Include all clib headers to make sure all of them are C-compatible, even if
// we don't actually use all of them in this test.
#include "cantera/clib/ct.h"
#include "cantera/clib/ctfunc.h"
#include "cantera/clib/ctmultiphase.h"
#include "cantera/clib/ctonedim.h"
#include "cantera/clib/ctreactor.h"
#include "cantera/clib/ctrpath.h"
#include "cantera/clib/ctsurf.h"

The point was that this is the only file within Cantera that actually gets compiled by the C (rather than C++) compiler, and ensures that these files don't do anything bad like include a C++ header or syntax that isn't valid C (which was in fact the case before I originally added this test). This is why this test was added to the older test_problems test suite rather than the all-C++ gtest test suite, and I think we still need something that ensures this, even if it's not the previous version of the clib test.

samples/clib/Makefile.in Outdated Show resolved Hide resolved
samples/clib/SConscript Outdated Show resolved Hide resolved
SConstruct Outdated Show resolved Hide resolved
@ischoegl ischoegl force-pushed the move-clib-demo branch 2 times, most recently from c338d8d to 549a1b0 Compare March 10, 2023 16:46
@ischoegl
Copy link
Member Author

@speth ... thanks for the feedback and for shedding some light on the *.in files (the cxx substitutions make some noise during the scons build stage, and I made the wrong conclusions).

One thing that's lost here is what was described at the top of clib_test.c:

// Include all clib headers to make sure all of them are C-compatible, even if
// we don't actually use all of them in this test.
#include "cantera/clib/ct.h"
#include "cantera/clib/ctfunc.h"
#include "cantera/clib/ctmultiphase.h"
#include "cantera/clib/ctonedim.h"
#include "cantera/clib/ctreactor.h"
#include "cantera/clib/ctrpath.h"
#include "cantera/clib/ctsurf.h"

Good point. I re-added the 'lost' includes to demo.c, and added a comment explaining why they are there.

@ischoegl ischoegl requested a review from speth March 10, 2023 18:52
_MSC_VER < 1900 corresponds to 1800 and earlier, which is
VC++ version 12.0 (Visual Studio 2013). Cantera now uses the C++17
standard, with the current minimum requirement VC++ version 14.1
(Visual Studio 2017).
Copy link
Member

@speth speth left a comment

Choose a reason for hiding this comment

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

Looks good to me!

@ischoegl ischoegl merged commit 5cd3d8a into Cantera:main Mar 10, 2023
@ischoegl ischoegl deleted the move-clib-demo branch March 10, 2023 19:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

2 participants