|
|
@ -604,6 +604,51 @@ async fn test_symlink_write_fail() -> anyhow::Result<()> {
|
|
|
|
Ok(())
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[tokio::test(flavor = "multi_thread")]
|
|
|
|
|
|
|
|
async fn test_symlink_write_relative() -> anyhow::Result<()> {
|
|
|
|
|
|
|
|
#[cfg(unix)]
|
|
|
|
|
|
|
|
use std::os::unix::fs::symlink;
|
|
|
|
|
|
|
|
#[cfg(not(unix))]
|
|
|
|
|
|
|
|
use std::os::windows::fs::symlink_file as symlink;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// tempdir
|
|
|
|
|
|
|
|
// |- - b
|
|
|
|
|
|
|
|
// | |- file
|
|
|
|
|
|
|
|
// |- linked (symlink to file)
|
|
|
|
|
|
|
|
let dir = tempfile::tempdir()?;
|
|
|
|
|
|
|
|
let inner_dir = dir.path().join("b");
|
|
|
|
|
|
|
|
std::fs::create_dir(&inner_dir)?;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let mut file = tempfile::NamedTempFile::new_in(&inner_dir)?;
|
|
|
|
|
|
|
|
let symlink_path = dir.path().join("linked");
|
|
|
|
|
|
|
|
let relative_path = std::path::PathBuf::from("b").join(file.path().file_name().unwrap());
|
|
|
|
|
|
|
|
symlink(relative_path, &symlink_path)?;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let mut app = helpers::AppBuilder::new()
|
|
|
|
|
|
|
|
.with_file(&symlink_path, None)
|
|
|
|
|
|
|
|
.build()?;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
test_key_sequence(
|
|
|
|
|
|
|
|
&mut app,
|
|
|
|
|
|
|
|
Some("ithe gostak distims the doshes<ret><esc>:w<ret>"),
|
|
|
|
|
|
|
|
None,
|
|
|
|
|
|
|
|
false,
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
.await?;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
reload_file(&mut file).unwrap();
|
|
|
|
|
|
|
|
let mut file_content = String::new();
|
|
|
|
|
|
|
|
file.as_file_mut().read_to_string(&mut file_content)?;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assert_eq!(
|
|
|
|
|
|
|
|
LineFeedHandling::Native.apply("the gostak distims the doshes"),
|
|
|
|
|
|
|
|
file_content
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
assert!(symlink_path.is_symlink());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
async fn edit_file_with_content(file_content: &[u8]) -> anyhow::Result<()> {
|
|
|
|
async fn edit_file_with_content(file_content: &[u8]) -> anyhow::Result<()> {
|
|
|
|
let mut file = tempfile::NamedTempFile::new()?;
|
|
|
|
let mut file = tempfile::NamedTempFile::new()?;
|
|
|
|
|
|
|
|
|
|
|
|