Skip to content

Commit 64c3d64

Browse files
mcpplibs.os 0.2.0
Co-authored-by: speak-agent <248744407+speak-agent@users.noreply.github.com>
1 parent 3cae999 commit 64c3d64

4 files changed

Lines changed: 40 additions & 2 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@
3838
openkal-macos 0.15.1 与 openkal-windows 0.13.3,以 `KAL_SPAWN_ONE_STRING` 启动命令解释器的 image 在 okrun
3939
下得到该标志的语义;三个包仍为同一版本、同一归档。openkal-musl 随 openkal-windows 0.13.3 与 openkal-ld 0.1.1
4040
移动,openkal-llvm-runtime 随 openkal-musl 移动。测试成员 `openkal`、`openkal-musl`、`openkal-tools` 随之移动。
41+
- **mcpplibs.os 0.2.0。** mcpp 的操作系统层所承载的内容进入 os:`exec`(本进程成为另一个程序)、
42+
一个管道按写入顺序承载输出与错误输出、追加写与持久化、卷的容量、`place` 与 `exchange`、属主、
43+
处理器数与可用内存、有界读取输入、发往错误流的输出、保留中断的原始模式,以及 Windows 的事实。
44+
基于 openkal 0.17.1(openkal-linux 0.18.2、openkal-macos 0.15.1、openkal-windows 0.13.3);ok image
45+
形态基于 openkal-llvm-runtime 0.16.3 与 openkal-tools 0.1.1。测试成员 `os` 移到 0.2.0,并观察两个输出
46+
经一个管道按序到达。
4147

4248
### Changed
4349

‎pkgs/o/os.lua‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ package = {
2626

2727
xpm = {
2828
linux = {
29+
["0.2.0"] = {
30+
url = "https://github.com/mcpplibs/os/archive/refs/tags/0.2.0.tar.gz",
31+
sha256 = "9dc147ad8dca0216549c40dc4dfabaed7394cdf7a7f253c58613ccc226abd04e",
32+
},
2933
["0.1.2"] = {
3034
url = "https://github.com/mcpplibs/os/archive/refs/tags/0.1.2.tar.gz",
3135
sha256 = "bf6f5cfb1518b045b693e246ee39306746074586434419d4052e648be111ea34",
@@ -43,6 +47,10 @@ package = {
4347
},
4448
},
4549
macosx = {
50+
["0.2.0"] = {
51+
url = "https://github.com/mcpplibs/os/archive/refs/tags/0.2.0.tar.gz",
52+
sha256 = "9dc147ad8dca0216549c40dc4dfabaed7394cdf7a7f253c58613ccc226abd04e",
53+
},
4654
["0.1.2"] = {
4755
url = "https://github.com/mcpplibs/os/archive/refs/tags/0.1.2.tar.gz",
4856
sha256 = "bf6f5cfb1518b045b693e246ee39306746074586434419d4052e648be111ea34",
@@ -60,6 +68,10 @@ package = {
6068
},
6169
},
6270
windows = {
71+
["0.2.0"] = {
72+
url = "https://github.com/mcpplibs/os/archive/refs/tags/0.2.0.tar.gz",
73+
sha256 = "9dc147ad8dca0216549c40dc4dfabaed7394cdf7a7f253c58613ccc226abd04e",
74+
},
6375
["0.1.2"] = {
6476
url = "https://github.com/mcpplibs/os/archive/refs/tags/0.1.2.tar.gz",
6577
sha256 = "bf6f5cfb1518b045b693e246ee39306746074586434419d4052e648be111ea34",

‎tests/examples/os/mcpp.toml‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
# mcpplibs.os test project: the library over this system's openkal
22
# implementation, on every runner --- a program started and read, a file
3-
# published, a list of directories split, and the platform the build is for.
3+
# published, a list of directories split, the platform the build is for, and a
4+
# program's two outputs on one pipe.
45
[package]
56
name = "os-tests"
67
version = "0.1.0"
78

89
[dependencies.mcpplibs]
9-
os = "0.1.2"
10+
os = "0.2.0"
1011

1112
[indices]
1213
mcpplibs = { path = "../../.." }

‎tests/examples/os/tests/os.cpp‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ int main(int argc, char** argv) {
1010
(void)os::stdio::write_output("echoed");
1111
return 0;
1212
}
13+
if (argc > 1 && std::string_view(argv[1]) == "--both") {
14+
(void)os::stdio::write_output("out ");
15+
(void)os::stdio::write_error("err");
16+
return 0;
17+
}
1318
int failures = 0;
1419
auto check = [&](bool ok, std::string_view what) { if (!ok) { ++failures; std::println(std::cerr, "FAIL: {}", what); } };
1520

@@ -39,6 +44,20 @@ int main(int argc, char** argv) {
3944
o.args.push_back("--echo");
4045
auto r = os::process::run(o);
4146
check(r && r->status.success() && r->out == "echoed", "a started program's output is read");
47+
48+
// 0.2.0: one pipe carries the output and the error output in the order written.
49+
o.args.back() = "--both";
50+
o.out = os::process::stdio::pipe;
51+
o.err = os::process::stdio::output;
52+
std::string merged;
53+
auto p = os::process::process::spawn(o);
54+
if (p) {
55+
for (;;) { auto c = p->read_output(); if (!c || c->empty()) break; merged += *c; }
56+
auto st = p->wait();
57+
check(st && st->success() && merged == "out err", "both outputs arrive on one pipe in order");
58+
} else {
59+
check(false, "a program with both outputs on one pipe starts");
60+
}
4261
}
4362
// 0.1.2: a symbol of the program resolves as the loader resolves it.
4463
if (os::library::supported())

0 commit comments

Comments
 (0)