summaryrefslogtreecommitdiffstats
path: root/features/step_definitions/tbb_test_suite.rb
blob: 95aae757caf623b49cf092a23c7bffa5dc234768 (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
When /^I set up the TBB test suite environment$/ do
  next if @skip_steps_while_restoring_background
  @vm.execute_successfully(
    'git clone https://git-tails.immerda.ch/tor-browser-bundle-testsuite',
    LIVE_USER
  )
  @vm.execute_successfully(
    'cd tor-browser-bundle-testsuite && git submodule init',
    LIVE_USER
  )
  @vm.execute_successfully(
    'cd tor-browser-bundle-testsuite && git submodule update',
    LIVE_USER
  )
  @vm.execute_successfully('apt-get update')
  @vm.execute_successfully(
    'export DEBIAN_FRONTEND=noninteractive ;' +
    'cd /home/amnesia/tor-browser-bundle-testsuite && ' +
    './install-deps X'
  )
  @vm.execute_successfully(
    'cd tor-browser-bundle-testsuite && torsocks ./setup-virtualenv',
    LIVE_USER
  )
end

When /^the ([a-zA-Z0-9-]+) Mozmill test passes$/ do |test_name|
  next if @skip_steps_while_restoring_background
  @vm.execute_successfully(
    'export LD_LIBRARY_PATH=/usr/local/lib/tor-browser;' +
    'export MOZMILL_SCREENSHOTS=/tmp;' +
    'cd tor-browser-bundle-testsuite && ' +
    './virtualenv/bin/mozmill ' +
    '   -b /usr/local/lib/tor-browser/firefox ' +
    '   -p /home/amnesia/.tor-browser/profile.default ' +
    "-t ./mozmill-tests/tbb-tests/#{test_name}.js",
    LIVE_USER
  )
end

def run_selenium_test(test_name)
  @vm.execute_successfully(
    'export TBB_BIN=/usr/local/lib/tor-browser/firefox;' +
    'export TBB_PROFILE=/home/amnesia/.tor-browser/profile.default;' +
    "./virtualenv/bin/python ./selenium-tests/run_test #{test_name}",
    LIVE_USER
  )
end

Then /^all Selenium tests pass$/ do
  next if @skip_steps_while_restoring_background
  selenium_test_names = @vm.execute_successfully(
    'ls -1 selenium-tests/test_*.py', LIVE_USER
  ).stdout.chomp.sub(/^selenium-tests\/test_/, '').sub(/\.py$/, '').split
  STDERR.puts "selenium_test_names: #{selenium_test_names}"
  selenium_test_names.each do |test_name|
    run_selenium_test(test_name)
  end
end