#!/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

f1 = [
    get_filter(from_string='********************** Mulliken population analysis **********************',
               to_string='*** Total gross population ***',
               rel_tolerance=1.0e-5)
]

f2 = [
    get_filter(from_string='Energy eigenvalues in atomic units',
               to_string='=====================',
               rel_tolerance=1.0e-5)
]


options = cli()

ierr = 0

for inp in ['Rn.x2c.scf_2fs_1iter.inp']:
    for mol in ['Rn.v2z.D2h.mol']:
        ierr += run(options,
                    configure,
                    input_files=[inp, mol],
                    extra_args=' --noarch --gb=1.777 --ag=3 --put="DFPCMO.Rn.x2c_sf.scf.v2z.D2h=DFPCMO"',
                    filters={'out': f1})


for inp in ['Tl.x2c.resolve_2fs_fromSFMO.inp']:
    for mol in ['Tl.v2z.D2h.mol']:
        ierr += run(options,
                    configure,
                    input_files=[inp, mol],
                    extra_args=' --noarch --gb=1.777 --ag=3 --put="DFPCMO.Tl.x2c_sf.scf.v2z.D2h=DFPCMO"',
                    filters={'out': f2})


for inp in ['Tl.x2c.resolve_2fs.inp']:
    for mol in ['Tl.v2z.D2h.mol']:
        ierr += run(options,
                    configure,
                    input_files=[inp, mol],
                    extra_args=' --noarch --gb=1.777 --ag=3 --put="DFPCMO.Tl.x2c.scf.v2z.D2h=DFPCMO"',
                    filters={'out': f2})

sys.exit(ierr)
