Hi! I’m very new to Mongoose OS development and was hoping to get my feet wet by compiling the source and running/making my own tests. In particular, I want to investigate how Mongoose’s implementation of cron works (to debug some issues we have with our application that uses it). But I’m unsure how to make a minimal environment to be able to compile and run these tests.
My goal is: to debug a problem in an application by cloning the mongoose-os-libs/cron repository and running tests.
My actions are: I cloned the repository at this address: https://github.com/mongoose-os-libs/cron and was hoping to compile and run the tests located in the test folder.
The result I see is: When I run make on the Makefile in the test folder, I get a bunch of errors related to the fact that there are ../../.. directories leading well outside the repository’s root folder. This is what powershell shows:
I suppose that this cron repository isn’t meant to be compiled by itself and instead should be part of another project. Would someone be able to point me in the direction of that repository and perhaps give me a few pointers as to how one might get a working environment set up to begin testing functions? Thank you!
Not sure how the tests are run, I don’t see any CI setup in the repo.
You’re probably right, if you want to do anything useful you’ll likely need to follow the basic instructions on getting started with a C/C++ project: Mongoose OS Documentation
I’m guessing you’ll want to clone the c-demo app, not the js app. If you wanted to test the actual cron library on your device, then add the cron library to the mos.yml file in your new project.
I don’t use the cloud compilation service, I build locally which pulls the source files required to build - I’m guessing are required to run the tests based on your comment. If you get stuck there because source files are not being pulled, take a look at mos build locally: the mos build flag you want is --local, but docker is required. You might find this thread handy.
There are a few threads on this forum about speeding things up, but cross that bridge when you get to it.
The list of files in the Makefile is obsolete. The file dates from 2018 when the cron library was created. Since than a lot of changes were made.
To make the test compile and run, one should add step by step the needed .h and .c files and clone the relevant repos (mongoose-os, frozen, etc.).
Thanks! I am just realising this fact as I followed the tutorial linked by Klimbot and even after running mos build --platform esp32 --local --verbose I still do not get any kind of directory structure that allows the Makefile to run.
What I think I will try is to make frozen and common folders directly in my local copy of the cron repo, copy the requisite files directly from the mongoose-os directory, and then get the Makefile to point to these folders rather than to the frozen and common folders in some mythical grandparent directory like they currently point.
I will continue working on this and will update this thread later on with what worked (if I manage to get the tests to run).
As an update, cloning the cron repo and then copying in all the files referenced by the Makefile (a la carte from the mjs, mongoose-os, and mongoose repos) does indeed produce a compilable and runnable version of ./cron_test in the test folder of cron. (Here is a link to my fork if you would like to see exactly what I did.)
Unfortunately the tests do not actually pass, but since that is a different issue entirely, I have created a new thread for it, and the main topic of this thread has been resolved.