Class: ConfiguratorSetup

Inherits:
Object show all
Defined in:
lib/ceedling/configurator_setup.rb

Instance Method Summary collapse

Instance Method Details

#build_constants_and_accessors(config, context) ⇒ Object



115
116
117
118
# File 'lib/ceedling/configurator_setup.rb', line 115

def build_constants_and_accessors(config, context)
  @configurator_builder.build_global_constants(config)
  @configurator_builder.build_accessor_methods(config, context)
end

#build_directory_structure(flattened_config) ⇒ Object



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/ceedling/configurator_setup.rb', line 47

def build_directory_structure(flattened_config)
  msg = "Build paths:"
  flattened_config[:project_build_paths].each do |path|
    msg += "\n - #{(path.nil? or path.empty?) ? '<empty>' : path}"
  end
  @loginator.log( msg, Verbosity::DEBUG )

  flattened_config[:project_build_paths].each do |path|
    if path.nil? or path.empty?
      raise CeedlingException.new( "An internal project build path subdirectory path is unexpectedly blank" )
    end

    @file_wrapper.mkdir( path )
  end
end

#build_project_collections(flattened_config) ⇒ Object



92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/ceedling/configurator_setup.rb', line 92

def build_project_collections(flattened_config)
  # Iterate through all entries in paths section and expand any & all globs to actual paths
  flattened_config.merge!( @configurator_builder.expand_all_path_globs( flattened_config ) )

  flattened_config.merge!( @configurator_builder.collect_vendor_paths( flattened_config ) )
  flattened_config.merge!( @configurator_builder.collect_source_and_include_paths( flattened_config ) )
  flattened_config.merge!( @configurator_builder.collect_source_include_vendor_paths( flattened_config ) )
  flattened_config.merge!( @configurator_builder.collect_test_support_source_include_paths( flattened_config ) )
  flattened_config.merge!( @configurator_builder.collect_test_support_source_include_vendor_paths( flattened_config ) )
  flattened_config.merge!( @configurator_builder.collect_tests( flattened_config ) )
  flattened_config.merge!( @configurator_builder.collect_assembly( flattened_config ) )
  flattened_config.merge!( @configurator_builder.collect_source( flattened_config ) )
  flattened_config.merge!( @configurator_builder.collect_headers( flattened_config ) )
  flattened_config.merge!( @configurator_builder.collect_release_build_input( flattened_config ) )
  flattened_config.merge!( @configurator_builder.collect_existing_test_build_input( flattened_config ) )
  flattened_config.merge!( @configurator_builder.collect_release_artifact_extra_link_objects( flattened_config ) )
  flattened_config.merge!( @configurator_builder.collect_test_fixture_extra_link_objects( flattened_config ) )
  flattened_config.merge!( @configurator_builder.collect_vendor_framework_sources( flattened_config ) )

  return flattened_config
end

#build_project_config(ceedling_lib_path, logging_path, flattened_config) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/ceedling/configurator_setup.rb', line 33

def build_project_config(ceedling_lib_path, logging_path, flattened_config)
  # Housekeeping
  @configurator_builder.cleanup( flattened_config )

  # Add to hash values we build up from configuration & file system contents
  flattened_config.merge!( @configurator_builder.set_build_paths( flattened_config, logging_path ) )
  flattened_config.merge!( @configurator_builder.set_rakefile_components( ceedling_lib_path, flattened_config ) )
  flattened_config.merge!( @configurator_builder.set_release_target( flattened_config ) )
  flattened_config.merge!( @configurator_builder.set_build_thread_counts( flattened_config ) )
  flattened_config.merge!( @configurator_builder.set_test_preprocessor_accessors( flattened_config ) )

  return flattened_config
end

#inspectObject

Override to prevent exception handling from walking & stringifying the object variables. Object variables are gigantic and produce a flood of output.



28
29
30
31
# File 'lib/ceedling/configurator_setup.rb', line 28

def inspect
  # TODO: When identifying information is added to constructor, insert it into `inspect()` string
  return this.class.name
end

#validate_backtrace(config) ⇒ Object



682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
# File 'lib/ceedling/configurator_setup.rb', line 682

def validate_backtrace(config)
  valid = true

  options = [:none, :simple, :gdb]

  use_backtrace = config[:project][:use_backtrace]

  if !options.include?( use_backtrace )
    walk = @reportinator.generate_config_walk( [:project, :use_backtrace] )

    msg = "#{walk} is ':#{use_backtrace}' but must be one of {#{options.map{|o| ':' + o.to_s()}.join(', ')}}"
    @loginator.log( msg, Verbosity::ERRORS )
    valid = false
  end

  return valid
end

#validate_deep_preprocessor(config) ⇒ Object



578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
# File 'lib/ceedling/configurator_setup.rb', line 578

def validate_deep_preprocessor(config)
  valid = true

  options = [:none, :mocks]

  use_deep_preprocessor = config[:project][:use_deep_preprocessor]

  if !options.include?( use_deep_preprocessor )
    walk = @reportinator.generate_config_walk( [:project, :use_deep_preprocessor] )
    msg = "#{walk} is ':#{use_deep_preprocessor}' but must be one of {#{options.map{|o| ':' + o.to_s()}.join(', ')}}"
    @loginator.log( msg, Verbosity::ERRORS )
    valid = false
  end

  return valid
end

#validate_defines(_config) ⇒ Object



194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
# File 'lib/ceedling/configurator_setup.rb', line 194

def validate_defines(_config)
  defines = _config[:defines]

  return true if defines.nil?

  # Ensure config[:defines] is a hash
  if defines.class != Hash
    msg = ":defines must contain key / value pairs, not #{defines.class.to_s.downcase} (see docs for examples)"
    @loginator.log( msg, Verbosity::ERRORS )
    return false
  end

  valid = true

  # Validate that each context contains only a list of symbols or a matcher hash for :test / :preprocess context
  #
  # :defines:
  #   :<context>:
  #    - FOO
  #    - BAR
  #
  # or
  #
  # :defines:
  #   :test:
  #     :<matcher>:
  #       - FOO
  #       - BAR
  #   :preprocess:
  #     :<matcher>:
  #       - FOO
  #       - BAR

  defines.each_pair do |context, config|
    walk = @reportinator.generate_config_walk( [:defines, context] )

    # Special handling for configuration setting, not a hash context container
    next if context == :use_test_definition

    # Matcher contexts (only contexts that support matcher hashes)
    if context == :test or context == :preprocess
      if config.class != Array and config.class != Hash
        msg = "#{walk} entry '#{config}' must be a list or matcher, not #{config.class.to_s.downcase} (see docs for examples)"
        @loginator.log( msg, Verbosity::ERRORS )
        valid = false
      end

    # All other (simple) contexts
    else
      # Handle the (probably) common case of trying to use matchers for any context other than :test or :preprocess
      if config.class == Hash
        msg = "#{walk} entry '#{config}' must be a list--matcher hashes only availalbe for :test & :preprocess contexts (see docs for details)"
        @loginator.log( msg, Verbosity::ERRORS )
        valid = false
      # Catchall for any oddball entries
      elsif config.class != Array
        msg = "#{walk} entry '#{config}' must be a list, not #{config.class.to_s.downcase} (see docs for examples)"
        @loginator.log( msg, Verbosity::ERRORS )
        valid = false
      end
    end
  end

  # Validate simple option of lists applied across an entire context of any name
  # :defines:
  #   :<context>: # :test, :release, etc.
  #    - FOO
  #    - BAR

  defines.each_pair do |context, config|
    # Only validate lists of compilation symbols in this block (look for matchers in next block)
    next if config.class != Array

    # Handle any YAML alias referencing causing a nested array
    config.flatten!()

    # Ensure each item in list is a string
    config.each do |symbol|
      if symbol.class != String
        walk = @reportinator.generate_config_walk( [:defines, context] )
        msg = "#{walk} list entry #{symbol} must be a string, not #{symbol.class.to_s.downcase} (see docs for examples)"
        @loginator.log( msg, Verbosity::ERRORS )
        valid = false
      end
    end
  end

  # Validate :test / :preprocess context matchers (hash) if they exist
  # :defines:
  #   :test:
  #     :<matcher>: # Can be wildcard, substring, or regular expression in a string or symbol
  #       - FOO
  #       - BAR
  #   :preprocess:
  #     :<matcher>: # Can be wildcard, substring, or regular expression in a string or symbol
  #       - FOO
  #       - BAR

  contexts = [:test, :preprocess]

  contexts.each do |context|
    matchers = defines[context]

    # Skip processing if context isn't present or is present but is not a matcher hash
    next if matchers.nil? or matchers.class != Hash

    # Inspect each test matcher
    matchers.each_pair do |matcher, symbols|

      walk = @reportinator.generate_config_walk( [:defines, context, matcher] )
  
      # Ensure container associated with matcher is a list
      if symbols.class != Array
        msg = "#{walk} entry '#{symbols}' is not a list of compilation symbols but a #{symbols.class.to_s.downcase}"
        @loginator.log( msg, Verbosity::ERRORS )
        valid = false

        # Skip further validation if matcher value is not a list of symbols
        next          
      end

      # Handle any YAML alias nesting in array
      symbols.flatten!()

      # Ensure matcher itself is a Ruby symbol or string
      if matcher.class != Symbol and matcher.class != String
        msg = "#{walk} matcher is not a string or symbol"
        @loginator.log( msg, Verbosity::ERRORS )
        valid = false

        # Skip further validation if matcher key is not a symbol
        next
      end

      walk = @reportinator.generate_config_walk( [:defines, context, matcher] )

      # Ensure each item in compilation symbols list for matcher is a string
      symbols.each do |symbol|
        if symbol.class != String
          msg = "#{walk} entry '#{symbol}' is not a string"
          @loginator.log( msg, Verbosity::ERRORS )
          valid = false
        end
      end

      begin
        @configurator_validator.validate_matcher( matcher.to_s.strip() )
      rescue Exception => ex
        msg = "Matcher #{walk} contains #{ex.message}"
        @loginator.log( msg, Verbosity::ERRORS )
        valid = false
      end

    end
  end

  return valid
end

#validate_environment_vars(config) ⇒ Object



596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
# File 'lib/ceedling/configurator_setup.rb', line 596

def validate_environment_vars(config)
  environment = config[:environment]

  return true if environment.nil?

  # Ensure config[:environment] is an array (of simple hashes--validated below)
  if environment.class != Array
    msg = ":environment must contain a list of key / value pairs, not #{environment.class.to_s.downcase} (see docs for examples)"
    @loginator.log( msg, Verbosity::ERRORS )
    return false
  end

  valid = true
  keys = []

  # Ensure a hash for each entry
  environment.each do |entry|
    if entry.class != Hash
      msg = ":environment list entry #{entry} is not a key / value pair (ex. :var: value)"
      @loginator.log( msg, Verbosity::ERRORS )
      valid = false
    end
  end

  # Only end processing if an entry wasn't a hash
  return valid if !valid

  # Validate each hash entry
  environment.each do |entry|
    key_length = entry.keys.length()

    # Ensure entry is a hash with just a single key / value pair
    if key_length != 1
      msg = ":environment entry #{entry} does not specify exactly one key (see docs for examples)"
      @loginator.log( msg, Verbosity::ERRORS )
      valid = false
    end

    key   = entry.keys[0] # Get first (should be only) environment variable entry
    value = entry[key]    # Get associated value

    # Remember key for later duplication check
    keys << key.to_s.downcase

    # Ensure entry key is a symbol or string
    if key.class != Symbol and key.class != String
      msg = ":environment entry '#{key}' must be a symbol or string (:#{key})"
      @loginator.log( msg, Verbosity::ERRORS )
      valid = false

      # Skip validation of value if key is not a symbol or string
      next
    end

    # Ensure entry value is a string or list
    if not (value.class == String or value.class == Array)
      msg = ":environment entry #{key} is associated with #{value.class.to_s.downcase}, not a string or list (see docs for details)"
      @loginator.log( msg, Verbosity::ERRORS )
      valid = false
    end

    # If path is a list, ensure it's all strings
    if value.class == Array
      value.each do |item|
        if item.class != String
          msg = ":environment entry #{key} contains a list element '#{item}' (#{item.class.to_s.downcase}) that is not a string"
          @loginator.log( msg, Verbosity::ERRORS )
          valid = false
        end
      end
    end
  end

  # Find any duplicate keys
  dups = keys.uniq.select { |k| keys.count( k ) > 1 }
  
  if !dups.empty?
    msg = "Duplicate :environment entr#{dups.length() == 1 ? 'y' : 'ies'} #{dups.map{|d| ':' + d.to_s}.join( ', ' )} found"
    @loginator.log( msg, Verbosity::ERRORS )
    valid = false
  end
  
  return valid
end

#validate_flags(_config) ⇒ Object



354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
# File 'lib/ceedling/configurator_setup.rb', line 354

def validate_flags(_config)
  flags = _config[:flags]

  return true if flags.nil?

  # Ensure config[:flags] is a hash
  if flags.class != Hash
    msg = ":flags must contain key / value pairs, not #{flags.class.to_s.downcase} (see docs for examples)"
    @loginator.log( msg, Verbosity::ERRORS )
    # Immediately bail out
    return false
  end

  valid = true

  # Validate that each context has an operation hash
  # :flags
  #   :<context>:     # :test, :release, etc.
  #     :<operation>: # :compile, :link, etc.
  #       ...

  flags.each_pair do |context, operations|
    walk = @reportinator.generate_config_walk( [:flags, context] )

    if operations.nil?
      msg = "#{walk} operations key / value pairs are missing"
      @loginator.log( msg, Verbosity::ERRORS )

      valid = false
      next
    end

    if operations.class != Hash
      example = @reportinator.generate_config_walk( [:flags, context, :compile] )
      msg = "#{walk} context must contain :<operation> key / value pairs, not #{operations.class.to_s.downcase} '#{operations}' (ex. #{example})"
      @loginator.log( msg, Verbosity::ERRORS )

      # Immediately bail out
      return false
    end
  end

  if !!flags[:release] and !!flags[:release][:preprocess]
    walk = @reportinator.generate_config_walk( [:flags, :release, :preprocess] )
    msg = "Preprocessing configured at #{walk} is only supported in the :test context"
    @loginator.log( msg, Verbosity::ERRORS, LogLabels::WARNING )      
  end

  # Validate that each <:context> ↳ <:operation> contains only a list of flags or that :test ↳ <:operation> optionally contains a matcher hash
  #
  # :flags:
  #   :<context>:      # :test or :release
  #     :<operation>:  # :compile, :link, or :assemble (plus :preprocess for :test context)
  #      - --flag
  #
  # or
  #
  # :flags:
  #   :test:
  #     :<operation>:
  #       :<matcher>:
  #         - --flag

  flags.each_pair do |context, operations|
    operations.each_pair do |operation, config|
      walk = @reportinator.generate_config_walk( [:flags, context, operation] )

      if config.nil?
        msg = "#{walk} is missing a list or matcher hash"
        @loginator.log( msg, Verbosity::ERRORS )

        valid = false
        next
      end

      # :test context operations with lists or matchers (hashes)
      if context == :test
        if config.class != Array and config.class != Hash
          msg = "#{walk} entry '#{config}' must be a list or matcher hash, not #{config.class.to_s.downcase} (see docs for examples)"
          @loginator.log( msg, Verbosity::ERRORS )
          valid = false
        end

      # Other (simple) contexts
      else
        # Handle the (probably) common case of trying to use matchers for operations in any context other than :test
        if config.class == Hash
          msg = "#{walk} entry '#{config}' must be a list--matcher hashes only availalbe for :test context (see docs for details)"
          @loginator.log( msg, Verbosity::ERRORS )
          valid = false
        # Catchall for any oddball entries
        elsif config.class != Array
          msg = "#{walk} entry '#{config}' must be a list, not #{config.class.to_s.downcase} (see docs for examples)"
          @loginator.log( msg, Verbosity::ERRORS )
          valid = false
        end
      end
    end
  end

  # Validate simple option of lists of flags (strings) for <:context> ↳ <:operation>
  # :flags
  #   :<context>:
  #     :<operation>:
  #       - --flag

  flags.each_pair do |context, operations|
    operations.each_pair do |operation, flags|

      # Only validate lists of flags in this block (look for matchers in next block)
      next if flags.class != Array

      # Handle any YAML alias referencing causing a nested array
      flags.flatten!()

      # Ensure each item in list is a string
      flags.each do |flag|
        if flag.class != String
          walk = @reportinator.generate_config_walk( [:flags, context, operation] )
          msg = "#{walk} simple list entry '#{flag}' must be a string, not #{flag.class.to_s.downcase} (see docs for examples)"
          @loginator.log( msg, Verbosity::ERRORS )
          valid = false
        end
      end
    end
  end

  # Validate :test ↳ <:operation> matchers (hash) if they exist
  # :flags:
  #   :test:
  #     :<operation>: # :preprocess, :compile, :assemble, :link
  #       :<matcher>: # Can be wildcard, substring, or regular expression as a Ruby string or symbol
  #         - FOO
  #         - BAR

  # If there's no test context, we're done    
  test_context = flags[:test]
  return valid if test_context.nil?

  matchers_present = false
  test_context.each_pair do |operation, matchers|
    if matchers.class == Hash
      matchers_present = true
      break
    end
  end

  # If there's no matchers for :test ↳ <:operation>, we're done
  return valid if !matchers_present

  # Inspect each :test ↳ <:operation> matcher
  test_context.each_pair do |operation, matchers|
    # Only validate matchers (skip simple lists of flags)
    next if matchers.class != Hash

    matchers.each_pair do |matcher, flags|
      # Ensure matcher itself is a Ruby symbol or string
      if matcher.class != Symbol and matcher.class != String
        walk = @reportinator.generate_config_walk( [:flags, :test, operation] )
        msg = "#{walk} entry '#{matcher}' is not a string or symbol"
        @loginator.log( msg, Verbosity::ERRORS )
        valid = false

        # Skip further validation if matcher key is not a string or symbol
        next
      end

      walk = @reportinator.generate_config_walk( [:flags, :test, operation, matcher] )

      # Ensure container associated with matcher is a list
      if flags.class != Array
        msg = "#{walk} entry '#{flags}' is not a list of command line flags but a #{flags.class.to_s.downcase}"
        @loginator.log( msg, Verbosity::ERRORS )
        valid = false

        # Skip further validation if matcher value is not a list of flags
        next          
      end

      # Handle any YAML alias nesting in array
      flags.flatten!()
      
      # Ensure each item in flags list for matcher is a string
      flags.each do |flag|
        if flag.class != String
          msg = "#{walk} entry '#{flag}' is not a string"
          @loginator.log( msg, Verbosity::ERRORS )
          valid = false
        end
      end

      begin
        @configurator_validator.validate_matcher( matcher.to_s.strip() )
      rescue Exception => ex
        msg = "Matcher #{walk} contains #{ex.message}"
        @loginator.log( msg, Verbosity::ERRORS )
        valid = false
      end

    end
  end

  return valid
end

#validate_paths(config) ⇒ Object



142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
# File 'lib/ceedling/configurator_setup.rb', line 142

def validate_paths(config)
  valid = true

  # Ceedling ensures [:unity_helper_path] is an array
  config[:cmock][:unity_helper_path].each do |path|
    valid &= @configurator_validator.validate_filepath_simple( path, :cmock, :unity_helper_path ) 
  end

  config[:plugins][:load_paths].each do |path|
    valid &= @configurator_validator.validate_filepath_simple( path, :plugins, :load_paths )
  end

  config[:paths].keys.sort.each do |key|
    valid &= @configurator_validator.validate_path_list(config, :paths, key)
    valid &= @configurator_validator.validate_paths_entries(config, key)
  end

  config[:files].keys.sort.each do |key|
    valid &= @configurator_validator.validate_path_list(config, :files, key)
    valid &= @configurator_validator.validate_files_entries(config, key)
  end

  return valid
end

#validate_plugins(config) ⇒ Object



745
746
747
748
749
750
751
752
753
754
755
756
757
# File 'lib/ceedling/configurator_setup.rb', line 745

def validate_plugins(config)
  missing_plugins =
    Set.new( config[:plugins][:enabled] ) -
    Set.new( @configurator_plugins.rake_plugins ) -
    Set.new( @configurator_plugins.programmatic_plugins.map {|p| p[:plugin]} )

  missing_plugins.each do |plugin|
    message = "Plugin '#{plugin}' not found in built-in or project Ruby load paths. Check load paths and plugin naming and path conventions."
    @loginator.log( message, Verbosity::ERRORS )
  end

  return ( (missing_plugins.size > 0) ? false : true )
end

#validate_required_section_values(config) ⇒ Object



131
132
133
134
135
136
137
138
139
# File 'lib/ceedling/configurator_setup.rb', line 131

def validate_required_section_values(config)
  validation = []
  validation << @configurator_validator.exists?(config, :project, :build_root)
  validation << @configurator_validator.exists?(config, :paths, :test)
  validation << @configurator_validator.exists?(config, :paths, :source)

  return false if (validation.include?(false))
  return true
end

#validate_required_sections(config) ⇒ Object



121
122
123
124
125
126
127
128
# File 'lib/ceedling/configurator_setup.rb', line 121

def validate_required_sections(config)
  validation = []
  validation << @configurator_validator.exists?(config, :project)
  validation << @configurator_validator.exists?(config, :paths)

  return false if (validation.include?(false))
  return true
end

#validate_test_preprocessor(config) ⇒ Object



560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
# File 'lib/ceedling/configurator_setup.rb', line 560

def validate_test_preprocessor(config)
  valid = true

  options = [:none, :all, :tests, :mocks]

  use_test_preprocessor = config[:project][:use_test_preprocessor]

  if !options.include?( use_test_preprocessor )
    walk = @reportinator.generate_config_walk( [:project, :use_test_preprocessor] )
    msg = "#{walk} is ':#{use_test_preprocessor}' but must be one of {#{options.map{|o| ':' + o.to_s()}.join(', ')}}"
    @loginator.log( msg, Verbosity::ERRORS )
    valid = false
  end

  return valid
end

#validate_test_runner_generation(config, include_test_case, exclude_test_case) ⇒ Object



177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
# File 'lib/ceedling/configurator_setup.rb', line 177

def validate_test_runner_generation(config, include_test_case, exclude_test_case)
  cmdline_args = config[:test_runner][:cmdline_args]

  # Test case filters in use
  test_case_filters = !include_test_case.empty? || !exclude_test_case.empty?

  # Test case filters are in use but test runner command line arguments are not enabled
  if (test_case_filters and !cmdline_args)
    msg = 'Test case filters cannot be used -- enable :test_runner ↳ :cmdline_args in your project configuration'
    @loginator.log( msg, Verbosity::ERRORS )
    return false
  end

  return true
end

#validate_threads(config) ⇒ Object



700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
# File 'lib/ceedling/configurator_setup.rb', line 700

def validate_threads(config)
  valid = true

  compile_threads = config[:project][:compile_threads]
  test_threads = config[:project][:test_threads]

  walk = @reportinator.generate_config_walk( [:project, :compile_threads] )

  case compile_threads
  when Integer
    if compile_threads < 1
      @loginator.log( "#{walk} must be greater than 0", Verbosity::ERRORS )
      valid = false
    end
  when Symbol
    if compile_threads != :auto
      @loginator.log( "#{walk} is neither an integer nor :auto", Verbosity::ERRORS ) 
      valid = false
    end
  else
    @loginator.log( "#{walk} is neither an integer nor :auto", Verbosity::ERRORS ) 
    valid = false
  end

  walk = @reportinator.generate_config_walk( [:project, :test_threads] )

  case test_threads
  when Integer
    if test_threads < 1
      @loginator.log( "#{walk} must be greater than 0", Verbosity::ERRORS )
      valid = false
    end
  when Symbol
    if test_threads != :auto
      @loginator.log( "#{walk} is neither an integer nor :auto", Verbosity::ERRORS ) 
      valid = false
    end
  else
    @loginator.log( "#{walk} is neither an integer nor :auto", Verbosity::ERRORS ) 
    valid = false
  end

  return valid
end

#validate_tools(config) ⇒ Object



167
168
169
170
171
172
173
174
175
# File 'lib/ceedling/configurator_setup.rb', line 167

def validate_tools(config)
  valid = true

  config[:tools].keys.sort.each do |tool|
    valid &= @configurator_validator.validate_tool( config:config, key:tool )
  end

  return valid
end

#vendor_frameworks_and_support_files(ceedling_lib_path, flattened_config) ⇒ Object



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/ceedling/configurator_setup.rb', line 63

def vendor_frameworks_and_support_files(ceedling_lib_path, flattened_config)
  # Copy Unity C files into build/vendor directory structure
  @file_wrapper.cp_r(
    # '/.' to cause cp_r to copy directory contents
    File.join( flattened_config[:unity_vendor_path], UNITY_LIB_PATH, '/.' ),
    flattened_config[:project_build_vendor_unity_path]
  )

  # Copy CMock C files into build/vendor directory structure
  @file_wrapper.cp_r(
    # '/.' to cause cp_r to copy directory contents
    File.join( flattened_config[:cmock_vendor_path], CMOCK_LIB_PATH, '/.' ),
    flattened_config[:project_build_vendor_cmock_path]
  ) if flattened_config[:project_use_mocks]

  # Copy CException C files into build/vendor directory structure
  @file_wrapper.cp_r(
    # '/.' to cause cp_r to copy directory contents
    File.join( flattened_config[:cexception_vendor_path], CEXCEPTION_LIB_PATH, '/.' ),
    flattened_config[:project_build_vendor_cexception_path]
  ) if flattened_config[:project_use_exceptions]

  # Copy backtrace debugging script into build/test directory structure
  @file_wrapper.cp_r(
    File.join( ceedling_lib_path, BACKTRACE_GDB_SCRIPT_FILE ),
    flattened_config[:project_build_tests_root]
  ) if flattened_config[:project_use_backtrace] == :gdb
end

#warnings_for_problematic_configs(config) ⇒ Object



759
760
761
762
# File 'lib/ceedling/configurator_setup.rb', line 759

def warnings_for_problematic_configs(config)
  warning_for_parameterized_tests_with_preprocessing( config )
  warning_for_deep_preprocessor_without_preprocessing( config )
end