From da080c472fc415b0ce918f4dd4a1ab143bb1bca4 Mon Sep 17 00:00:00 2001 From: Philip Hands Date: Mon, 14 Mar 2016 15:36:16 +0100 Subject: rough attempt to grab the good cucumber bits from recent tails --- features/step_definitions/build.rb | 62 ++++++++++++++++++++++++++++++++------ 1 file changed, 53 insertions(+), 9 deletions(-) (limited to 'features/step_definitions/build.rb') diff --git a/features/step_definitions/build.rb b/features/step_definitions/build.rb index 2e597a4d..fd001ff4 100644 --- a/features/step_definitions/build.rb +++ b/features/step_definitions/build.rb @@ -1,6 +1,8 @@ Given /^Tails ([[:alnum:].]+) has been released$/ do |version| create_git unless git_exists? + old_branch = current_branch + fatal_system "git checkout --quiet stable" old_entries = File.open('debian/changelog') { |f| f.read } File.open('debian/changelog', 'w') do |changelog| @@ -16,6 +18,11 @@ END_OF_CHANGELOG end fatal_system "git commit --quiet debian/changelog -m 'Release #{version}'" fatal_system "git tag '#{version}'" + + if old_branch != 'stable' + fatal_system "git checkout --quiet '#{old_branch}'" + fatal_system "git merge --quiet 'stable'" + end end Given /^Tails ([[:alnum:].-]+) has been tagged$/ do |version| @@ -26,7 +33,7 @@ Given /^Tails ([[:alnum:].]+) has not been released yet$/ do |version| !File.exists? ".git/refs/tags/#{version}" end -Given /^last released version mentioned in debian\/changelog is ([[:alnum:]~.]+)$/ do |version| +Given /^the last version mentioned in debian\/changelog is ([[:alnum:]~.]+)$/ do |version| last = `dpkg-parsechangelog | awk '/^Version: / { print $2 }'`.strip raise StandardError.new('dpkg-parsechangelog failed.') if $? != 0 @@ -35,37 +42,74 @@ Given /^last released version mentioned in debian\/changelog is ([[:alnum:]~.]+) end end -Given %r{I am working on the ([[:alnum:]./_-]+) branch$} do |branch| +Given %r{I am working on the ([[:alnum:]./_-]+) base branch$} do |branch| create_git unless git_exists? - current_branch = `git branch | awk '/^\*/ { print $2 }'`.strip - raise StandardError.new('git-branch failed.') if $? != 0 - if current_branch != branch fatal_system "git checkout --quiet '#{branch}'" end + + File.open('config/base_branch', 'w+') do |base_branch_file| + base_branch_file.write("#{branch}\n") + end end Given %r{I am working on the ([[:alnum:]./_-]+) branch based on ([[:alnum:]./_-]+)$} do |branch, base| create_git unless git_exists? - current_branch = `git branch | awk '/^\*/ { print $2 }'`.strip - raise StandardError.new('git-branch failed.') if $? != 0 - if current_branch != branch fatal_system "git checkout --quiet -b '#{branch}' '#{base}'" end + + File.open('config/base_branch', 'w+') do |base_branch_file| + base_branch_file.write("#{base}\n") + end end -When /^I run ([[:alnum:]-]+)$/ do |command| +When /^I successfully run ([[:alnum:]-]+)$/ do |command| @output = `#{File.expand_path("../../../auto/scripts/#{command}", __FILE__)}` raise StandardError.new("#{command} failed. Exit code: #{$?}") if $? != 0 end +When /^I run ([[:alnum:]-]+)$/ do |command| + @output = `#{File.expand_path("../../../auto/scripts/#{command}", __FILE__)}` + @exit_code = $?.exitstatus +end + Then /^I should see the ['"]?([[:alnum:].-]+)['"]? suite$/ do |suite| @output.should have_suite(suite) end +Then /^I should see only the ['"]?([[:alnum:].-]+)['"]? suite$/ do |suite| + assert_equal(1, @output.lines.count) + @output.should have_suite(suite) +end + Then /^I should not see the ['"]?([[:alnum:].-]+)['"]? suite$/ do |suite| @output.should_not have_suite(suite) end + +Given(/^the config\/APT_overlays\.d directory is empty$/) do + Dir.glob('config/APT_overlays.d/*').empty? \ + or raise "config/APT_overlays.d/ is not empty" +end + +Given(/^config\/APT_overlays\.d contains ['"]?([[:alnum:].-]+)['"]?$/) do |suite| + FileUtils.touch("config/APT_overlays.d/#{suite}") +end + +Then(/^it should fail$/) do + assert_not_equal(0, @exit_code) +end + +Given(/^the (config\/base_branch) file does not exist$/) do |file| + File.delete(file) +end + +Given(/^the (config\/APT_overlays\.d) directory does not exist$/) do |dir| + Dir.rmdir(dir) +end + +Given(/^the config\/base_branch file is empty$/) do + File.truncate('config/base_branch', 0) +end -- cgit v1.2.3-70-g09d2