Skip to content

[BUG] Inverted include filter in runner generator removes test headers instead of vendor files #1158

@dwhitters

Description

@dwhitters

Description

In generator.rb (line 155, tag v1.1.0-pre.1), the reject block that is intended to remove vendor files from runner #include directives has inverted logic. The ! negation causes reject to keep only vendor files and remove all test file headers from generated runners.

Comment says: "Further filter others to remove vendor files"

others = includes.reject do |include|  !VENDORS_FILES.include?( include.filename.ext() )  # BUG: negation inverts the filter

reject { |x| !VENDORS_FILES.include?(...) } is logically equivalent to select { |x| VENDORS_FILES.include?(...) }

The opposite of the stated intent.

Example

Test File

test_a.c

#include "unity.h"
#include "my_project_header.h"
#include "mock_some_header.h"

Generated Runner

test_a_runner.c

#include "unity.h"
/* MISSING PROJECT HEADER INCLUDE */
#include "mock_some_header.h"

Impact

When :use_test_preprocessor: :mocks is configured, generated test runners do not #include the test file project includes. Any constants defined in the project header file(s) are unresolved, causing compilation failures across the entire test suite:

Steps to Reproduce

Use Ceedling v1.1.0-pre.1 (commit 7c2cd26)

  1. Configure a project with:
    :project:  :use_test_preprocessor: :mocks
  2. Create a test file with project-specific includes
  3. Run ceedling test:all
  4. Observe missing project-specific includes in the runner, and resulting compilation errors.

Expected Behavior

The generated test runner includes all non-vendor headers (test file headers, mock headers, application headers). Vendor files are filtered out since Unity's runner generator adds them itself.

Actual Behavior

The generated test runner includes only vendor headers and strips all project-specific headers, breaking any test that relies on constants, macros, or declarations from its own header.

Fix

Remove the erroneous ! negation:

# Further filter others to remove vendor files     
others = includes.reject do |include|
-  !VENDORS_FILES.include?( include.filename.ext() ) 
+ VENDORS_FILES.include?( include.filename.ext() )  
end

Environment

Ceedling v1.1.0-pre.1 (commit 7c2cd26)
Ruby 3.3.0
gcc-9 / Linux x86_64
CMock 2.6.1, Unity 2.6.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions