refactor: 迁移至 bashly CLI 与功能域模块结构

- CLI 定义迁移至 src/bashly.yml(bashly 1.4 生成参数解析),入口收敛为 src/root_command.sh
- 源码按功能域重组:config/storage/integrate/media/pipeline,消除扁平散落
- 新增零依赖测试框架 tests/(123 用例)与 CI 流水线(lint + test + build + 产物一致性)
- build.sh 支持版本单一来源注入与 --check 产物校验;新增 lint.sh(bash -n + shellcheck 零容忍)
- 删除旧单文件 media_organizer.sh 与旧扁平模块
This commit is contained in:
Shuery committed 2026-08-14 22:41:28 +08:00
1 parent d978a13a83
commit 0df07ad0ae
48 files changed
+5813 -6812

No files matched your search

+61
View File
@@ -0,0 +1,61 @@
# ============================================================================
# 硬链接基础工具测试(src/lib/link.sh)
# ============================================================================
setup() {
TEST_DIR="$(mktemp -d)"
DRY_RUN=false
}
teardown() {
rm -rf "$TEST_DIR"
}
# get_file_inode:GNU stat 与兜底路径均可用
test_get_file_inode_works() {
local f="$TEST_DIR/a.txt"
echo hi >"$f"
local inode
inode="$(get_file_inode "$f")"
assert_not_empty "$inode"
assert_eq "$(stat -c '%i' "$f")" "$inode" "inode 应与 stat 一致"
}
# same_inode:硬链接同 inode,普通文件不同
test_same_inode_detection() {
local f1="$TEST_DIR/a.txt" f2="$TEST_DIR/b.txt"
echo hi >"$f1"
ln "$f1" "$f2"
assert_success same_inode "$f1" "$f2"
echo other >"$TEST_DIR/c.txt"
assert_failure same_inode "$f1" "$TEST_DIR/c.txt"
assert_failure same_inode "$f1" "$TEST_DIR/不存在.txt"
}
# hardlink_or_dryrun:真实创建硬链接
test_hardlink_or_dryrun_creates_link() {
local f1="$TEST_DIR/a.txt" f2="$TEST_DIR/link.txt"
echo data >"$f1"
assert_success hardlink_or_dryrun "$f1" "$f2"
assert_file_exists "$f2"
assert_success same_inode "$f1" "$f2"
}
# hardlink_or_dryrun:干运行不创建
test_hardlink_or_dryrun_dry_run() {
local f1="$TEST_DIR/a.txt" f2="$TEST_DIR/link.txt"
echo data >"$f1"
DRY_RUN=true
assert_success hardlink_or_dryrun "$f1" "$f2"
assert_file_absent "$f2"
}
# hardlink_or_dryrun:目标已存在时替换
test_hardlink_or_dryrun_replaces_existing() {
local f1="$TEST_DIR/a.txt" f2="$TEST_DIR/exists.txt"
echo new >"$f1"
echo old >"$f2"
assert_success hardlink_or_dryrun "$f1" "$f2"
assert_success same_inode "$f1" "$f2"
assert_eq "new" "$(cat "$f2")"
}