2 require "#{Dir.pwd}/features/support/extra_hooks.rb"
6 # Force UTF-8. Ruby will default to the system locale, and if it is
7 # non-UTF-8, String-methods will fail when operating on non-ASCII
9 Encoding.default_external = Encoding::UTF_8
10 Encoding.default_internal = Encoding::UTF_8
14 raise StandardError.new("Command exited with #{$?}")
24 FileUtils.touch('config/base_branch')
25 Dir.mkdir('config/APT_overlays.d')
26 Dir.mkdir('config/APT_snapshots.d')
27 ['debian', 'debian-security', 'torproject'].map do |origin|
28 Dir.mkdir("config/APT_snapshots.d/#{origin}")
31 File.open('debian/changelog', 'w') do |changelog|
32 changelog.write(<<END_OF_CHANGELOG)
33 tails (0) stable; urgency=low
37 -- Tails developers <tails@boum.org> Mon, 30 Jan 2012 01:00:00 +0000
41 fatal_system "git init --quiet"
42 fatal_system "git config user.email 'tails@boum.org'"
43 fatal_system "git config user.name 'Tails developers'"
44 fatal_system "git add debian/changelog"
45 fatal_system "git commit --quiet debian/changelog -m 'First release'"
46 fatal_system "git branch -M stable"
47 fatal_system "git branch testing stable"
48 fatal_system "git branch devel stable"
49 fatal_system "git branch feature/jessie devel"
53 cmd = 'git rev-parse --symbolic-full-name --abbrev-ref HEAD'.split
54 branch = cmd_helper(cmd).strip
55 assert_not_equal("HEAD", branch, "We are in 'detached HEAD' state")
59 # In order: if git HEAD is tagged, return its name; if a branch is
60 # checked out, return its name; otherwise we are in 'detached HEAD'
61 # state, and we return the empty string.
63 cmd_helper("git describe --tags --exact-match #{current_commit}".split).strip
64 rescue Test::Unit::AssertionFailedError
67 rescue Test::Unit::AssertionFailedError
73 cmd_helper('git rev-parse HEAD'.split).strip
76 def current_short_commit
80 RSpec::Matchers.define :have_suite do |suite|
82 # e.g.: `deb http://deb.tails.boum.org/ 0.10 main contrib non-free`
83 %r{^deb +http://deb\.tails\.boum\.org/ +#{Regexp.escape(suite)} main}.match(string)
85 failure_message_for_should do |string|
86 "expected the sources to include #{suite}\nCurrent sources : #{string}"
88 failure_message_for_should_not do |string|
89 "expected the sources to exclude #{suite}\nCurrent sources : #{string}"
92 "expected an output with #{suite}"
96 RSpec::Matchers.define :have_tagged_snapshot do |tag|
98 # e.g.: `http://tagged.snapshots.deb.tails.boum.org/0.10`
99 %r{^http://tagged\.snapshots\.deb\.tails\.boum\.org/#{Regexp.escape(tag)}/[a-z-]+$}.match(string)
101 failure_message_for_should do |string|
102 "expected the mirror to be #{tag}\nCurrent mirror: #{string}"
104 failure_message_for_should_not do |string|
105 "expected the mirror not to be #{tag}\nCurrent mirror: #{string}"
108 "expected an output with #{tag}"
112 RSpec::Matchers.define :have_time_based_snapshot do |tag|
114 # e.g.: `http://time-based.snapshots.deb.tails.boum.org/debian/2016060602`
115 %r{^http://time\-based\.snapshots\.deb\.tails\.boum\.org/[^/]+/\d+}.match(string)
117 failure_message_for_should do |string|
118 "expected the mirror to be a time-based snapshot\nCurrent mirror: #{string}"
120 failure_message_for_should_not do |string|
121 "expected the mirror not to be a time-based snapshot\nCurrent mirror: #{string}"
124 "expected a time-based snapshot"