Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ Metrics/AbcSize:
- 'lib/ceedling/test_invoker/test_build_planner.rb'
- 'lib/ceedling/test_invoker/test_build_setup.rb'
- 'lib/ceedling/test_invoker/test_pipeline_manager.rb'
- 'lib/ceedling/tool_executor.rb'
- 'lib/ceedling/tool_executor_helper.rb'
- 'lib/ceedling/tools/tool_executor.rb'
- 'lib/ceedling/tools/tool_executor_helper.rb'
- 'plugins/beep/lib/beep.rb'
- 'plugins/bullseye/lib/bullseye.rb'
- 'plugins/cppcheck/lib/cppcheck.rb'
Expand Down Expand Up @@ -184,7 +184,7 @@ Metrics/ClassLength:
- 'lib/ceedling/test_invoker/test_build_planner.rb'
- 'lib/ceedling/test_invoker/test_build_setup.rb'
- 'lib/ceedling/test_invoker/test_pipeline_manager.rb'
- 'lib/ceedling/tool_executor.rb'
- 'lib/ceedling/tools/tool_executor.rb'
- 'plugins/bullseye/lib/bullseye.rb'
- 'plugins/cppcheck/lib/cppcheck.rb'
- 'plugins/dependencies/lib/dependencies.rb'
Expand Down Expand Up @@ -237,8 +237,8 @@ Metrics/CyclomaticComplexity:
- 'lib/ceedling/test_invoker/test_build_executor.rb'
- 'lib/ceedling/test_invoker/test_build_planner.rb'
- 'lib/ceedling/test_invoker/test_pipeline_manager.rb'
- 'lib/ceedling/tool_executor.rb'
- 'lib/ceedling/tool_executor_helper.rb'
- 'lib/ceedling/tools/tool_executor.rb'
- 'lib/ceedling/tools/tool_executor_helper.rb'
- 'plugins/bullseye/lib/bullseye.rb'
- 'plugins/cppcheck/lib/cppcheck.rb'
- 'plugins/dependencies/lib/dependencies.rb'
Expand Down Expand Up @@ -315,8 +315,8 @@ Metrics/MethodLength:
- 'lib/ceedling/test_invoker/test_build_setup.rb'
- 'lib/ceedling/test_invoker/test_invoker.rb'
- 'lib/ceedling/test_invoker/test_pipeline_manager.rb'
- 'lib/ceedling/tool_executor.rb'
- 'lib/ceedling/tool_executor_helper.rb'
- 'lib/ceedling/tools/tool_executor.rb'
- 'lib/ceedling/tools/tool_executor_helper.rb'
- 'lib/ceedling/yaml_wrapper.rb'
- 'plugins/beep/lib/beep.rb'
- 'plugins/bullseye/config/defaults_bullseye.rb'
Expand Down Expand Up @@ -383,8 +383,8 @@ Metrics/PerceivedComplexity:
- 'lib/ceedling/test_invoker/test_build_executor.rb'
- 'lib/ceedling/test_invoker/test_build_planner.rb'
- 'lib/ceedling/test_invoker/test_pipeline_manager.rb'
- 'lib/ceedling/tool_executor.rb'
- 'lib/ceedling/tool_executor_helper.rb'
- 'lib/ceedling/tools/tool_executor.rb'
- 'lib/ceedling/tools/tool_executor_helper.rb'
- 'plugins/bullseye/lib/bullseye.rb'
- 'plugins/cppcheck/lib/cppcheck.rb'
- 'plugins/fff/lib/fff_mock_generator.rb'
Expand Down
8 changes: 8 additions & 0 deletions docs/BreakingChanges.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ A release has a section only if it breaks something. Each section lists what cha

---

# [1.2.3] — Unreleased

## Each tool argument closes its own quotes

Tool validation now fails a tool whose `:executable` or argument leaves a quote open ([tool definitions](https://docs.throwtheswitch.org/Ceedling/1.2.0/configuration/reference/tools/#tool-definition-configurable-elements)). A tool that opens a quote in one `:arguments` entry and closes it in a later one worked before and now fails. Join such entries into one, as in `- -DMSG="a b"` in place of `- -DMSG="a` and `- b"`.

---

# [1.2.2] — 2026-10-31

## Test build output is organized by each test’s path from the project root
Expand Down
1 change: 1 addition & 0 deletions docs/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ Each release has its own section, listing only what changed in that release.
## 🌟 Added

- More and better guidance on compilation and linking failures that point to common root causes. More cases are covered with more complete explanations and consistent wording. Failure matching is expanded to help across a variety of toolchains. A test whose Partials macro, such as `PARTIAL_LOCAL_VAR()`, builds a name nothing declares gets guidance on the macro’s arguments.
- [#699](https://github.com/ThrowTheSwitch/Ceedling/issues/699) Added a check of each tool’s quoting when Ceedling validates its configuration ([tool definitions](https://docs.throwtheswitch.org/Ceedling/1.2.0/configuration/reference/tools/#tool-definition-configurable-elements)). A quote that `:executable` or an argument leaves open fails validation and names the entry. A typographic quote such as `”`, often pasted from a web page, draws a warning, and it is named as the likely cause of a quote left open. Before, a quote left open paired with one in a later argument. The build then failed with an unrelated error, such as `no input files`, or ran with corrupted paths.
- Added `PARTIAL_TYPE()` and `PARTIAL_LOCAL_TYPE()` to `ceedling.h`. Each names the type a [Partial](https://docs.throwtheswitch.org/Ceedling/1.2.0/testing-guide/partials/) gives a variable declared together with its type, so a test can declare another object of that type, such as a saved copy of a module’s state ([Partials macros](https://docs.throwtheswitch.org/Ceedling/1.2.0/reference/partials-macros/#variable-type-names)).
- [#1386](https://github.com/ThrowTheSwitch/Ceedling/issues/1386) Added [`:project` ↳ `:win_path_limit`](https://docs.throwtheswitch.org/Ceedling/1.2.0/configuration/reference/project/#win_path_limit) for Windows. `:classic`, the default, keeps Windows’ 260-character limit and now also flags a directory Ceedling creates past 248 characters. `:long_paths` and `:auto` stop long path logging warnings/errors on a host with long paths enabled, after checking once that Ruby can work with long paths. If that check fails, the new optional [`:windows_registry_query`](https://docs.throwtheswitch.org/Ceedling/1.2.0/configuration/reference/tools/#windows_registry_query) tool reads the host’s registry setting to name the cause. On Ruby before 4.0, which can create long paths but not list them, `:auto` keeps the classic limit, and `:long_paths` warns once about what can fail. The setting changes only what Ceedling reports.
- Added [`:partials` ↳ `:suppress_redundant_decls`](https://docs.throwtheswitch.org/Ceedling/1.2.0/configuration/reference/partials/#suppress_redundant_decls). Enabled by default, it wraps the prototypes a [Partial](https://docs.throwtheswitch.org/Ceedling/1.2.0/testing-guide/partials/) carries in GCC diagnostic pragmas, so `-Wredundant-decls` stays quiet where a carried prototype repeats a header’s declaration.
Expand Down
8 changes: 8 additions & 0 deletions docs/mkdocs/configuration/reference/tools.md
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,14 @@ line such as `LongPathsEnabled REG_DWORD 0x1` in its output.
characters. On Linux and macOS, a path holding `"`, `$`, a backtick, or
`\` can still break a command.

!!! note "Each argument closes its own quotes"
Ceedling checks the quoting in `:executable` and in each argument when it
validates a tool. A quote left open fails validation. Every argument must
close quotes it opens; a quoted value can’t span two entries in the list.
A typographic quote (e.g. `”`) pasted from elsewhere draws a warning. A
shell treats it as an ordinary character. On Windows, `'` is an ordinary
character too and is not checked.

1. `:name` - Simple name (i.e. "nickname") of tool beyond its executable name.
This is optional. If not explicitly set then Ceedling will form a name from
the tool’s YAML entry key.
Expand Down
2 changes: 1 addition & 1 deletion lib/ceedling/config/configurator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
require 'ceedling/filesystem/file_path_utils'
require 'ceedling/exceptions'
require 'ceedling/rake_app/rakefile_component_resolver'
require 'ceedling/tool_executor'
require 'ceedling/tools/tool_executor'
require 'deep_merge'

class Configurator
Expand Down
45 changes: 45 additions & 0 deletions lib/ceedling/tools/shell_quoting.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# =========================================================================
# Ceedling - Test-Centered Build System for C
# ThrowTheSwitch.org
# Copyright (c) 2010-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
# SPDX-License-Identifier: MIT
# =========================================================================

require 'ceedling/constants'

# Reads the quoting in one piece of a command line as the shell running it will.
#
# A tool's command reaches the shell as one string, so a quote one piece leaves open pairs
# with a quote in a later piece and the command's words shift. A typographic quote looks
# like a quote but is an ordinary character to every shell.
module ShellQuoting

TYPOGRAPHIC = %w[“ ” „ ‟ ‘ ’ ‚ ‛ « » ‹ ›].freeze

# Each alternative consumes one escaped character or one closed span, in that order, so a
# quote matched alone is one that never closes. A backslash escapes the character after
# it, except inside single quotes.
SPANS = /\\.|"(?:\\.|[^"\\])*"|'[^']*'|["']/m

# cmd.exe treats a single quote as an ordinary character
WINDOWS_SPANS = /\\.|"(?:\\.|[^"\\])*"|"/m

# The quote character `text` leaves open, or nil when every quote closes
def self.unclosed(text, windows:)
return scannable( text ).scan( windows ? WINDOWS_SPANS : SPANS ).find { |span| span == '"' or span == "'" }
end

# The distinct typographic quotes in `text`, in the order they first appear
def self.typographic(text)
return scannable( text ).each_char.select { |char| TYPOGRAPHIC.include?( char ) }.uniq
end

# `text` with invalid bytes replaced and everything from its first Ruby expansion through
# its last removed, since an expansion's own quotes are Ruby's, not the shell's. A quote
# between two expansions goes unread, so a mistake there is missed rather than invented.
def self.scannable(text)
return text.scrub.gsub( PATTERNS::RUBY_STRING_REPLACEMENT, '' )
end
private_class_method :scannable

end
File renamed without changes.
79 changes: 79 additions & 0 deletions lib/ceedling/tools/tool_quoting.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# =========================================================================
# Ceedling - Test-Centered Build System for C
# ThrowTheSwitch.org
# Copyright (c) 2010-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
# SPDX-License-Identifier: MIT
# =========================================================================

require 'ceedling/tools/shell_quoting'

# Finds the quoting problems in a tool definition, one entry at a time.
#
# Each entry that reaches the shell must close its own quotes, since a quote left open pairs
# with one in a later entry. A typographic quote is only a warning, since it may be meant
# literally, as in a string a define holds.
module ToolQuoting

# `error` is false for a warning
Finding = Struct.new( :field, :message, :error, keyword_init: true ) do
# An executable whose quote is unclosed names no file that can be looked for
def unclosed_executable?
return (error and field == :executable)
end
end

# The findings for `tool`'s :executable and arguments, in order
def self.findings(tool, name:, windows:)
return entries( tool ).filter_map { |field, text| finding( name, field, text, windows ) }
end

# Each [field, text] pair the command line is built from
def self.entries(tool)
arguments = [tool[:arguments]].flatten.flat_map { |element| expanded( element ) }
entries = [[:executable, tool[:executable]]] + arguments.map { |argument| [:arguments, argument] }

return entries.select { |_, text| text.is_a?( String ) }
end

# The text one argument contributes, as ToolExecutor expands it. A string is itself the
# text. A hash contributes its first key, the substitution string, and each string among
# that key's values. Anything else adds nothing to the command line.
def self.expanded(element)
return [element] if element.is_a?( String )
return [] unless element.is_a?( Hash ) and element.any?

substitution, values = element.first
return [substitution.to_s, *[values].flatten.grep( String )]
end

def self.finding(name, field, text, windows)
location = "#{name} ↳ :#{field} ➡️ `#{text}`"
quote = ShellQuoting.unclosed( text, windows: windows )
typographic = ShellQuoting.typographic( text )

return unclosed( location, field, quote, typographic ) if quote
return nil if typographic.empty?

message = "#{location} holds #{phrase( typographic )} Use \" or ' unless the characters are meant literally."
return Finding.new( field: field, message: message, error: false )
end

# An unclosed quote's error names any typographic quote as its likely cause
def self.unclosed(location, field, quote, typographic)
subject = (field == :executable) ? 'executable' : 'argument'
message = "#{location} leaves a #{quote} quote unclosed. Enclose the #{subject} with #{quote} quotes."
message += " It holds #{phrase( typographic )} Replace it with #{quote}." if typographic.any?

return Finding.new( field: field, message: message, error: true )
end

# The typographic quotes found, and what a shell makes of them
def self.phrase(typographic)
return "#{typographic.first}, a typographic quote that a shell treats as an ordinary character." if typographic.one?

return "#{typographic.join( ' ' )}, typographic quotes that a shell treats as ordinary characters."
end

private_class_method :entries, :expanded, :finding, :unclosed, :phrase

end
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@
require 'ceedling/constants'
require 'ceedling/filename_extension'
require 'ceedling/exceptions'
require 'ceedling/tools/tool_quoting'

# Confirms a tool's configuration can run before a build depends on it.
#
# A tool is valid when its executable can be found and its stderr redirect is a known
# option. The executable is an explicit path or a bare name searched on PATH, and either
# may omit the extension its file carries on disk. An executable built at run time, from
# an argument or a Ruby expansion, is left for the shell to resolve.
# A tool is valid when its executable and each argument close the quotes they open, its
# executable can be found and its stderr redirect is a known option. The executable is an
# explicit path or a bare name searched on PATH, and either may omit the extension its file
# carries on disk. An executable built at run time, from an argument or a Ruby expansion,
# is left for the shell to resolve.
class ToolValidator

constructor :file_wrapper, :loginator, :system_wrapper, :ruby_expandinator
Expand Down Expand Up @@ -63,16 +65,25 @@ def validate(tool:, name:nil, extension:nil, respect_optional:false, boom:false)
name = tool[:name] if name.nil? or name.empty?
extension ||= default_extension()

valid = validate_executable( tool:tool, name:name, extension:extension, respect_optional:respect_optional, boom:boom )

# Both checks run, so a tool with two problems reports both
# Every check runs, so a tool with several problems reports each. An executable whose
# quote is unclosed can't be found, and saying so would only repeat the quoting error.
findings = ToolQuoting.findings( tool, name:name, windows:@system_wrapper.windows? )
valid = validate_quoting( findings, boom )
valid &= validate_executable( tool:tool, name:name, extension:extension, respect_optional:respect_optional, boom:boom ) unless findings.any?( &:unclosed_executable? )
return valid & validate_stderr_redirect( tool:tool, name:name, boom:boom )
end

### Private ###

private

# An unclosed quote fails validation, and a typographic quote only warns
def validate_quoting(findings, boom)
findings.reject( &:error ).each { |finding| @loginator.log( finding.message, Verbosity::COMPLAIN ) }

return findings.select( &:error ).map { |finding| fail_validation( finding.message, boom ) }.all?
end

def validate_executable(tool:, name:, extension:, respect_optional:, boom:)
command = tool[:executable]
executable = ToolValidator.executable_from( command )
Expand Down
2 changes: 1 addition & 1 deletion plugins/command_hooks/lib/command_hooks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
require 'ceedling/constants'
require 'ceedling/exceptions'
require 'ceedling/plugins/plugin'
require 'ceedling/tool_executor'
require 'ceedling/tools/tool_executor'

COMMAND_HOOKS_ROOT_NAME = 'command_hooks'.freeze
COMMAND_HOOKS_SYM = COMMAND_HOOKS_ROOT_NAME.to_sym
Expand Down
2 changes: 1 addition & 1 deletion spec/integration/tool_executor_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# SPDX-License-Identifier: MIT
# =========================================================================

# Unlike spec/units/tool_executor_spec.rb, this spec wires the REAL ToolExecutor +
# Unlike spec/units/tools/tool_executor_spec.rb, this spec wires the REAL ToolExecutor +
# ToolExecutorHelper + SystemWrapper + SystemUtils + Loginator + Verbosinator +
# RubyExpandinator graph (see tool_executor_integration_helper.rb) and genuinely shells
# out through SystemWrapper#shell_capture3 (Open3.capture3). The one external dependency
Expand Down
4 changes: 2 additions & 2 deletions spec/integration/tool_validator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
# Whether a candidate file exists, how a quoted path with spaces resolves, and what PATH
# a process actually searches are facts a doubled file layer cannot prove. A real
# FileWrapper and SystemWrapper run here against real temp directories, with PATH set
# per example. The unit spec at spec/units/tool_validator_spec.rb owns every decision
# per example. The unit spec at spec/units/tools/tool_validator_spec.rb owns every decision
# observable through doubles alone.

require 'spec_helper'
require 'spec_integration_helper'
require 'fileutils'
require 'ceedling/tool_validator'
require 'ceedling/tools/tool_validator'
require 'ceedling/filesystem/file_wrapper'
require 'ceedling/system_wrapper'
require 'ceedling/ruby_expandinator'
Expand Down
6 changes: 3 additions & 3 deletions spec/support/integration/configurator_integration_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
require 'ceedling/ruby_expandinator'
require 'ceedling/filesystem/file_path_collection_utils'
require 'ceedling/filesystem/file_path_utils'
require 'ceedling/tool_validator'
require 'ceedling/tool_executor'
require 'ceedling/tool_executor_helper'
require 'ceedling/tools/tool_validator'
require 'ceedling/tools/tool_executor'
require 'ceedling/tools/tool_executor_helper'
require 'ceedling/setupinator'
require 'ceedling/config/config_walkinator'
require 'ceedling/config/configurator'
Expand Down
2 changes: 1 addition & 1 deletion spec/support/integration/spec_integration_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
require 'ceedling/includes/includes'
require 'ceedling/includes/include_factory'
require 'ceedling/preprocess/preprocessinator'
require 'ceedling/tool_executor'
require 'ceedling/tools/tool_executor'
require 'ceedling/quote_include_isolator'
require 'ceedling/preprocess/preprocessinator_includes_handler'
require 'ceedling/preprocess/preprocessinator_bare_includes_extractor'
Expand Down
4 changes: 2 additions & 2 deletions spec/support/integration/tool_executor_integration_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@

require 'rbconfig'

require 'ceedling/tool_executor'
require 'ceedling/tool_executor_helper'
require 'ceedling/tools/tool_executor'
require 'ceedling/tools/tool_executor_helper'
require 'ceedling/system_wrapper'
require 'ceedling/system_utils'
require 'ceedling/loginator'
Expand Down
2 changes: 1 addition & 1 deletion spec/units/config/configurator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
require 'ceedling/ruby_expandinator'
require 'ceedling/exceptions'
require 'ceedling/constants'
require 'ceedling/tool_executor'
require 'ceedling/tools/tool_executor'
require 'ceedling/config/config_walkinator'
require 'ceedling/config/configurator_builder'
require 'ceedling/system_utils'
Expand Down
2 changes: 1 addition & 1 deletion spec/units/plugins/console_reportinator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

require 'spec_helper'
require 'ceedling/filename_extension'
require 'ceedling/tool_executor'
require 'ceedling/tools/tool_executor'
require 'ceedling/constants'
require 'ceedling/exceptions'
require 'ceedling/filesystem/path_mirror'
Expand Down
2 changes: 1 addition & 1 deletion spec/units/plugins/reportgenerator_reportinator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# =========================================================================

require 'spec_helper'
require 'ceedling/tool_executor'
require 'ceedling/tools/tool_executor'
require 'ceedling/constants'
require 'ceedling/exceptions'
require 'ceedling/filesystem/file_path_utils'
Expand Down
2 changes: 1 addition & 1 deletion spec/units/preprocess/preprocessinator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
require 'spec_helper'
require 'ceedling/preprocess/preprocessinator'
require 'ceedling/includes/includes'
require 'ceedling/tool_executor'
require 'ceedling/tools/tool_executor'

RSpec.describe Preprocessinator do

Expand Down
Loading
Loading