def files_already_under_bin_are_not_replaced(): deployed_package = _deploy_package( [ sh_script_description("bin/hello", "echo Hello from bin"), sh_script_description(".bin/hello", "echo Hello from .bin"), ] ) with deployed_package: command = [deployed_package.path("bin/hello")] _assert_output(command, b"Hello from bin\n")
def whack_root_is_not_remounted_if_executing_scripts_under_whack_root(): deployed_package = _deploy_package( [ sh_script_description(".bin/hello", "echo Hello there"), sh_script_description(".bin/hello2", "{0}/bin/hello".format(WHACK_ROOT)), ] ) with deployed_package: _add_echo_to_run_command(deployed_package) command = [deployed_package.path("bin/hello2")] _assert_output(command, b"Run!\nHello there\n")
def whack_root_is_remounted_if_in_different_whack_root(): first_deployed_package = _deploy_package( [ plain_file("message", "Hello there"), sh_script_description(".bin/hello", "cat {0}/message".format(WHACK_ROOT)), ] ) with first_deployed_package: hello_path = first_deployed_package.path("bin/hello") second_deployed_package = _deploy_package([sh_script_description(".bin/hello2", "{0}".format(hello_path))]) with second_deployed_package: _add_echo_to_run_command(first_deployed_package) _add_echo_to_run_command(second_deployed_package) command = [second_deployed_package.path("bin/hello2")] _assert_output(command, b"Run!\nRun!\nHello there")
def run_script_in_installation_mounts_whack_root_before_running_command(): deployed_package = _deploy_package( [plain_file("message", "Hello there"), sh_script_description("bin/hello", "cat {0}/message".format(WHACK_ROOT))] ) with deployed_package: command = [deployed_package.path("run"), deployed_package.path("bin/hello")] _assert_output(command, b"Hello there")
def broken_symlinked_dot_bin_is_ignored(): deployed_package = _deploy_package( [sh_script_description("bin/hello", "echo Hello there"), symlink(".bin", "sub/binn")] ) with deployed_package: command = [deployed_package.path("bin/hello")] _assert_output(command, b"Hello there\n")
def _package_source(build_script, description): files = [ plain_file("whack/whack.json", json.dumps(description)), sh_script_description("whack/build", build_script), ] with create_temporary_dir(files) as package_source_dir: yield PackageSource.local(package_source_dir)
def placing_executables_under_dot_sbin_creates_directly_executable_files_under_sbin(): deployed_package = _deploy_package( [ plain_file("message", "Hello there"), sh_script_description(".sbin/hello", "cat {0}/message".format(WHACK_ROOT)), ] ) with deployed_package: command = [deployed_package.path("sbin/hello")] _assert_output(command, b"Hello there")
def relative_symlinks_in_dot_bin_are_created_in_bin(): deployed_package = _deploy_package( [ plain_file("message", "Hello there"), sh_script_description("sub/bin/hello", "cat {0}/message".format(WHACK_ROOT)), symlink(".bin", "sub/bin"), ] ) with deployed_package: command = [deployed_package.path("bin/hello")] _assert_output(command, b"Hello there")
def directory_can_be_deployed_in_place(ops): package_files = [ plain_file("message", "Hello there"), sh_script_description(".bin/hello", "cat {0}/message".format(WHACK_ROOT)), ] with create_temporary_dir(package_files) as package_dir: ops.deploy(package_dir) output = _check_output([os.path.join(package_dir, "bin/hello")]) assert_equal(b"Hello there", output) assert _is_deployed(package_dir)
def working_symlinks_in_dot_bin_to_files_under_whack_root_are_created_in_bin(): deployed_package = _deploy_package( [ sh_script_description(".bin/hello", "echo Hello there"), symlink(".bin/hello-sym", os.path.join(WHACK_ROOT, ".bin/hello")), symlink(".bin/hello-borked", os.path.join(WHACK_ROOT, ".bin/hell")), ] ) with deployed_package: command = [deployed_package.path("bin/hello-sym")] _assert_output(command, b"Hello there\n") assert not os.path.exists(deployed_package.path("bin/hello-borked"))
def path_environment_variable_includes_sbin_directory_under_whack_root(): deployed_package = _deploy_package([sh_script_description("sbin/hello", "echo Hello there")]) with deployed_package: command = [deployed_package.path("run"), "hello"] _assert_output(command, b"Hello there\n")
def _package_source(build): return create_temporary_dir([sh_script_description("whack/build", build)])