summaryrefslogtreecommitdiffstats
path: root/features/step_definitions/build.rb
blob: 2e597a4da4a856d25aa6809e066b94f1c19e2fc4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
Given /^Tails ([[:alnum:].]+) has been released$/ do |version|
  create_git unless git_exists?

  fatal_system "git checkout --quiet stable"
  old_entries = File.open('debian/changelog') { |f| f.read }
  File.open('debian/changelog', 'w') do |changelog|
    changelog.write(<<END_OF_CHANGELOG)
tails (#{version}) stable; urgency=low

  * New upstream release.

 -- Tails developers <tails@boum.org>  Tue, 31 Jan 2012 15:12:57 +0100

#{old_entries}
END_OF_CHANGELOG
  end
  fatal_system "git commit --quiet debian/changelog -m 'Release #{version}'"
  fatal_system "git tag '#{version}'"
end

Given /^Tails ([[:alnum:].-]+) has been tagged$/ do |version|
  fatal_system "git tag '#{version}'"
end

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|
  last = `dpkg-parsechangelog | awk '/^Version: / { print $2 }'`.strip
  raise StandardError.new('dpkg-parsechangelog failed.') if $? != 0

  if last != version
    fatal_system "debchange -v '#{version}' 'New upstream release'"
  end
end

Given %r{I am working on the ([[:alnum:]./_-]+) 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
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
end

When /^I run ([[:alnum:]-]+)$/ do |command|
  @output = `#{File.expand_path("../../../auto/scripts/#{command}", __FILE__)}`
  raise StandardError.new("#{command} failed. Exit code: #{$?}") if $? != 0
end

Then /^I should see the ['"]?([[:alnum:].-]+)['"]? suite$/ do |suite|
  @output.should have_suite(suite)
end

Then /^I should not see the ['"]?([[:alnum:].-]+)['"]? suite$/ do |suite|
  @output.should_not have_suite(suite)
end