migrate: own fs/file and path sources with host-authorization assertions

Move the official stdlib file and path modules to their unique source authority
without changing public paths or host authorization. Carry the pre-migration
product assertions, including the bounded read and cleanup semantics.

Refs cflmy/marqdo#9, cflmy/marqdo-std-fs#1
This commit was merged in pull request #2.
This commit is contained in:
cflmy committed 2026-11-26 23:30:29 +08:00
1 parent 3ef21c7de0
commit 63bceae587
10 files changed
+893 -6

No files matched your search

+5 -1
View File
@@ -1,3 +1,7 @@
# 验收测试
首个功能附带正例和失败用例,记录所用 CLI 提交或发行版本以及实际运行命令。
`tests/*.mq.md` 是从迁移前 CLI 官方标准库自测迁入的真实测试源;`tests/cases/*.json` 固定每个测试的输入(stdin、CLI 参数、环境、所需 Bundle 模块)和期望结果(observation 终值、stdout、必要的资源事件)。
运行入口是 `scripts/test.sh`,它要求显式传入 `MARQDO_BIN` 与 `MARQDO_STDLIB_DIR`。缺少制品、Bundle 缺少模块或 digest 校验失败时必须失败,不得回退到其它目录。
期望值取自迁移前基线 Bundle(`sha256:5407d36...`)与已验证候选 CLI 的真实执行结果;任何期望值改动都必须作为公开行为变化单独评审并记录证据。
+98
View File
@@ -0,0 +1,98 @@
{
"schema": "marqdo.stdlib-test-case",
"schema_version": 1,
"name": "fs",
"file": "fs.mq.md",
"require_module": "fs/file.mq.md",
"args": [
"--allow-read",
"out",
"--allow-read",
"out/**",
"--allow-write",
"out",
"--allow-write",
"out/**"
],
"stdin": "",
"env": {},
"expected_stdout": "",
"expected_terminal": {
"items": [
{
"type": "bool",
"value": true
},
{
"decimal": "7",
"type": "int"
},
{
"type": "bool",
"value": true
},
{
"type": "text",
"value": "file"
},
{
"decimal": "7",
"type": "int"
},
{
"items": [
{
"type": "text",
"value": "fs-a.txt"
}
],
"type": "list"
},
{
"type": "bool",
"value": true
},
{
"type": "bool",
"value": true
},
{
"type": "bool",
"value": true
},
{
"type": "text",
"value": "你好\n"
},
{
"decimal": "7",
"type": "int"
},
{
"type": "text",
"value": "你好\n世界\n"
},
{
"items": [
{
"type": "text",
"value": "fs-b.txt"
}
],
"type": "list"
},
{
"type": "bool",
"value": true
},
{
"type": "bool",
"value": true
}
],
"type": "list"
},
"clean": [
"out"
]
}
+52
View File
@@ -0,0 +1,52 @@
{
"schema": "marqdo.stdlib-test-case",
"schema_version": 1,
"name": "path",
"file": "path.mq.md",
"require_module": "path.mq.md",
"args": [],
"stdin": "",
"env": {},
"expected_stdout": "",
"expected_terminal": {
"items": [
{
"type": "text",
"value": "a/b/c"
},
{
"type": "text",
"value": "c.txt"
},
{
"type": "text",
"value": "a/b"
},
{
"type": "text",
"value": "txt"
},
{
"type": "text",
"value": "a/c"
},
{
"type": "text",
"value": "/a/c"
},
{
"type": "text",
"value": "../a/b"
},
{
"type": "bool",
"value": true
},
{
"type": "bool",
"value": false
}
],
"type": "list"
}
}
+38
View File
@@ -0,0 +1,38 @@
---
import:
fs_lib: "std:fs/file"
---
# @exec fs
## main
**创建 = fs_lib.创建目录("out")**
**写入 = fs_lib.写文本("out/fs-a.txt", "你好\n")**
**存在 = fs_lib.存在("out/fs-a.txt")**
**元数据 = fs_lib.元数据("out/fs-a.txt")**
**列表 = fs_lib.列出目录("out")**
**是文件 = fs_lib.是文件("out/fs-a.txt")**
**是目录 = fs_lib.是目录("out")**
**重命名 = fs_lib.重命名("out/fs-a.txt", "out/fs-b.txt")**
**读取 = fs_lib.读文本("out/fs-b.txt")**
**追加 = fs_lib.追加文本("out/fs-b.txt", "世界\n")**
**片段 = fs_lib.读取片段("out/fs-b.txt", 0, 100)**
**遍历 = fs_lib.遍历("out")**
**删除 = fs_lib.删除("out/fs-b.txt")**
**删除目录 = fs_lib.删除("out")**
`return [创建.ok, 写入.value.count, 存在.value, 元数据.value.kind, 元数据.value.size, 列表.value, 是文件.value, 是目录.value, 重命名.ok, 读取.value, 追加.value, 片段.value, 遍历.value, 删除.ok, 删除目录.ok]`
+10
View File
@@ -0,0 +1,10 @@
---
import:
path: "std:path"
---
# @exec path
## main
`return [path.连接(["a", "", "b", "c"]), path.文件名("a/b/c.txt"), path.目录名("a/b/c.txt"), path.扩展名("a/b/c.txt"), path.规范("./a//b/../c"), path.规范("/a/./b/../c"), path.规范("../a/b"), path.是否绝对("/a"), path.是否绝对("a")]`