#!/usr/bin/python

import os
import sys

import jstest

class t1:
    search_term = 'example'
    n_results = 35
    n_links = 35
    n_highlights = 32

class t2:
    search_term = 'examples'
    n_results = 35
    n_links = 35
    n_highlights = 6

class t3:
    search_term = 'graph'
    n_results = 12
    n_links = 12
    n_highlights = 3

if __name__ == '__main__':
    if not os.getenv('DISPLAY'):
        raise RuntimeError('These tests requires access to an X server')
    build_directory = os.path.join(os.path.dirname(__file__), '..', '..', 'build', 'html')
    build_directory = os.path.abspath(build_directory)
    n_failures = 0
    for testcase in t1, t2, t3:
        failures = jstest.test_directory(build_directory, testcase).failures
        n_failures += len(failures)
    sys.exit(n_failures > 0)

# vim:ts=4 sw=4 et
