Prebuild scripts

441 views
Skip to first unread message

Łukasz Przeniosło

unread,
Mar 9, 2021, 3:29:50 AM3/9/21
to ThrowTheSwitch Forums
Hello there,
When using Ceedling, is there a way to configure the project file, so each time a test is run, before doing any actual work, Ceedling would call an *.sh script that was set in the project file?
I would appreciate all help.

Mark Vander Voord

unread,
Mar 9, 2021, 7:35:43 AM3/9/21
to ThrowTheSwitch Forums
You want to enable the command_hooks plugin and then set the :pre_test_fixture_execute hook to be your .sh script.


Mark

--
You received this message because you are subscribed to the Google Groups "ThrowTheSwitch Forums" group.
To unsubscribe from this group and stop receiving emails from it, send an email to throwtheswitc...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/throwtheswitch/275a78ac-7315-4da5-aae2-6406b9d089c5n%40googlegroups.com.

Łukasz Przeniosło

unread,
Mar 9, 2021, 5:19:59 PM3/9/21
to ThrowTheSwitch Forums
Noted, thank you!

Łukasz Przeniosło

unread,
Mar 10, 2021, 6:26:59 AM3/10/21
to ThrowTheSwitch Forums
Hi Mark,
What I added in my project file is the last line here:

:plugins:
  :load_paths:
    - vendor/ceedling/plugins
  :enabled:
    - stdout_pretty_tests_report
    - module_generator
    - command_hooks 

When I run ceedling test:all now I get:

ERROR: Ceedling plugin 'command_hooks' contains no rake or ruby class entry point. (Misspelled or missing files?)

Am I still missing something?

Łukasz Przeniosło

unread,
Mar 10, 2021, 6:58:13 AM3/10/21
to ThrowTheSwitch Forums
I have added the command_hooks directory with lib/command_hooks.rb inside to the vendor/ceedling/plugins dir, but I am still missing the rake file for that plugin. How can I get that? I feel like this is not the right way of installing a plugin.

Mark Vander Voord

unread,
Mar 10, 2021, 8:06:48 AM3/10/21
to ThrowTheSwitch Forums
Based on the line you just wrote, I'm getting a mixed message as to how you're using Ceedling. You either created this project to run with ceedling as a gem OR you are using ceedling from the local vendor folder. The details on how you use it vary slightly when configuring plugins. In EITHER case, you should not need to copy any plugins, which suggests something is configured wrong.

First, let's see which way your project is installed. If you're running from the gem, you would see this in your project.yml file:

:project:
   :which_ceedling: gem

If you're running from the vendor folder, you should be seeing this:

:project:
    :which_ceedling: vendor/ceedling

This decision drives where it should look for plugins. If you're using a gem, you should see this:

:plugins:
    :load_paths:
        - "#{Ceedling.load_path}"

If you're running as a vendor tool, you should see this:

:plugins:
    :load_paths:
        - vendor/ceedling/plugins

If you have a mismatch, fix it. If they appear to be correct, please let me know what version of Ceedling you're using and we'll try to figure out what is going on.

Mark



Łukasz Przeniosło

unread,
Mar 10, 2021, 8:19:18 AM3/10/21
to throwth...@googlegroups.com, Mark Vander Voord
Hi Mark,
Thank you for the follow up. It seems that I am using the vendor approach. What I am doing is building my demo project on an example downloaded from here. Since the configuration was complicated for me and I dont kbownhow the system works fully yet, I just took this examplea nd started tweaking it to my target MCU and actual files (my project. I dont mind transforming the project to "gem" based, but is it possible?).

I am afk now, but right after I am back I could upload the whole project as zip if you think this is ok.

Thank you!

--
Pozdrawiam / Best Regards,
Łukasz Przeniosło

You received this message because you are subscribed to a topic in the Google Groups "ThrowTheSwitch Forums" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/throwtheswitch/e53DEJw_r_k/unsubscribe.
To unsubscribe from this group and all its topics, send an email to throwtheswitc...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/throwtheswitch/CAAu8-XHrH0VeUK0XnkZVLShqphcNftU7Ut%3D_garwJY9P_W7k3A%40mail.gmail.com.

Mark Vander Voord

unread,
Mar 10, 2021, 8:34:58 AM3/10/21
to Łukasz Przeniosło, ThrowTheSwitch Forums
Ah. That example is using a VERY old version of Ceedling. It definitely needs updating.

I'd like to say that the only thing you should have to change is the two lines that I pointed out in the previous email (switch to using `gem` and change the plugin location). I'm not 100% sure that everything else will just work on the new version, but I'd say this is a good start. I can try to help through the other issues.

Mark

Łukasz Przeniosło

unread,
Mar 10, 2021, 8:37:01 AM3/10/21
to Mark Vander Voord, ThrowTheSwitch Forums
Thanks Mark, will try that today. Just so uou know, I have installed ceedling through gem. I am only using the project strucutre here (in the mentioned tutorial it is also suggested to install ceedling through gem).

--
Pozdrawiam / Best Regards,
Łukasz Przeniosło

Mark Vander Voord

unread,
Mar 10, 2021, 8:42:03 AM3/10/21
to Łukasz Przeniosło, ThrowTheSwitch Forums
:) That's good.

You can delete the entire vendor folder, update the two lines mentioned, and you will have migrated completely to use the new gem. Right now you've installed the new gem, but this particular project is still using the old one in the vendor folder. :)

Mark

Łukasz Przeniosło

unread,
Mar 10, 2021, 9:59:50 AM3/10/21
to Mark Vander Voord, ThrowTheSwitch Forums
Mark, so to answer you first question:

First, let's see which way your project is installed. If you're running from the gem, you would see this in your project.yml file:

:project:
   :which_ceedling: gem

If you're running from the vendor folder, you should be seeing this:

:project:
    :which_ceedling: vendor/ceedling

In my project file I had none of the lines. So I added the former now: :which_ceedling: gem

This decision drives where it should look for plugins. If you're using a gem, you should see this:

:plugins:
    :load_paths:
        - "#{Ceedling.load_path}"

If you're running as a vendor tool, you should see this:

:plugins:
    :load_paths:
        - vendor/ceedling/plugins

I had the second option in my project file. So I commented it out and added: - "#{Ceedling.load_path}". I have also renamed the vendor directory to vendor1 just for the sake of testing. But now the build cannot be completed:

#:/media/sf_repo/proj/trunk/driver/tests/cqm_demo$ ceedling test:all 
Traceback (most recent call last):
13: from /usr/local/bin/ceedling:23:in `<main>'
12: from /usr/local/bin/ceedling:23:in `load'
11: from /var/lib/gems/2.5.0/gems/ceedling-0.31.0/bin/ceedling:322:in `<top (required)>'
10: from /var/lib/gems/2.5.0/gems/ceedling-0.31.0/bin/ceedling:322:in `load'
 9: from rakefile.rb:2:in `<top (required)>'
 8: from rakefile.rb:2:in `load'
 7: from vendor/ceedling/lib/rakefile.rb:42:in `<top (required)>'
 6: from /media/sf_repo/proj/trunk/driver/tests/cqm_demo/vendor/ceedling/lib/setupinator.rb:25:in `do_setup'
 5: from /media/sf_repo/proj/trunk/driver/tests/cqm_demo/vendor/ceedling/lib/configurator.rb:160:in `find_and_merge_plugins'
 4: from /media/sf_repo/proj/trunk/driver/tests/cqm_demo/vendor/ceedling/lib/configurator.rb:160:in `each'
 3: from /media/sf_repo/proj/trunk/driver/tests/cqm_demo/vendor/ceedling/lib/configurator.rb:161:in `block in find_and_merge_plugins'
 2: from /media/sf_repo/proj/trunk/driver/tests/cqm_demo/vendor/ceedling/lib/system_wrapper.rb:17:in `module_eval'
 1: from /media/sf_repo/proj/trunk/driver/tests/cqm_demo/vendor/ceedling/lib/system_wrapper.rb:17:in `module_eval'
/media/sf_repo/proj/trunk/driver/tests/cqm_demo/vendor/ceedling/lib/system_wrapper.rb:17:in `module_eval': uninitialized constant Ceedling (NameError)
Did you mean?  CEEDLING_VENDOR

My project file is attached to this message. I would appreciate your further feedback. Thank you so far!

--
Pozdrawiam / Best Regards,
Łukasz Przeniosło
Przenioslo Electronics & Software
ul. Ofiar Katynia 21
72-100 Goleniów, Poland
VATID: PL5993131022
tel. +48 792 456 829
www.przenioslo.com


project.yml

Mark Vander Voord

unread,
Mar 10, 2021, 10:55:49 AM3/10/21
to Łukasz Przeniosło, ThrowTheSwitch Forums
Ah. You want to delete the rakefile from the project. It's no longer necessary and is formatted wrong.

Mark


Łukasz Przeniosło

unread,
Mar 10, 2021, 11:25:12 AM3/10/21
to ThrowTheSwitch Forums
This worked, thank you!
Seems like I am nearly there- the "- command_hooks" works, but I still dont get the output from my test executable:

  :pre_test_fixture_execute:
    :executable: echo
    :arguments:
      - "test123"
      - ${1}

Just wanted to print test123 to the console before the process is started after calling "ceedling test:all", but I see nothing in the output (the test is performed correctly though. Is there anything I am missing for this one? One can see that something is being run here:

Test 'test_cqm.c'
-----------------
Linking test_cqm.out...
Running Hook pre_test_fixture_execute...
Running test_cqm.out...
test/simulation/sim_test_fixture.rb:3: warning: Insecure world writable dir /opt/microchip/xc16/v1.41/bin in PATH, mode 040777

Łukasz Przeniosło

unread,
Mar 23, 2021, 6:42:14 AM3/23/21
to ThrowTheSwitch Forums
Hi Mark,
Im having the following problem. As part of my "pre build" script I would like to create the "src" directory, but it seems that there are no hooks available that would allow to run my script before it is checked whether src exists. I tried all with "pre_" prefix. I always get:

ceedling verbosity[4] test:all
(eval):1: warning: Insecure world writable dir /opt/microchip/xc16/v1.41/bin in PATH, mode 040777
ERROR: Config path [:paths][:source]['src'] does not exist on disk.
Traceback (most recent call last):
        7: from /usr/local/bin/ceedling:23:in `<main>'
        6: from /usr/local/bin/ceedling:23:in `load'
        5: from /var/lib/gems/2.5.0/gems/ceedling-0.31.0/bin/ceedling:329:in `<top (required)>'
        4: from /var/lib/gems/2.5.0/gems/ceedling-0.31.0/lib/ceedling.rb:66:in `load_project'
        3: from /var/lib/gems/2.5.0/gems/ceedling-0.31.0/lib/ceedling.rb:66:in `load'
        2: from /var/lib/gems/2.5.0/gems/ceedling-0.31.0/lib/ceedling/rakefile.rb:47:in `<top (required)>'
        1: from /var/lib/gems/2.5.0/gems/ceedling-0.31.0/lib/ceedling/setupinator.rb:32:in `do_setup'
/var/lib/gems/2.5.0/gems/ceedling-0.31.0/lib/ceedling/configurator.rb:304:in `validate': unhandled exception

Do you know any way around this?

Mark Vander Voord

unread,
Mar 23, 2021, 7:38:21 AM3/23/21
to ThrowTheSwitch Forums
That's a really good question. Rake's first task is to trace through dependencies and it does that while it's figuring out what you're even asking it to do. I'm not sure if we could add an earlier hook. maybe?

I'm not sure what you're using it for, but is it a situation where you could leave the generated src off your paths lists and then add it directly to your compiler calls when it's needed so that it had a chance to be built first?

Łukasz Przeniosło

unread,
Mar 23, 2021, 7:40:52 AM3/23/21
to ThrowTheSwitch Forums
Hi Mark, thank you for your answer. My case is very simple: I cannot commit empty dir's to GIT (need the src folder). Thats why I wanted to create it each time before Ceedling is called. Currently I am incorporating some workaround with .gitignore + .gitkeep, but its not very pretty. 
Reply all
Reply to author
Forward
0 new messages