aboutsummaryrefslogtreecommitdiff
path: root/bin/test-website
blob: 2e91f364b3e9f91252989de3e3ec368b27cdb343 (about) (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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/usr/bin/env ruby


USAGE = <<EOT
This is Mechanical-Rob - an automated web server tester for 
                         Genenetwork.org that uses the brilliant 
                         mechanize gem.

To use this software you need to install mechanize. Run it from
the root of the genenetwork2 source tree as, for example,

  ./bin/test-website http://localhost:5003/ (default)

If you are using the small deployment database you can use

  ./bin/test-website --skip -n

For more information see http://genenetwork.org/
                        
EOT
$stderr.print USAGE

require 'optparse'

options = { database: :small, link_checker: false}
opts = OptionParser.new do |o|
  o.banner = "Usage: #{File.basename($0)} [options] URL"
  
  o.on('-d','--database', String, 'Use database (default db_webqtl_s)') do |s|
    options[:database] =
      case s
      when 'xx'
        :unknown
      else
        :small
      end
  end

  o.on('-l','--link-checker', 'Check for dead links') do
    options[:link_checker] = true
  end
  
  o.on('-n','--navigation-test', 'Check for navigation test results') do
    options[:navigation_test] = true
  end

  o.on('--skip-broken', 'Skip tests that are known to be broken') do
    options[:skip_broken] = true
  end

  o.separator ""
  o.on_tail('-h', '--help', 'display this help and exit') do
    options[:show_help] = true
  end
end

opts.parse!(ARGV)

if options[:show_help]
  print opts
  exit 1
end

$options = options  # we are using a global here
$host = 
  if ARGV.size>0
    ARGV.shift
  else
    "http://localhost:5003"
  end

$stderr.print "Testing <",$host,">\n"

require 'mechanize'
require 'minitest/spec'
require 'minitest/autorun'

# These are the actual testing modules

libpath = File.dirname(File.dirname(__FILE__))
$: << File.join(libpath,'test/lib')

if options[:link_checker]
  require 'link_checker'
else
  require 'main_web_functionality'
end
  
if options[:navigation_test]
  require 'navigation'
end