How do you run a single OCaml inline test with dune? - ocaml

I'm trying to run a single inline test in OCaml, in a dune project. The only command I have is dune test which runs all the tests. I can't seem to find the command to run a single test.

Related

Automate CMake build using C++ script

I would like to automate the build of CMake using an MSVC C++ script instead of using CMake-gui to generate the build or CMake terminal or using the CMake integrated on MSVC 2017 by right click on the CMakeLists.txt to build it manually. Assume we have a project (name it: initialize) that includes the CMakeLists.txt and initialize.cpp, so my question is how I can convert these commands into a C++ code, assume build_initialize.cpp:
mkdir build
cd build/
cmake ..
So, the requirement of this tiny C++ code is to
Set the path to this project
Create build folder
Run CMake
At the end if I execute build_initialize.exe, the job is just to build the initialize.cpp using CMake. The goal is to test if the build is success or not as a test case within another project that has several test cases.
You may ask, why I didnot include it to the top CMakelists.txt, and then build it from the beginning using CMake. If I am going to do that, I will get an executable file. As a result, by running the ctest of CMake, the initialize.exe will require a pace of hardware. This is not the goal. My goal is just to build it. If I run build_initialize.exe, just repeat the build using CMake without initialize.exe execution.
Sorry, it could be very simple, but I lack the good experience either in C++ or CMake. Two days have been lost without success.
Thanks to all of you for the comments. The answer has been given by #Fred. To run cmake from C++ script, simply the system() can be used such as: System(cmake -S path_to_src -B path_to_bld).
Useful link: https://faq.cprogramming.com/cgi-bin/smartfaq.cgi?id=1043284392&answer=1044654269

migrating CMake results in multi-stage Docker build

I have a CMake-based C++ project that I need to integrate into a CI/CD pipeline. The pipeline has two steps, one for building, the other for testing. Creating this environment in a Docker container works like a charm, but results in a 2GB container. So I am trying to implement a multi-stage Docker build where I copy the executables into an Alpine base image. All that works, except for the cmake/ctest functionality. I want to expose the command "make test" which will execute the CMake generate target.
This is the target that CMake has created for running ctest.
# Targets provided globally by CMake.
# Special rule for the target test
test:
#$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running tests..."
/usr/bin/ctest --force-new-ctest-process $(ARGS)
.PHONY : test
The problem I can't figure out is where ctest gets the test configuration from. When I issue
ctest -N
in the container it shows no tests.
Looking for an SME on CMake to educate me how this is supposed to work.
Ok, I straced ctest in the container and discovered that it was hunting down a CTestTestfile.cmake file in each of the directories that have test executables. Adding that file to the deployment container along side the executables, basically where the file is found in the build container, solves the problem.
There is a CTestTestfile.cmake at the root of the build tree, and then individual CTestTestfile.cmake files along side the test executables.
strace is your friend, although I had to learn a new trick for docker, as strace is privileged. This was the command I used to strace ctest
docker run --rm --security-opt seccomp:unconfined strace ctest -N

Compile TypeScript with modules and bundle to one file

When using a module inside tsconfig.json the TypeScript compiler will ignore any --out flags and generate regular output, e.g. commonjs modules in seperate files.
Is there a way to bundle all transpiled files into a single file?
I am currently trying to use webpack but can not get any of the loaders to run. Running the TypeScript compiler directly works.
For typescript external module bundles you can use the npm package TsProject

Coverity: command line build script for basic c++ code

I am working on a requirement to do instrumented build for c++ code on coverity(static code analysis tool, version 7.5.1) build server via command line. Need to execute a basic c++ code via command line, I tried using the cov-build command cov-build –-dir cov-int cl /c test.cpp and various other permutations on the directory where coverity is actually installed in the build machine. But there is some problem. System can understand only the cov-buld --dir and if i use only this command along with /c, this file opens in visual studio rather than giving the% of compilation units.
Please help me if anyone have done this before.
First be clear with your requirements. Which system you are working on?(windows or Mac or Unix or Solaris). Before starting cov-build, configure the compiler which will execute the source file. As you said you are working on C++ source code, use GCC compiler to configure with Coverity Static Analyzer. Coverity Directly supports for 3 Compilers(Gcc and 2 more). To configure this GCC use cov-configure command followed by gcc.
Then use cov-build command to analyze.
Sample command is:
path_to_cov_bin/cov-build --dir path_to_output_folder gcc hi.cpp
It will create emit folder with emit-db in path_to_output_folder. Then cov-analyze command will be analyze that emit folder and create Output Directory in given path.
To compile N number of source files use makefile. If you have any query about makefile You can put a post here or refer in this site.

Selectively building gtest tests with cmake and showing gtest output

I've got cmake working with a test file similar to " How to start working with GTest and CMake " but the problem is that gtest and the test binary gets built each time I make rather than just when I run make test. And when running make test, only the ctest summary output is shown, not the actual gtest output.
How can I change this behaviour so that the tests and gtest library is only built when I run make test, and running make test actually shows the proper output?