just playing with tangled
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

tests: remove generic parameters from config TestCase

We don't care about the memory layout here, and it'll become verbose to spell
them out in the following patches.

+42 -44
+42 -44
cli/src/config.rs
··· 1240 1240 #[test] 1241 1241 fn test_config_path_home_existing() -> anyhow::Result<()> { 1242 1242 TestCase { 1243 - files: ["home/.jjconfig.toml"], 1243 + files: &["home/.jjconfig.toml"], 1244 1244 env: UnresolvedConfigEnv { 1245 1245 home_dir: Some("home".into()), 1246 1246 ..Default::default() 1247 1247 }, 1248 - wants: [Want::Existing("home/.jjconfig.toml")], 1248 + wants: &[Want::Existing("home/.jjconfig.toml")], 1249 1249 } 1250 1250 .run() 1251 1251 } ··· 1253 1253 #[test] 1254 1254 fn test_config_path_home_new() -> anyhow::Result<()> { 1255 1255 TestCase { 1256 - files: [], 1256 + files: &[], 1257 1257 env: UnresolvedConfigEnv { 1258 1258 home_dir: Some("home".into()), 1259 1259 ..Default::default() 1260 1260 }, 1261 - wants: [Want::New("home/.jjconfig.toml")], 1261 + wants: &[Want::New("home/.jjconfig.toml")], 1262 1262 } 1263 1263 .run() 1264 1264 } ··· 1266 1266 #[test] 1267 1267 fn test_config_path_home_existing_platform_new() -> anyhow::Result<()> { 1268 1268 TestCase { 1269 - files: ["home/.jjconfig.toml"], 1269 + files: &["home/.jjconfig.toml"], 1270 1270 env: UnresolvedConfigEnv { 1271 1271 home_dir: Some("home".into()), 1272 1272 config_dir: Some("config".into()), 1273 1273 ..Default::default() 1274 1274 }, 1275 - wants: [ 1275 + wants: &[ 1276 1276 Want::Existing("home/.jjconfig.toml"), 1277 1277 Want::New("config/jj/config.toml"), 1278 1278 ], ··· 1283 1283 #[test] 1284 1284 fn test_config_path_platform_existing() -> anyhow::Result<()> { 1285 1285 TestCase { 1286 - files: ["config/jj/config.toml"], 1286 + files: &["config/jj/config.toml"], 1287 1287 env: UnresolvedConfigEnv { 1288 1288 home_dir: Some("home".into()), 1289 1289 config_dir: Some("config".into()), 1290 1290 ..Default::default() 1291 1291 }, 1292 - wants: [Want::Existing("config/jj/config.toml")], 1292 + wants: &[Want::Existing("config/jj/config.toml")], 1293 1293 } 1294 1294 .run() 1295 1295 } ··· 1297 1297 #[test] 1298 1298 fn test_config_path_platform_new() -> anyhow::Result<()> { 1299 1299 TestCase { 1300 - files: [], 1300 + files: &[], 1301 1301 env: UnresolvedConfigEnv { 1302 1302 config_dir: Some("config".into()), 1303 1303 ..Default::default() 1304 1304 }, 1305 - wants: [Want::New("config/jj/config.toml")], 1305 + wants: &[Want::New("config/jj/config.toml")], 1306 1306 } 1307 1307 .run() 1308 1308 } ··· 1310 1310 #[test] 1311 1311 fn test_config_path_new_prefer_platform() -> anyhow::Result<()> { 1312 1312 TestCase { 1313 - files: [], 1313 + files: &[], 1314 1314 env: UnresolvedConfigEnv { 1315 1315 home_dir: Some("home".into()), 1316 1316 config_dir: Some("config".into()), 1317 1317 ..Default::default() 1318 1318 }, 1319 - wants: [Want::New("config/jj/config.toml")], 1319 + wants: &[Want::New("config/jj/config.toml")], 1320 1320 } 1321 1321 .run() 1322 1322 } ··· 1324 1324 #[test] 1325 1325 fn test_config_path_jj_config_existing() -> anyhow::Result<()> { 1326 1326 TestCase { 1327 - files: ["custom.toml"], 1327 + files: &["custom.toml"], 1328 1328 env: UnresolvedConfigEnv { 1329 1329 jj_config: Some("custom.toml".into()), 1330 1330 ..Default::default() 1331 1331 }, 1332 - wants: [Want::Existing("custom.toml")], 1332 + wants: &[Want::Existing("custom.toml")], 1333 1333 } 1334 1334 .run() 1335 1335 } ··· 1337 1337 #[test] 1338 1338 fn test_config_path_jj_config_new() -> anyhow::Result<()> { 1339 1339 TestCase { 1340 - files: [], 1340 + files: &[], 1341 1341 env: UnresolvedConfigEnv { 1342 1342 jj_config: Some("custom.toml".into()), 1343 1343 ..Default::default() 1344 1344 }, 1345 - wants: [Want::New("custom.toml")], 1345 + wants: &[Want::New("custom.toml")], 1346 1346 } 1347 1347 .run() 1348 1348 } ··· 1350 1350 #[test] 1351 1351 fn test_config_path_jj_config_existing_multiple() -> anyhow::Result<()> { 1352 1352 TestCase { 1353 - files: ["custom1.toml", "custom2.toml"], 1353 + files: &["custom1.toml", "custom2.toml"], 1354 1354 env: UnresolvedConfigEnv { 1355 1355 jj_config: Some( 1356 1356 join_paths(["custom1.toml", "custom2.toml"]) ··· 1360 1360 ), 1361 1361 ..Default::default() 1362 1362 }, 1363 - wants: [ 1363 + wants: &[ 1364 1364 Want::Existing("custom1.toml"), 1365 1365 Want::Existing("custom2.toml"), 1366 1366 ], ··· 1371 1371 #[test] 1372 1372 fn test_config_path_jj_config_new_multiple() -> anyhow::Result<()> { 1373 1373 TestCase { 1374 - files: ["custom1.toml"], 1374 + files: &["custom1.toml"], 1375 1375 env: UnresolvedConfigEnv { 1376 1376 jj_config: Some( 1377 1377 join_paths(["custom1.toml", "custom2.toml"]) ··· 1381 1381 ), 1382 1382 ..Default::default() 1383 1383 }, 1384 - wants: [Want::Existing("custom1.toml"), Want::New("custom2.toml")], 1384 + wants: &[Want::Existing("custom1.toml"), Want::New("custom2.toml")], 1385 1385 } 1386 1386 .run() 1387 1387 } ··· 1389 1389 #[test] 1390 1390 fn test_config_path_jj_config_empty_paths_filtered() -> anyhow::Result<()> { 1391 1391 TestCase { 1392 - files: ["custom1.toml"], 1392 + files: &["custom1.toml"], 1393 1393 env: UnresolvedConfigEnv { 1394 1394 jj_config: Some( 1395 1395 join_paths(["custom1.toml", "", "custom2.toml"]) ··· 1399 1399 ), 1400 1400 ..Default::default() 1401 1401 }, 1402 - wants: [Want::Existing("custom1.toml"), Want::New("custom2.toml")], 1402 + wants: &[Want::Existing("custom1.toml"), Want::New("custom2.toml")], 1403 1403 } 1404 1404 .run() 1405 1405 } ··· 1407 1407 #[test] 1408 1408 fn test_config_path_jj_config_empty() -> anyhow::Result<()> { 1409 1409 TestCase { 1410 - files: [], 1410 + files: &[], 1411 1411 env: UnresolvedConfigEnv { 1412 1412 jj_config: Some("".to_owned()), 1413 1413 ..Default::default() 1414 1414 }, 1415 - wants: [], 1415 + wants: &[], 1416 1416 } 1417 1417 .run() 1418 1418 } ··· 1420 1420 #[test] 1421 1421 fn test_config_path_config_pick_platform() -> anyhow::Result<()> { 1422 1422 TestCase { 1423 - files: ["config/jj/config.toml"], 1423 + files: &["config/jj/config.toml"], 1424 1424 env: UnresolvedConfigEnv { 1425 1425 home_dir: Some("home".into()), 1426 1426 config_dir: Some("config".into()), 1427 1427 ..Default::default() 1428 1428 }, 1429 - wants: [Want::Existing("config/jj/config.toml")], 1429 + wants: &[Want::Existing("config/jj/config.toml")], 1430 1430 } 1431 1431 .run() 1432 1432 } ··· 1434 1434 #[test] 1435 1435 fn test_config_path_config_pick_home() -> anyhow::Result<()> { 1436 1436 TestCase { 1437 - files: ["home/.jjconfig.toml"], 1437 + files: &["home/.jjconfig.toml"], 1438 1438 env: UnresolvedConfigEnv { 1439 1439 home_dir: Some("home".into()), 1440 1440 config_dir: Some("config".into()), 1441 1441 ..Default::default() 1442 1442 }, 1443 - wants: [ 1443 + wants: &[ 1444 1444 Want::Existing("home/.jjconfig.toml"), 1445 1445 Want::New("config/jj/config.toml"), 1446 1446 ], ··· 1451 1451 #[test] 1452 1452 fn test_config_path_platform_new_conf_dir_existing() -> anyhow::Result<()> { 1453 1453 TestCase { 1454 - files: ["config/jj/conf.d/_"], 1454 + files: &["config/jj/conf.d/_"], 1455 1455 env: UnresolvedConfigEnv { 1456 1456 home_dir: Some("home".into()), 1457 1457 config_dir: Some("config".into()), 1458 1458 ..Default::default() 1459 1459 }, 1460 - wants: [ 1460 + wants: &[ 1461 1461 Want::New("config/jj/config.toml"), 1462 1462 Want::Existing("config/jj/conf.d"), 1463 1463 ], ··· 1468 1468 #[test] 1469 1469 fn test_config_path_platform_existing_conf_dir_existing() -> anyhow::Result<()> { 1470 1470 TestCase { 1471 - files: ["config/jj/config.toml", "config/jj/conf.d/_"], 1471 + files: &["config/jj/config.toml", "config/jj/conf.d/_"], 1472 1472 env: UnresolvedConfigEnv { 1473 1473 home_dir: Some("home".into()), 1474 1474 config_dir: Some("config".into()), 1475 1475 ..Default::default() 1476 1476 }, 1477 - wants: [ 1477 + wants: &[ 1478 1478 Want::Existing("config/jj/config.toml"), 1479 1479 Want::Existing("config/jj/conf.d"), 1480 1480 ], ··· 1485 1485 #[test] 1486 1486 fn test_config_path_all_existing() -> anyhow::Result<()> { 1487 1487 TestCase { 1488 - files: [ 1488 + files: &[ 1489 1489 "config/jj/conf.d/_", 1490 1490 "config/jj/config.toml", 1491 1491 "home/.jjconfig.toml", ··· 1496 1496 ..Default::default() 1497 1497 }, 1498 1498 // Precedence order is important 1499 - wants: [ 1499 + wants: &[ 1500 1500 Want::Existing("home/.jjconfig.toml"), 1501 1501 Want::Existing("config/jj/config.toml"), 1502 1502 Want::Existing("config/jj/conf.d"), ··· 1508 1508 #[test] 1509 1509 fn test_config_path_none() -> anyhow::Result<()> { 1510 1510 TestCase { 1511 - files: [], 1511 + files: &[], 1512 1512 env: Default::default(), 1513 - wants: [], 1513 + wants: &[], 1514 1514 } 1515 1515 .run() 1516 1516 } 1517 1517 1518 - fn setup_config_fs<const N: usize>( 1519 - files: &[&'static str; N], 1520 - ) -> anyhow::Result<tempfile::TempDir> { 1518 + fn setup_config_fs(files: &[&str]) -> anyhow::Result<tempfile::TempDir> { 1521 1519 let tmp = testutils::new_temp_dir(); 1522 1520 for file in files { 1523 1521 let path = tmp.path().join(file); ··· 1534 1532 Existing(&'static str), 1535 1533 } 1536 1534 1537 - struct TestCase<const N: usize, const M: usize> { 1538 - files: [&'static str; N], 1535 + struct TestCase { 1536 + files: &'static [&'static str], 1539 1537 env: UnresolvedConfigEnv, 1540 - wants: [Want; M], 1538 + wants: &'static [Want], 1541 1539 } 1542 1540 1543 - impl<const N: usize, const M: usize> TestCase<N, M> { 1541 + impl TestCase { 1544 1542 fn resolve(&self, root: &Path) -> ConfigEnv { 1545 1543 let home_dir = self.env.home_dir.as_ref().map(|p| root.join(p)); 1546 1544 let env = UnresolvedConfigEnv { ··· 1568 1566 } 1569 1567 1570 1568 fn run(&self) -> anyhow::Result<()> { 1571 - let tmp = setup_config_fs(&self.files)?; 1569 + let tmp = setup_config_fs(self.files)?; 1572 1570 self.check_existing_paths(&tmp)?; 1573 1571 self.check_paths(&tmp)?; 1574 1572 Ok(())