#!/usr/bin/python3

import os
import sys

import jstest

class t1:
    search_term = 'example'
    n_results = 77
    n_links = 77
    n_highlights = 68

class t2:
    search_term = 'examples'
    n_results = 69
    n_links = 69
    n_highlights = 11

class t3:
    search_term = 'graph'
    n_results = 31
    n_links = 31
    n_highlights = 4

if __name__ == '__main__':
    if not os.getenv('DISPLAY'):
        raise RuntimeError('These tests require access to an X server')
    [build_directory] = sys.argv[1:]
    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
