ThrowTheSwitch / Ceedling

Ruby-based unit testing and build system for C projects

Home Page:http://throwtheswitch.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Ceedling not working with Ruby 3.2.2

usmanmehmoodSSP opened this issue · comments

I did a fresh install of Ceedling, and it is incompatible with Ruby 3.2.2.

ceedling example temp_sensor
C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/ceedling-0.31.1/bin/ceedling:12:in `<top (required)>': undefined method `exists?' for File:Class (NoMethodError)

  project_found = File.exists?(main_filepath)
                      ^^^^^^^^
Did you mean?  exist?
        from C:/Ruby32-x64/bin/ceedling:32:in `load'
        from C:/Ruby32-x64/bin/ceedling:32:in `<main>'

I tried making changes manually in the ceedling Ruby files, but there's only so many things I can fix without breaking other things in a codebase and a language I know nothing about. And I am also finding it difficult to downgrade Ruby.

I do understand that Ceedling is compatible with Ruby 2.something and that it cannot be made compatible with the latest Ruby release. My request is to kindly include the specific instruction to install the compatible Ruby version in the tutorial at your website and where to download it from. And if possible, also instructions on how to downgrade to the correct Ruby version.

Thanks in advance.

Ceedling CAN be made compatible with Ruby 3 and IS already. There's an in-progress gem working towards the next release which has Ruby 3 compatibility under Releases. It seems to work solid for anyone not using preprocessing at the moment, but the preprocessor support is currently being updated and isn't working in that branch.

I had exact same error with Ruby 3.2. It seems to be due to the use of exists? method, which is deprecated. I think that since ruby 3.2 only the exist? one is recognized.

Correct. As I mention above, it's been fixed already if you grab the pre-release gem.

Noted, I will try the pre-release gem whenever I get the time to do so. In the meantime should this issue be closed?

Sorry, where can I find pre-release gem?

Hi, I've just installed ceedling 0.31.1 and it does not work with ruby 3.2.2 as stated in this issue.
It should be better documented which ruby version ceedling is compatible to.
https://rubygems.org/gems/ceedling/versions/0.31.1 mentions REQUIRED RUBY VERSION: >= 2.4.0

As mentioned above, that was true when this version was released. This issue has been resolved. Just grab the pre-release gem.

I took the 0.32 version and it does not work. "ceedling test" does not compile foo.c even if test_foo.c includes foo.h.
I then installed ruby 2.7.8 and got the ceedling 0.31 and the issue is gone. I will stick with these versions then.

Im facing the same issue. I installed as suggested the pre-release version, to be precise i installed 0.32.0-c67c010 , but its still broken. When can we expect a fix?
ruby vendor\ceedling\bin\ceedling clobber vendor/ceedling/bin/ceedling:12:in

': undefined method `exists?' for File:Class (NoMethodError)

project_found = File.exists?(main_filepath)

                  ^^^^^^^^

Did you mean? exist?`

eedling version Welcome to Ceedling! Calling DidYouMean::SPELL_CHECKERS.merge!(error_name => spell_checker)' has been deprecated. Please call DidYouMean.correct_error(error_name, spell_checker)' instead. Ceedling:: 0.32.0 CMock:: 2.5.4 Unity:: 2.5.4 CException:: 1.3.3
ruby -v ruby 3.2.2 (2023-03-30 revision e51014f9c0) [x64-mingw-ucrt]

My guess is that you updated the gem, but your vendored ceedling (the one inside your project) is still the old ceedling? You can delete and re-import the vendored ceedling, or you can change the :which_ceedling: line of your project.yml file to read gem.

Thanks for the swift reply. You are right, i did update my gem by running: gem update ceedling. I have now reverted everything. But i still get the error ruby vendor\ceedling\bin\ceedling clobber vendor/ceedling/bin/ceedling:12:in

': undefined method `exists?' for File:Class (NoMethodError)

project_found = File.exists?(main_filepath)

                  ^^^^^^^^

Did you mean? exist?`

How do i do this: "You can delete and re-import the vendored ceedling"?

Our upgrade process isn't awesome yet. The easiest way at the moment would be to do this:

  • delete your vendor directory and everything in it
  • outside of your project, run ceedling new temp_project --local
  • copy the vendor directory from the new temp_project to your project

There are also some breaking changes in the latest release that you run into, primarily regarding the way includes are handled. If you were relying on your headers being found in your source paths, then you will need to clone them to an include entry in your project.yml as well, like this:

:paths:
  :source:
    - folder1
    - folder2
  :include:
    - folder1
    - folder2

@mvandervoord I still get an issue with 'SPELL_CHECKERS' being deprecated:

image

I pulled the most recent release of the 0.32.0 pre-release candidate:

https://github.com/ThrowTheSwitch/Ceedling/releases/tag/0.32.0-c67c010

I also did a fresh install of Ruby 3.2.2. I have not yet created a project, this error comes up when trying to verify versions to ensure things installed correctly.

Thanks @mvandervoord for the upgrade process, it solved most of the wierd errors. Now it almost works and looks clean only that i get this when i run one of my test module:
`D:\temp\Test\Deploy\test\ceedling_test>ruby vendor\ceedling\bin\ceedling test:test_fls.c --trace
#<Thread:0x000001f6e96d1460 D:/temp/Test/Deploy/test/ceedling_test/vendor/ceedling/lib/ceedling/par_map.rb:8 run> terminated with exception (report_on_exception is true):
Preparing Build Paths...

Extracting Build Directive Macros

Parsing test_fls.c...

D:/temp/Test/Deploy/test/ceedling_test/vendor/ceedling/lib/ceedling/test_context_extractor.rb:168:in `gsub!': invalid byte sequence in UTF-8 (ArgumentError)

content.gsub!(/\/\/.*$/, '')
              ^^^^^^^^^^^^^
from D:/temp/Test/Deploy/test/ceedling_test/vendor/ceedling/lib/ceedling/test_context_extractor.rb:168:in `remove_comments'
from D:/temp/Test/Deploy/test/ceedling_test/vendor/ceedling/lib/ceedling/test_context_extractor.rb:111:in `extract_build_directives'
from D:/temp/Test/Deploy/test/ceedling_test/vendor/ceedling/lib/ceedling/test_context_extractor.rb:22:in `collect_build_directives'
from D:/temp/Test/Deploy/test/ceedling_test/vendor/ceedling/lib/ceedling/preprocessinator.rb:29:in `extract_test_build_directives'
from D:/temp/Test/Deploy/test/ceedling_test/vendor/ceedling/lib/ceedling/test_invoker.rb:76:in `block (2 levels) in setup_and_invoke'
from D:/temp/Test/Deploy/test/ceedling_test/vendor/ceedling/lib/ceedling/par_map.rb:11:in `block (2 levels) in par_map'

rake aborted!
ArgumentError: invalid byte sequence in UTF-8
D:/temp/Test/Deploy/test/ceedling_test/vendor/ceedling/lib/ceedling/test_context_extractor.rb:168:in gsub!' D:/temp/Test/Deploy/test/ceedling_test/vendor/ceedling/lib/ceedling/test_context_extractor.rb:168:in remove_comments'
D:/temp/Test/Deploy/test/ceedling_test/vendor/ceedling/lib/ceedling/test_context_extractor.rb:111:in extract_build_directives' D:/temp/Test/Deploy/test/ceedling_test/vendor/ceedling/lib/ceedling/test_context_extractor.rb:22:in collect_build_directives'
D:/temp/Test/Deploy/test/ceedling_test/vendor/ceedling/lib/ceedling/preprocessinator.rb:29:in extract_test_build_directives' D:/temp/Test/Deploy/test/ceedling_test/vendor/ceedling/lib/ceedling/test_invoker.rb:76:in block (2 levels) in setup_and_invoke'
D:/temp/Test/Deploy/test/ceedling_test/vendor/ceedling/lib/ceedling/par_map.rb:11:in `block (2 levels) in par_map'
Tasks: TOP => test:test_fls.c
(See full trace by running task with --trace)


OVERALL TEST SUMMARY

No tests executed.
`

my include paths look okay i guess:
:paths: :test: - +:test/** - -:test/support :source: - ../../input/swc_bsw/core/mcal/fls - ../../input/swc_bsw/pjspec/mcal_cfg/fls_cfg - ../../input/swc_bsw/pjspec/autosar_stack/integration/src - ../../input/swc_bsw/core/fls_if :include: - ../../input/swc_bsw/** - ../../src/** - ../../input/swc_com/** - ../../input/swc_sbc/** :support: - test/support :libraries: []

Do you have any hints here? Thanks in advance

I have put lots of effort in writing my testcases its unfortunate that Ceedling is broken with Ruby 3.2.0, And the amount of attention that this issue is given is quite low. Ill have to downgrade my Ruby installation, its too frustrating. The statement REQUIRED RUBY VERSION: >= 2.4.0 is just misleading! How unfortunate for such a great tool.

It appears the issue above is that the mentioned file contains an illegal character. Often this is a character from a foreign language or the like. Ruby has changed the way they handle these issues over time. The newer versions of Ruby are stricter about these issues.

Thanks, i cleaned up the non UTF-8 characters, now it almost works. But the change of the of how includes are handled brings up this error: `reparing Build Paths...

Extracting Build Directive Macros

Parsing test_fls.c...

Ingesting Test Configurations

Collecting search paths, flags, and defines for test_fls.c...

Collecting Testing Context

Extracting #include statements via preprocessor from test_fls.c...
Using fallback regex #include extraction for test_fls.c...
" -I"../../src/memory_placement/CRYPTO" -I"../../src/memory_placement/RTE" -I"../../src/memory_placement/SBC" -I"../../src/memory_placement/SCC_APP" -I"../../src/project_versions" -I"../../src/rte" -I"../../src/rte/cfg" -I"../../src/rte/extensions" -I"../../src/rte/generated" -I"../../src/rte/generated/service_headers" -I"../../src/rte/report" -I"../../src/xcp" -I"test/support" -I"build/test/mocks/test_fls" -I"build/vendor/unity/src" -I"build/vendor/cmock/src" -D"TEST=1" -D"CORE_ASSOCIATION=0" -DGNU_COMPILER -nostdinc "test/test_fls.c" 2>&1'

Produced output:
Die Befehlszeile ist zu lang.
And exited with status: [pid 14080 exit 1].

` command-line string limitation because of many include paths. Is there a way to go about this? I didnt have this problem in the older version.

Yes. The new Ceedling introduces more flexible includes handling, actually to handle exactly the sort of problem that you've run into. Here are two phases:

(1) Update your :paths: :include: section of your project yaml file to only include the directories that you want the majority of your tests to include.
(2) For tests that need additional include files, you can add the required directory(ies) to that test directly. For example, if I wanted to add the directory ../../src/project_versions to one of my test files, then in that test file (likely after it's #include statements), I'd add the following:

TEST_INCLUDE_PATH("../../src/project_versions")

In this way, you can control which include paths are used in each test. This keeps the list from getting too long. It also allows you to handle situations where there are multiple header files called the same thing, but located in different folders, etc.

This also lays the groundwork for future automatic optimizations, but those are not included at this time.

Ok, thanks. That's actually a very good idea. Updating paths went quickly, It finally runs, thanks alot for the support!!!

Some observation:
So I've noticed something that doesn't work anymore as before. Let's say I have a folder ../../src/common/inc with a bunch of include files, and since these files are used a lot, I would add this to the project.yml as my common include path. Inside this folder, I have a header file header_a.h (some legacy code) which has some weird includes, and I don't want to deal with them. So normally, I would add a new file with the same name in the support folder and remove the wierd includes. This way, when my test module is compiled, it would always use the new file located under support. Now this doesn't work anymore out of the box. It looks as if the support path is no longer default a default path. So you have to add TEST_INCLUDE_PATH("test/support") is this intentional?

No, this isn't intentional. Thanks for bringing it up.

Just to clarify:

  • the part where you ignore header_a.h seems to be working.
  • the part where support is automatically added to your path no longer seems to be working.

Correct?

i can only ignore a header file after i add TEST_INCLUDE_PATH("test/support") to my my test module, otherwise the compiler will prefer the original header, even though the new fake header is already in the support folder with all the definitions and function prototypes.

I also have another observation:
if i use standard includes e.g #include <time.h> ceedling does no longer know where the standard header files are located. Do i have to define the compiler includes additionally in project.yml?

I would like to second that gem install ceedling which installs ceedling 0.31.1 for me on Windows 11 does not work with Ruby 3.2.2. Until this issue is fixed, I request the README be modified accordingly and/or a check added to Ceedling to check for version compatibility.

Or you google and find this issue which clearly states there is a problem.

I test Ceedling for a new project and run into the same issue. Thanks for this thread which helped me to get it running with Ruby 2.7.8. This works fine and the Ceedling evaluation is positive. But I am now unsure whether I should really use ceedling for a new project when it only works with an end of life marked version of ruby. What is the perspective on solving the issue?

Hi @RickCaspar -- as you can see scrolling up further, it's already been solved. The new ceedling (0.32) works with new Ruby (3.0+). It's just working through the release process at the moment. :)