Skip to content

Commit 97e0041

Browse files
committed
docs: step 2 的环境验证改用 mcpp test -p solutions
上一版让 step 2 跑裸 `mcpp test`,然后解释「全红是对的」。这在逻辑上站不住: 工具链坏掉时也是全红,学习者看着同样的输出,分辨不出是自己还没做题还是环境 没装好——一个只会红的命令没法用来验证环境。 solutions/ 成为工程之后就有了确定的绿: mcpp test -p solutions # 验证环境: 52 份参考答案, 应当全绿 mcpp test # 你的进度表: 练习还没做, 此刻全红 两条命令各自含义明确:第一条绿 = 工具链没问题;第二条红 = 你的起点。 README 三语 + book 两语 + chapter_1 两语同步。chapter_1 里另外写清了答案与 练习靠 tests/ 相对路径配对,以及 `mcpp test -p solutions cpp11` 的筛选用法。 撰稿技能(.agents/skills/d2mcpp-authoring)的路径与「答案怎么验」也跟随更新: 新增答案后可以直接 `mcpp test -p solutions <slug>` 自查,不必再走覆盖流程。
1 parent 7aee9c3 commit 97e0041

9 files changed

Lines changed: 49 additions & 34 deletions

File tree

.agents/skills/d2mcpp-authoring/SKILL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ When adding a feature numbered `NN` with slug `topic` (e.g. `06-scoped-enums`):
7171
2. `book/en/src/<std>/NN-topic.md` — en chapter (translate prose, keep code identical)
7272
3. `src/<std>/tests/NN-topic/K.cpp` — one or more exercises (`K` = 0,1,2…), zh comments
7373
4. `src/en/<std>/tests/NN-topic/K.cpp` — en exercises (translate comments only)
74-
5. `solutions/<std>/NN-topic/K.cpp` — reference solution per exercise (zh/en 共用)
74+
5. `solutions/tests/<std>/NN-topic/K.cpp` — reference solution per exercise (zh/en 共用)
7575
6. (nothing to register — exercises are tests, discovered by directory convention)
7676
8. Add the chapter line to **both** `book/src/SUMMARY.md` and `book/en/src/SUMMARY.md`
7777
9. Add a changelog entry to **both** `book/src/changelog.md` and `book/en/src/changelog.md`

.agents/skills/d2mcpp-authoring/references/anatomy.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ book/en/src/changelog.md # en changelog (add entry)
1919
src/<std>/tests/NN-topic/K.cpp # zh exercise(s) — no registration needed
2020
src/en/<std>/tests/NN-topic/K.cpp # en exercise(s) — no registration needed
2121
22-
solutions/<std>/NN-topic/K.cpp # reference solution(s), zh/en 共用
22+
solutions/tests/<std>/NN-topic/K.cpp # reference solution(s), zh/en 共用
2323
```
2424

2525
Repo-level shared basis (NOT per-lesson, created once, never edited by hand):
@@ -37,7 +37,7 @@ snapshot via `msvc-stl/SOURCE.md` when needed.
3737

3838
A new `<std>` section that does not exist yet needs: a `src/<std>/mcpp.toml` (copy
3939
`src/cpp14/mcpp.toml`, change the name), `src/<std>/tests/` + `src/en/<std>/tests/` +
40-
`solutions/<std>/` directories, the member added to the root `mcpp.toml`
40+
`solutions/tests/<std>/` directories, the member added to the root `mcpp.toml`
4141
workspace list (both `src/<std>` and `src/en/<std>`), and the section heading in both
4242
`SUMMARY.md` files (e.g. `# C++14核心语言特性` / `# C++14 Core Language
4343
Features`).
@@ -79,9 +79,11 @@ change compile flags.
7979

8080
## Solution registration — there is none either
8181

82-
Drop the file at `solutions/<std>/NN-topic/K.cpp` (zh/en share one solution).
83-
CI swaps it over the exercise and asserts it passes; see
84-
`d2x/buildtools/tests/e2e.sh`.
82+
Drop the file at `solutions/tests/<std>/NN-topic/K.cpp` (zh/en share one
83+
solution). `solutions/` is itself an mcpp package, so the file becomes a test by
84+
directory convention — verify it with `mcpp test -p solutions <slug>`, no copying
85+
involved. CI additionally swaps it over the exercise and asserts it passes there
86+
too; see `d2x/buildtools/tests/e2e.sh`.
8587

8688
## SUMMARY registration
8789

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,14 @@ xlings install d2x mcpp -y # d2x: exercise framework CLI | mcpp: C++ build & t
7777
```bash
7878
d2x install d2mcpp # download the course, toolchain auto-configured
7979
cd d2mcpp
80-
mcpp test # environment self-check — prints your progress table
80+
mcpp test -p solutions # verify the environment: 52 reference answers, all green
81+
mcpp test # your progress table: the exercises, all red for now
8182
```
8283

83-
> The exercises **are** the tests, and they ship unfinished — so a fresh `mcpp test` is
84-
> *supposed* to come out all red. What it verifies is everything around them: the
85-
> toolchain resolved, the `d2x` library built, and the runner reached every exercise.
86-
> Copy `solutions/` over the exercise files and the very same command goes all green
87-
> (that is exactly what CI does).
84+
> `solutions/` is a real mcpp package, so the first command compiles and runs all 52
85+
> reference answers — an unambiguous green tick that your toolchain works. The second
86+
> one is your own progress table: the exercises **are** the tests and they ship
87+
> unfinished, so red is exactly where you start.
8888
8989
<details>
9090
<summary>optional - start from the git source instead</summary>

README.zh.hant.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,13 @@ xlings install d2x mcpp -y # d2x: 練習框架 CLI | mcpp: C++ 建置與測試
7777
```bash
7878
d2x install d2mcpp # 下載課程,環境自動配置
7979
cd d2mcpp
80-
mcpp test # 環境自檢 —— 印出你的進度表
80+
mcpp test -p solutions # 驗證環境: 52 份參考答案, 應當全綠
81+
mcpp test # 你的進度表: 練習還沒做, 此刻全紅
8182
```
8283

83-
> 練習**就是**測試, 而且發下來時是沒做完的 —— 所以剛拿到課程時 `mcpp test` **本來就該全紅**
84-
> 它驗的是練習之外的一切: 工具鏈解析成功、`d2x` 函式庫編譯通過、測試執行器逐題都跑到了。
85-
> `solutions/` 覆蓋到練習檔案上, 同一條指令就會全綠(CI 做的正是這件事)
84+
> `solutions/` 本身就是一個 mcpp 工程, 所以第一條指令會真的編譯並執行全部 52 份參考答案 ——
85+
> 全綠即工具鏈沒問題, 這是個不含糊的訊號。第二條才是你自己的進度表: 練習**就是**測試,
86+
> 而且發下來時是沒做完的, 全紅正是起點
8687
8788
<details>
8889
<summary>可選 - 改用 clone 專案原始碼的方式</summary>

README.zh.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,13 @@ xlings install d2x mcpp -y # d2x: 练习框架 CLI | mcpp: C++ 构建与测试
7777
```bash
7878
d2x install d2mcpp # 下载课程,环境自动配置
7979
cd d2mcpp
80-
mcpp test # 环境自检 —— 打印你的进度表
80+
mcpp test -p solutions # 验证环境: 52 份参考答案, 应当全绿
81+
mcpp test # 你的进度表: 练习还没做, 此刻全红
8182
```
8283

83-
> 练习**就是**测试, 而且发下来时是没做完的 —— 所以刚拿到课程时 `mcpp test` **本来就该全红**
84-
> 它验的是练习之外的一切: 工具链解析成功、`d2x` 库编译通过、测试运行器逐题都跑到了。
85-
> `solutions/` 覆盖到练习文件上, 同一条命令就会全绿(CI 做的正是这件事)
84+
> `solutions/` 本身就是一个 mcpp 工程, 所以第一条命令会真的编译并运行全部 52 份参考答案 ——
85+
> 全绿即工具链没问题, 这是个不含糊的信号。第二条才是你自己的进度表: 练习**就是**测试,
86+
> 而且发下来时是没做完的, 全红正是起点
8687
8788
<details>
8889
<summary>可选 - 改用 clone 项目源码的方式</summary>

book/en/src/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,14 @@ xlings install d2x mcpp -y # d2x: exercise framework CLI | mcpp: C++ build & t
7373
```bash
7474
d2x install d2mcpp # download the course, toolchain auto-configured
7575
cd d2mcpp
76-
mcpp test # environment self-check — prints your progress table
76+
mcpp test -p solutions # verify the environment: 52 reference answers, all green
77+
mcpp test # your progress table: the exercises, all red for now
7778
```
7879

79-
> The exercises **are** the tests, and they ship unfinished — so a fresh `mcpp test` is
80-
> *supposed* to come out all red. What it verifies is everything around them: the
81-
> toolchain resolved, the `d2x` library built, and the runner reached every exercise.
82-
> Copy `solutions/` over the exercise files and the very same command goes all green
83-
> (that is exactly what CI does).
80+
> `solutions/` is a real mcpp package, so the first command compiles and runs all 52
81+
> reference answers — an unambiguous green tick that your toolchain works. The second
82+
> one is your own progress table: the exercises **are** the tests and they ship
83+
> unfinished, so red is exactly where you start.
8484
8585
<details>
8686
<summary>optional - start from the git source instead</summary>

book/en/src/base/chapter_1.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,15 @@ d2x install d2mcpp
5454
5555
```bash
5656
cd d2mcpp
57-
mcpp test
57+
mcpp test -p solutions # verify the environment: 52 reference answers, all green
58+
mcpp test # your progress table: the exercises, all red for now
5859
```
5960

60-
> The exercises **are** the tests, and they ship unfinished — so this is *supposed* to come out all red. What it verifies is everything around them: the toolchain resolved, the `d2x` library built, and the runner reached every exercise. Note that `solutions/` is not a workspace member, so `mcpp test` never runs it; copy it over the exercise files and only then does the same command go all green (that is exactly what CI does).
61+
> `solutions/` is a real mcpp package (`solutions/mcpp.toml` + `solutions/tests/`), so the first command actually compiles and runs all 52 reference answers — green means your toolchain is fine. The second is your own progress table: the exercises **are** the tests and they ship unfinished, so red is exactly where you start.
62+
>
63+
> An answer and its exercise are paired by their `tests/`-relative path:
64+
> `solutions/tests/cpp11/00-auto-and-decltype/0.cpp` ←→ `src/cpp11/tests/00-auto-and-decltype/0.cpp`.
65+
> To run just one slice: `mcpp test -p solutions cpp11`.
6166
6267
### Local E-book
6368

book/src/README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,13 @@ xlings install d2x mcpp -y # d2x: 练习框架 CLI | mcpp: C++ 构建与测试
7373
```bash
7474
d2x install d2mcpp # 下载课程,环境自动配置
7575
cd d2mcpp
76-
mcpp test # 环境自检 —— 打印你的进度表
76+
mcpp test -p solutions # 验证环境: 52 份参考答案, 应当全绿
77+
mcpp test # 你的进度表: 练习还没做, 此刻全红
7778
```
7879

79-
> 练习**就是**测试, 而且发下来时是没做完的 —— 所以刚拿到课程时 `mcpp test` **本来就该全红**
80-
> 它验的是练习之外的一切: 工具链解析成功、`d2x` 库编译通过、测试运行器逐题都跑到了。
81-
> `solutions/` 覆盖到练习文件上, 同一条命令就会全绿(CI 做的正是这件事)
80+
> `solutions/` 本身就是一个 mcpp 工程, 所以第一条命令会真的编译并运行全部 52 份参考答案 ——
81+
> 全绿即工具链没问题, 这是个不含糊的信号。第二条才是你自己的进度表: 练习**就是**测试,
82+
> 而且发下来时是没做完的, 全红正是起点
8283
8384
<details>
8485
<summary>可选 - 改用 clone 项目源码的方式</summary>

book/src/base/chapter_1.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,15 @@ d2x install d2mcpp
5454
5555
```bash
5656
cd d2mcpp
57-
mcpp test
57+
mcpp test -p solutions # 验证环境: 52 份参考答案, 应当全绿
58+
mcpp test # 你的进度表: 练习还没做, 此刻全红
5859
```
5960

60-
> 练习**就是**测试, 而且发下来时是没做完的 —— 所以这里**本来就该全红**。它验的是练习之外的一切: 工具链解析成功、`d2x` 库编译通过、测试运行器逐题都跑到了。注意 `solutions/` 不是工作区成员, `mcpp test` 不会去跑它; 把它覆盖到练习文件上, 同一条命令才会全绿(CI 做的正是这件事)。
61+
> `solutions/` 本身就是一个 mcpp 工程(`solutions/mcpp.toml` + `solutions/tests/`), 所以第一条命令会真的编译并运行全部 52 份参考答案 —— 全绿即工具链没问题。第二条才是你自己的进度表: 练习**就是**测试, 而且发下来时是没做完的, 全红正是起点。
62+
>
63+
> 答案与练习的对应关系就是 `tests/` 下的相对路径:
64+
> `solutions/tests/cpp11/00-auto-and-decltype/0.cpp` ←→ `src/cpp11/tests/00-auto-and-decltype/0.cpp`
65+
> 想只看某一部分: `mcpp test -p solutions cpp11`
6166
6267
### 本地电子书
6368

0 commit comments

Comments
 (0)