示例#1
0
def test_expand_cmd(monkeypatch):
    monkeypatch.setenv("HOME", "/home/qnet")
    monkeypatch.setenv("PREFIX", "/home/qnet/local")
    with pytest.raises(TypeError) as exc_info:
        expand_cmd("$CC -O2 -I$PREFIX/include/qsd -o qsd-example $HOME/qsd-example.cc -L$PREFIX/lib -lqsd")
    assert "cmd must be a list" in str(exc_info.value)
    cmd = ["$CC", "-O2", "-I$PREFIX/include/qsd", "-o qsd-example", "$HOME/qsd-example.cc", "-L$PREFIX/lib", "-lqsd"]
    assert (
        " ".join(expand_cmd(cmd))
        == "$CC -O2 -I/home/qnet/local/include/qsd -o qsd-example /home/qnet/qsd-example.cc -L/home/qnet/local/lib -lqsd"
    )
示例#2
0
def test_expand_cmd(monkeypatch):
    monkeypatch.setenv('HOME', '/home/qnet')
    monkeypatch.setenv('PREFIX', '/home/qnet/local')
    with pytest.raises(TypeError) as exc_info:
        expand_cmd(
            "$CC -O2 -I$PREFIX/include/qsd -o qsd-example $HOME/qsd-example.cc -L$PREFIX/lib -lqsd"
        )
    assert "cmd must be a list" in str(exc_info.value)
    cmd = [
        "$CC", "-O2", "-I$PREFIX/include/qsd", "-o qsd-example",
        "$HOME/qsd-example.cc", "-L$PREFIX/lib", "-lqsd"
    ]
    assert " ".join(
        expand_cmd(cmd)
    ) == '$CC -O2 -I/home/qnet/local/include/qsd -o qsd-example /home/qnet/qsd-example.cc -L/home/qnet/local/lib -lqsd'
示例#3
0
 def runner(cmd, stderr, cwd):
     """simulate invocation of the of the compiled program"""
     assert cwd == workdir
     assert os.path.isdir(cwd)  # should have been created
     assert " ".join(expand_cmd(cmd)) == HOME + '/bin/run_qsd 232334'
     shutil.copy(os.path.join(datadir, 'X1.out'), workdir)
     shutil.copy(os.path.join(datadir, 'X2.out'), workdir)
示例#4
0
 def runner(cmd, stderr, cwd):
     """simulate invocation of the of the compiled program"""
     assert cwd == workdir
     assert os.path.isdir(cwd)  # should have been created
     assert " ".join(expand_cmd(cmd)) == HOME + "/bin/run_qsd 232334"
     shutil.copy(os.path.join(datadir, "X1.out"), workdir)
     shutil.copy(os.path.join(datadir, "X2.out"), workdir)
示例#5
0
 def runner1(cmd, stderr, cwd):
     """simulate invocation of the compiler"""
     assert " ".join(
         expand_cmd(cmd)
     ) == 'CC -O2 -I' + PREFIX + '/include/qsd -o run_qsd1 run_qsd1.cc -L' + PREFIX + '/lib -lqsd'
     assert cwd == os.path.join(HOME, 'tmp')
     executable = os.path.join(HOME, 'tmp', 'run_qsd1')
     with open(executable, 'w') as out_fh:
         out_fh.write("#!/bin/bash\n")
         out_fh.write("echo 'Hello World'\n")
     st = os.stat(executable)
     os.chmod(executable, st.st_mode | stat.S_IEXEC)
示例#6
0
 def runner1(cmd, stderr, cwd):
     """simulate invocation of the compiler"""
     assert (
         " ".join(expand_cmd(cmd))
         == "CC -O2 -I" + PREFIX + "/include/qsd -o run_qsd1 run_qsd1.cc -L" + PREFIX + "/lib -lqsd"
     )
     assert cwd == os.path.join(HOME, "tmp")
     executable = os.path.join(HOME, "tmp", "run_qsd1")
     with open(executable, "w") as out_fh:
         out_fh.write("#!/bin/bash\n")
         out_fh.write("echo 'Hello World'\n")
     st = os.stat(executable)
     os.chmod(executable, st.st_mode | stat.S_IEXEC)