- 1235
#[test] - 1236
fn confirm_refuses_rather_than_assumes_when_not_interactive() { - 1237
// A piped stdin with no --yes must not be read as consent. - 1238
assert!(!confirm("do the thing?", false)); - 1239
assert!(confirm("do the thing?", true)); - 1240
} - 1241
- 1242
#[test] - 1243
fn every_optional_component_is_declared_optional() { - 1244
let required: Vec<&str> = COMPONENTS - 1245
.iter() - 1246
.filter(|c| c.required) - 1247
.map(|c| c.name) - 1248
.collect(); - 1249
assert_eq!( - 1250
required, - 1251
vec!["vak"], - 1252
"only the CLI is required; the rest ride along when built" - 1253
); - 1254
} - 1255
- 1256
#[cfg(unix)] - 1257
fn executable(path: &Path) { - 1258
use std::os::unix::fs::PermissionsExt as _; - 1259
std::fs::write(path, "#!/bin/sh\n").unwrap(); - 1260
std::fs::set_permissions(path, std::fs::Permissions::from_mode(0o755)).unwrap(); - 1261
} - 1262
- 1263
#[cfg(unix)] - 1264
#[test] - 1265
fn cli_on_path_follows_a_symlink_into_the_install() { - 1266
let tmp = tempfile::tempdir().unwrap(); - 1267
let bin = tmp.path().join("App/Contents/MacOS"); - 1268
let link_dir = tmp.path().join("local-bin"); - 1269
std::fs::create_dir_all(&bin).unwrap(); - 1270
std::fs::create_dir_all(&link_dir).unwrap(); - 1271
let cli = bin.join("vak"); - 1272
executable(&cli); - 1273
std::os::unix::fs::symlink(&cli, link_dir.join("vak")).unwrap(); - 1274
- 1275
let path = std::env::join_paths([&link_dir]).unwrap(); - 1276
assert_eq!(cli_on_path(Some(&path), &cli), CliOnPath::ThisInstall); - 1277
let path = std::env::join_paths([&bin]).unwrap(); - 1278
assert_eq!(cli_on_path(Some(&path), &cli), CliOnPath::ThisInstall); - 1279
} - 1280
- 1281
#[cfg(unix)] - 1282
#[test] - 1283
fn cli_on_path_reports_an_earlier_different_vak_as_shadowing() { - 1284
let tmp = tempfile::tempdir().unwrap(); - 1285
let bin = tmp.path().join("install"); - 1286
let stale = tmp.path().join("cargo-bin"); - 1287
let not_exec = tmp.path().join("plain"); - 1288
for dir in [&bin, &stale, ¬_exec] { - 1289
std::fs::create_dir_all(dir).unwrap(); - 1290
} - 1291
let cli = bin.join("vak"); - 1292
executable(&cli); - 1293
executable(&stale.join("vak")); - 1294
std::fs::write(not_exec.join("vak"), "not a program").unwrap(); - 1295
- 1296
// A non-executable `vak` is skipped, as a shell would skip it. - 1297
let path = std::env::join_paths([¬_exec, &bin]).unwrap(); - 1298
assert_eq!(cli_on_path(Some(&path), &cli), CliOnPath::ThisInstall); - 1299
let path = std::env::join_paths([&stale, &bin]).unwrap(); - 1300
assert_eq!( - 1301
cli_on_path(Some(&path), &cli), - 1302
CliOnPath::Shadowed(stale.join("vak")) - 1303
); - 1304
} - 1305
- 1306
#[test] - 1307
fn cli_on_path_is_absent_without_a_match() { - 1308
let tmp = tempfile::tempdir().unwrap(); - 1309
let cli = tmp.path().join("vak"); - 1310
let empty = tempfile::tempdir().unwrap(); - 1311
let path = std::env::join_paths([empty.path()]).unwrap(); - 1312
assert_eq!(cli_on_path(Some(&path), &cli), CliOnPath::Absent); - 1313
assert_eq!(cli_on_path(None, &cli), CliOnPath::Absent); - 1314
} - 1315
} - 1316
Indexing the workspace…
Vakyartha documentation is discovering safe artifacts, anchors, and source references.