Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable the collection of test of a directory tree #657

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Add use_test_collections to the options of the generate_test_runner.rb
  • Loading branch information
Constantin Dullo committed Feb 9, 2023
commit a9d4dfe90a8d37d22be44ac6b873653c4358c9fe
11 changes: 7 additions & 4 deletions auto/generate_test_runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def self.default_options
cmdline_args: false,
omit_begin_end: false,
use_param_tests: false,
use_test_collections: false,
include_extensions: '(?:hpp|hh|H|h)',
source_extensions: '(?:cpp|cc|ino|C|c)'
}
Expand Down Expand Up @@ -95,7 +96,7 @@ def generate(input_file, output_file, tests, used_mocks, testfile_includes)
create_teardown(output)
create_suite_setup(output)
create_suite_teardown(output)
create_reset(output)
create_reset(output) unless @options[:use_test_collections]
create_run_test(output) unless tests.empty?
create_args_wrappers(output, tests)
create_main(output, input_file, tests, used_mocks)
Expand Down Expand Up @@ -301,14 +302,14 @@ def create_mock_management(output, mock_headers)
end

def create_setup(output)
return if @options[:has_setup]
return if @options[:has_setup] or @options[:use_test_collections]

output.puts("\n/*=======Setup (stub)=====*/")
output.puts("void #{@options[:setup_name]}(void) {}")
end

def create_teardown(output)
return if @options[:has_teardown]
return if @options[:has_teardown] or @options[:use_test_collections]

output.puts("\n/*=======Teardown (stub)=====*/")
output.puts("void #{@options[:teardown_name]}(void) {}")
Expand Down Expand Up @@ -376,7 +377,7 @@ def create_args_wrappers(output, tests)
end

def create_main(output, filename, tests, used_mocks)
output.puts("\n/*=======MAIN=====*/")
@options[:use_test_collections] ? output.puts("\n/*=======RUNNER=====*/") : output.puts("\n/*=======MAIN=====*/")
main_name = @options[:main_name].to_sym == :auto ? "main_#{filename.gsub('.c', '')}" : (@options[:main_name]).to_s
if @options[:cmdline_args]
if main_name != 'main'
Expand Down Expand Up @@ -552,7 +553,9 @@ def directory_iterator(dir, options)

# check if input file is a directory
if File.directory?(ARGV[0])
options[:use_test_collections] = true
directory_iterator(ARGV[0], options)
options[:use_test_collections] = false
else
executor(ARGV[0], ARGV[1], options)
end
Expand Down