def test_create_or_update_env_shell_file():
    test_path = "/usr/share/R/libs"
    env_file_builder = EnvFileBuilder(test_path)
    line, path = env_file_builder.create_or_update_env_shell_file(
        TEST_INSTALL_DIR,
        dict(action="append_to", name="R_LIBS", value=test_path))
    assert path == join(TEST_INSTALL_DIR, "env.sh")
    assert line == "R_LIBS=$R_LIBS:/usr/share/R/libs; export R_LIBS"

    line, path = env_file_builder.create_or_update_env_shell_file(
        TEST_INSTALL_DIR,
        dict(action="prepend_to", name="R_LIBS", value=test_path))
    assert path == join(TEST_INSTALL_DIR, "env.sh")
    assert line == "R_LIBS=/usr/share/R/libs:$R_LIBS; export R_LIBS"

    line, path = env_file_builder.create_or_update_env_shell_file(
        TEST_INSTALL_DIR, dict(action="set_to", name="R_LIBS",
                               value=test_path))
    assert path == join(TEST_INSTALL_DIR, "env.sh")
    assert line == "R_LIBS=/usr/share/R/libs; export R_LIBS"

    line, path = env_file_builder.create_or_update_env_shell_file(
        TEST_INSTALL_DIR, dict(action="source", value=test_path))
    assert path == join(TEST_INSTALL_DIR, "env.sh")
    assert line == "if [ -f /usr/share/R/libs ] ; then . /usr/share/R/libs ; fi"
Ejemplo n.º 2
0
def test_create_or_update_env_shell_file():
    test_path = "/usr/share/R/libs"
    env_file_builder = EnvFileBuilder( test_path )
    line, path = env_file_builder.create_or_update_env_shell_file( TEST_INSTALL_DIR, dict( action="append_to", name="R_LIBS", value=test_path ) )
    assert path == join( TEST_INSTALL_DIR, "env.sh" )
    assert line == "R_LIBS=$R_LIBS:/usr/share/R/libs; export R_LIBS"

    line, path = env_file_builder.create_or_update_env_shell_file( TEST_INSTALL_DIR, dict( action="prepend_to", name="R_LIBS", value=test_path ) )
    assert path == join( TEST_INSTALL_DIR, "env.sh" )
    assert line == "R_LIBS=/usr/share/R/libs:$R_LIBS; export R_LIBS"

    line, path = env_file_builder.create_or_update_env_shell_file( TEST_INSTALL_DIR, dict( action="set_to", name="R_LIBS", value=test_path ) )
    assert path == join( TEST_INSTALL_DIR, "env.sh" )
    assert line == "R_LIBS=/usr/share/R/libs; export R_LIBS"

    line, path = env_file_builder.create_or_update_env_shell_file( TEST_INSTALL_DIR, dict( action="source", value=test_path ) )
    assert path == join( TEST_INSTALL_DIR, "env.sh" )
    assert line == "if [ -f /usr/share/R/libs ] ; then . /usr/share/R/libs ; fi"