use std::ffi::OsString;
use std::fs;
use std::path::PathBuf;
use bard::prelude::*;
mod util;
pub use util::*;
#[cfg(unix)]
fn bad_dir_name() -> OsString {
use std::os::unix::ffi::OsStringExt as _;
OsString::from_vec((b"bad-utf8-\xc0-\xc0\xaf"[..]).into())
}
#[cfg(windows)]
fn bad_dir_name() -> OsString {
use std::os::windows::ffi::OsStringExt as _;
OsString::from_wide(&[
0x0062, 0x0061, 0x0064, 0x002d, 0x0075, 0x0074, 0x0066, 0x0031, 0x0036, 0x002d, 0xd834,
0xd834, 0xdd1e, 0xdd1e,
])
}
#[test]
fn bad_unicode_path() {
let workdir = PathBuf::from(env!("CARGO_TARGET_TMPDIR")).join(bad_dir_name());
if workdir.exists() {
fs::remove_dir_all(&workdir)
.with_context(|| format!("Couldn't remove previous test run data: {:?}", workdir))
.unwrap();
}
fs::create_dir(&workdir).unwrap();
let app = Builder::app(false);
bard::bard_init_at::<&Path>(&app, &workdir)
.context("Failed to initialize")
.unwrap();
bard::bard_make_at::<&Path>(&app, &workdir)
.context("Failed to build project")
.unwrap();
fs::remove_dir_all(&workdir).unwrap();
}