import os
import subprocess
import pytest

chemshell_env_var = "CHEMSHELL_TCL"


def test_env():
    envvar = os.environ.get(chemshell_env_var)
    assert envvar != None


filedir = os.path.dirname(os.path.realpath(__file__))
files = [f for f in os.listdir(filedir) if f.endswith(".chm")]


@pytest.mark.parametrize("fname", files)
def test_file(fname):
    envvar = os.environ.get(chemshell_env_var)
    process = subprocess.run([envvar + "/scripts/chemsh", fname])
    assert process.returncode == 0
