#!/usr/bin/env python

import os
import sys
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))

from runtest import version_info, get_filter, cli, run
from runtest_config import configure

assert version_info.major == 2

f = [
    get_filter(from_string='Expectation values',
               to_string='    s0 = T : Expectation value zero by point group symmetry.',
               rel_tolerance=5.0e-5),
    get_filter(from_string='INDIRECT NUCLEAR SPIN-SPIN-COUPLINGS',
               to_string='DSO contribution to reduced SSCC K (SI:10**19 m-2 kg s-2 A-2)',
               rel_tolerance=5.0e-5),
    get_filter(from_string='At1  #  iso',
               num_lines=4,
               rel_tolerance=1.0e-3),
]

options = cli()

ierr = 0
for inp in ['bss_rkb+mfsso.spsp.inp']:
    for mol in ['H2O.mol']:
        ierr += run(options,
                    configure,
                    input_files=[inp, mol],
                    filters={'out': f},
                    extra_args='--mw=100 --aw=128')

f = [
    get_filter(from_string='RPA results',
               to_string='Timing of routine RPAA',
               rel_tolerance=5.0e-5),
]

for inp in ['spsp.inp', 'bss.spsp.inp', 'bss+mfsso.spsp.inp']:
    for mol in ['H2O.mol']:
        ierr += run(options,
                    configure,
                    input_files=[inp, mol],
                    filters={'out': f},
                    extra_args='--mw=100 --aw=128')

sys.exit(ierr)
