brainstorming
brainstorming
You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation).
run-puzzle-testsRun the jigsawR test suite via WSL R execution. Supports full suite, filtered by pattern, or single file. Interprets pass/fail/skip counts and identifies failing tests. Never uses --vanilla flag (renv needs .Rprofile for activation). Use after modifying any R source code, after adding a new puzzle type or feature, before committing changes to verify nothing…
Independent GitHub snapshot · Automated classification · Original documentation governs
執行 jigsawR 測試套件並解讀結果。
full、filtered 或 single)"snic"、"rectangular")| 範圍 | 適用時機 | 時長 |
|---|---|---|
| Full | 提交前、重大變更後 | 約 2-5 分 |
| Filtered | 處理單一拼圖類型 | 約 30 秒 |
| Single | 對特定測試文件除錯 | 約 10 秒 |
預期: 依當前工作流程選擇測試範圍:提交前用全套件、處理特定拼圖類型時用過濾、除錯單一測試時用單文件。
失敗時: 若不確定用何範圍,預設用全套件。較久但可捕跨類型回歸。
全套件:
建立腳本文件(如 /tmp/run_tests.R):
devtools::test()
R_EXE="/mnt/c/Program Files/R/R-4.5.0/bin/Rscript.exe"
cd /mnt/d/dev/p/jigsawR && "$R_EXE" -e "devtools::test()"
依模式過濾:
"$R_EXE" -e "devtools::test(filter = 'snic')"
單一文件:
"$R_EXE" -e "testthat::test_file('tests/testthat/test-snic-puzzles.R')"
預期: 測試輸出含通過/失敗/跳過計數。
失敗時:
--vanilla 旗標;renv 需 .Rprofile 以啟動renv::restore()尋找摘要行:
[ FAIL 0 | WARN 0 | SKIP 7 | PASS 2042 ]
snic)預期: 摘要行已解析以識別 PASS、FAIL、SKIP 與 WARN 計數。乾淨之執行 FAIL = 0。
失敗時: 若摘要行不可見,測試執行器可能於完成前崩潰。檢查摘要上方之 R 級錯誤。若輸出截斷,重定向至文件:"$R_EXE" -e "devtools::test()" > test_results.txt 2>&1。
若測試失敗:
# Run just the failing test with verbose output
"$R_EXE" -e "testthat::test_file('tests/testthat/test-failing.R', reporter = 'summary')"
預期: 各失敗測試之根因已識別。失敗或為真實回歸(代碼需修)或為測試環境問題(缺依賴、路徑問題)。
失敗時: 若失敗訊息不清,於測試中加入 browser() 或 print() 語句並以 testthat::test_file() 重新執行作互動除錯。
當缺選擇性依賴時跳過測試屬正常:
snic 套件測試以 skip_if_not_installed("snic") 跳過skip_on_os() 跳過skip_on_cran()確認跳過原因合理,未掩蓋真實失敗。
預期: 所有跳過皆有合理理由(選擇性依賴未安裝、平台特定跳過、僅 CRAN 跳過)。無跳過掩蓋實際測試失敗。
失敗時: 若某跳過可疑,暫時移除 skip_if_*() 呼叫並執行測試以見其通過或揭露隱藏失敗。
--vanilla:破壞 renv 啟動。對 jigsawR 切勿用之。-e 字串:Shell 跳脫問題引發 Exit code 5。改用腳本文件。devtools::load_all() 或 devtools::document()。DESCRIPTION 之 Suggests 欄。testthat::test_file() 順序執行。generate-puzzle — 產生拼圖以驗證行為符合測試add-puzzle-type — 新類型需全面測試套件write-testthat-tests — 撰寫 R 測試之通用模式validate-piles-notation — 獨立測試 PILES 解析