Skip to content

Commit

Permalink
Merge pull request #204 from dpostorivo/ignore_opt
Browse files Browse the repository at this point in the history
added with-ignore option to Ceedling new (Thanks @dpostorivo !)
  • Loading branch information
mvandervoord committed Nov 2, 2017
2 parents 5aa5674 + 4ab5d32 commit 2f905d4
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 8 deletions.
5 changes: 5 additions & 0 deletions assets/default_gitignore
@@ -0,0 +1,5 @@
build/artifacts
build/gcov
builld/logs
build/temp
build/test
14 changes: 11 additions & 3 deletions bin/ceedling
Expand Up @@ -34,6 +34,9 @@ unless (project_found)
method_option :no_docs, :type => :boolean, :default => false, :desc => "No docs in vendor directory"
method_option :nodocs, :type => :boolean, :default => false
method_option :as_gem, :type => :boolean, :default => false, :desc => "Create the scaffold using Ceedling as a gem instead of filling in the vendor directory. Implies --no-docs."
method_option :asgem, :type => :boolean, :default => false
method_option :with_ignore, :type => :boolean, :default => false, :desc => "Create a gitignore file for ignoring ceedling generated files."
method_option :withignore, :type => :boolean, :default => false
method_option :no_configs, :type => :boolean, :default => false, :desc => "Don't install starter configuration files."
method_option :noconfigs, :type => :boolean, :default => false
def new(name, silent = false)
Expand All @@ -52,9 +55,10 @@ unless (project_found)
no_commands do
def copy_assets_and_create_structure(name, silent=false, force=false, options = {})

no_docs = options[:no_docs] || options[:nodocs] || false
no_configs = options[:no_configs] || options[:noconfigs] || false
as_gem = options[:as_gem] || options[:asgem] || false
no_docs = options[:no_docs] || options[:nodocs] || false
no_configs = options[:no_configs] || options[:noconfigs] || false
as_gem = options[:as_gem] || options[:asgem] || false
with_ignore = options[:with_ignore] || options[:withignore] || false

ceedling_path = File.join(name, 'vendor', 'ceedling')
source_path = File.join(name, 'src')
Expand Down Expand Up @@ -138,6 +142,10 @@ unless (project_found)
end
end

if (with_ignore)
copy_file(File.join('assets', 'default_gitignore'), File.join(name, '.gitignore'), :force => force)
end

unless silent
puts "\n"
puts "Project '#{name}' #{force ? "upgraded" : "created"}!"
Expand Down
2 changes: 1 addition & 1 deletion spec/gcov/gcov_deployment_spec.rb
Expand Up @@ -44,7 +44,7 @@
it "should be testable" do
@c.with_context do
Dir.chdir "temp_sensor" do
@output = `bundle exec ruby -S ceedling gcov:all`
@output = `bundle exec ruby -S ceedling gcov:all 2>&1`
expect(@output).to match(/TESTED:\s+47/)
expect(@output).to match(/PASSED:\s+47/)

Expand Down
16 changes: 12 additions & 4 deletions spec/spec_system_helper.rb
Expand Up @@ -186,6 +186,14 @@ def can_create_projects
end
end

def has_an_ignore
@c.with_context do
Dir.chdir @proj_name do
expect(File.exists?(".gitignore")).to eq true
end
end
end

def can_upgrade_projects
@c.with_context do
output = `bundle exec ruby -S ceedling upgrade #{@proj_name} 2>&1`
Expand Down Expand Up @@ -242,7 +250,7 @@ def can_test_projects_with_success
FileUtils.cp test_asset_path("example_file.c"), 'src/'
FileUtils.cp test_asset_path("test_example_file_success.c"), 'test/'

output = `bundle exec ruby -S ceedling test:all`
output = `bundle exec ruby -S ceedling test:all 2>&1`
expect($?.exitstatus).to match(0) # Since a test either pass or are ignored, we return success here
expect(output).to match(/TESTED:\s+\d/)
expect(output).to match(/PASSED:\s+\d/)
Expand All @@ -259,7 +267,7 @@ def can_test_projects_with_fail
FileUtils.cp test_asset_path("example_file.c"), 'src/'
FileUtils.cp test_asset_path("test_example_file.c"), 'test/'

output = `bundle exec ruby -S ceedling test:all`
output = `bundle exec ruby -S ceedling test:all 2>&1`
expect($?.exitstatus).to match(1) # Since a test fails, we return error here
expect(output).to match(/TESTED:\s+\d/)
expect(output).to match(/PASSED:\s+\d/)
Expand All @@ -276,7 +284,7 @@ def can_test_projects_with_compile_error
FileUtils.cp test_asset_path("example_file.c"), 'src/'
FileUtils.cp test_asset_path("test_example_file_boom.c"), 'test/'

output = `bundle exec ruby -S ceedling test:all`
output = `bundle exec ruby -S ceedling test:all 2>&1`
expect($?.exitstatus).to match(1) # Since a test explodes, we return error here
expect(output).to match(/ERROR: Ceedling Failed/)
end
Expand Down Expand Up @@ -399,7 +407,7 @@ def handles_creating_the_same_module_twice_using_the_module_plugin
expect($?.exitstatus).to match(0)
expect(output).to match(/Generate Complete/i)

output = `bundle exec ruby -S ceedling module:create[unicorns]`
output = `bundle exec ruby -S ceedling module:create[unicorns] 2>&1`
expect($?.exitstatus).to match(1)
expect(output).to match(/ERROR: Ceedling Failed/)

Expand Down
17 changes: 17 additions & 0 deletions spec/system/deployment_spec.rb
Expand Up @@ -35,6 +35,23 @@
it { handles_destroying_a_module_that_does_not_exist_using_the_module_plugin }
end

describe "deployed in a project's `vendor` directory." do
before do
@c.with_context do
`bundle exec ruby -S ceedling new --with-ignore #{@proj_name} 2>&1`
end
end

it { can_create_projects }
it { has_an_ignore }
it { contains_a_vendor_directory }
it { contains_documentation }
it { can_test_projects_with_success }
it { can_use_the_module_plugin }
end



describe "deployed in a project's `vendor` directory without docs." do
before do
@c.with_context do
Expand Down

0 comments on commit 2f905d4

Please sign in to comment.