Calendar: add FT sprint
[tails/test.git] / features / step_definitions / build.rb
blob1ebe39c041a7f5823289bdddca472531b164735f
1 require 'English'
3 Given /^Tails ([[:alnum:]~.]+) has been released$/ do |version|
4   create_git unless git_exists?
6   old_branch = current_branch
8   fatal_system 'git checkout --quiet stable'
9   old_entries = File.open('debian/changelog', &:read)
10   File.open('debian/changelog', 'w') do |changelog|
11     changelog.write(<<~END_OF_CHANGELOG)
12       tails (#{version}) stable; urgency=low
14         * New upstream release.
16        -- Tails developers <tails@boum.org>  Tue, 31 Jan 2012 15:12:57 +0100
18       #{old_entries}
19     END_OF_CHANGELOG
20   end
21   fatal_system "git commit --quiet debian/changelog -m 'Release #{version}'"
22   fatal_system "git tag '#{version.gsub('~', '-')}'"
24   if old_branch != 'stable'
25     fatal_system "git checkout --quiet '#{old_branch}'"
26     fatal_system "git merge    --quiet 'stable'"
27   end
28 end
30 Given /^Tails ([[:alnum:].-]+) has been tagged$/ do |version|
31   fatal_system "git tag '#{version}'"
32 end
34 Given /^Tails ([[:alnum:].]+) has not been released yet$/ do |version|
35   !File.exist? ".git/refs/tags/#{version}"
36 end
38 Given %r{^the last version mentioned in debian/changelog is ([[:alnum:]~.]+)$} do |version|
39   last = `dpkg-parsechangelog --show-field Version --count 1`.strip
40   raise StandardError, 'dpkg-parsechangelog failed.' if $CHILD_STATUS != 0
42   if last != version
43     fatal_system "debchange -v '#{version}' 'New upstream release'"
44   end
45 end
47 Given %r{^the last versions mentioned in debian/changelog are ([[:alnum:]~.]+) and ([[:alnum:]~.]+)$} do |version_a, version_b|
48   step "the last version mentioned in debian/changelog is #{version_a}"
49   step "the last version mentioned in debian/changelog is #{version_b}"
50 end
52 Given %r{^no frozen APT snapshot is encoded in config/APT_snapshots\.d$} do
53   ['debian', 'debian-security', 'torproject'].map do |origin|
54     File.open("config/APT_snapshots.d/#{origin}/serial", 'w+') do |serial|
55       serial.write("latest\n")
56     end
57   end
58 end
60 Given %r{^frozen APT snapshots are encoded in config/APT_snapshots\.d$} do
61   ['debian', 'torproject'].map do |origin|
62     File.open("config/APT_snapshots.d/#{origin}/serial", 'w+') do |serial|
63       serial.write("2016060602\n")
64     end
65   end
66   # We never freeze debian-security
67   File.open('config/APT_snapshots.d/debian-security/serial', 'w+') do |serial|
68     serial.write("latest\n")
69   end
70 end
72 Given %r{I am working on the ([[:alnum:]./_-]+) base branch$} do |branch|
73   create_git unless git_exists?
75   fatal_system "git checkout --quiet '#{branch}'" if current_branch != branch
77   File.open('config/base_branch', 'w+') do |base_branch_file|
78     base_branch_file.write("#{branch}\n")
79   end
80 end
82 Given /^I checkout the ([[:alnum:]~.-]+) tag$/ do |tag|
83   create_git unless git_exists?
84   fatal_system "git checkout --quiet #{tag}"
85 end
87 Given %r{I am working on the ([[:alnum:]./_-]+) branch based on ([[:alnum:]./_-]+)$} do |branch, base|
88   create_git unless git_exists?
90   if current_branch != branch
91     fatal_system "git checkout --quiet -b '#{branch}' '#{base}'"
92   end
94   File.open('config/base_branch', 'w+') do |base_branch_file|
95     base_branch_file.write("#{base}\n")
96   end
97 end
99 When /^I successfully run "?([[:alnum:] -]+)"?$/ do |command|
100   @output = `#{File.expand_path("../../../auto/scripts/#{command}", __FILE__)}`
101   if $CHILD_STATUS != 0
102     raise StandardError,
103           "#{command} failed. Exit code: #{$CHILD_STATUS}"
104   end
107 When /^I run "?([[:alnum:] -]+)"?$/ do |command|
108   @output = `#{File.expand_path("../../../auto/scripts/#{command}", __FILE__)}`
109   @exit_code = $CHILD_STATUS.exitstatus
112 Then /^I should see the ['"]?([[:alnum:].-]+)['"]? suite$/ do |suite|
113   @output.should have_suite(suite)
116 Then /^I should see only the ['"]?([[:alnum:].-]+)['"]? suite$/ do |suite|
117   assert_equal(1, @output.lines.count)
118   @output.should have_suite(suite)
121 Then /^I should not see the ['"]?([[:alnum:].-]+)['"]? suite$/ do |suite|
122   @output.should_not have_suite(suite)
125 Given %r{^the config/APT_overlays\.d directory is empty$} do
126   Dir.glob('config/APT_overlays.d/*').empty? \
127   || raise('config/APT_overlays.d/ is not empty')
130 Given %r{^config/APT_overlays\.d contains ['"]?([[:alnum:].-]+)['"]?$} do |suite|
131   FileUtils.touch("config/APT_overlays.d/#{suite}")
134 Then /^it should fail$/ do
135   assert_not_equal(0, @exit_code)
138 Given %r{^the (config/base_branch) file does not exist$} do |file|
139   File.delete(file)
142 Given %r{^the (config/APT_overlays\.d) directory does not exist$} do |dir|
143   Dir.rmdir(dir)
146 Given %r{^the config/base_branch file is empty$} do
147   File.truncate('config/base_branch', 0)
150 Then /^I should see the ([[:alnum:].-]+) tagged snapshot$/ do |tag|
151   @output.should have_tagged_snapshot(tag)
154 Then /^I should see a time\-based snapshot$/ do
155   @output.should have_time_based_snapshot