diff --git a/.gitignore b/.gitignore index 862f14a..e76bce3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ build +cov *.out *.o *.s \ No newline at end of file diff --git a/README.md b/README.md index 833acc0..5c3b900 100644 --- a/README.md +++ b/README.md @@ -188,3 +188,24 @@ $ sh boot.sh - `ungetc` 和 `stdin`(理论上非必须,可以在本语言中手动模拟) - `fprintf` 和 `stderr`(理论上非必须,仅用于输出错误信息) +## 测试 + +### 单元测试 + +TODO + +### 覆盖率 + +安装如下可视化工具 + +```sh +$ pip install gcovr +``` + +然后 + +```sh +$ sh cov.sh +``` + +就会在 cov 文件夹下生成自举的 coverage 数据 diff --git a/cov.sh b/cov.sh new file mode 100644 index 0000000..e0d0dec --- /dev/null +++ b/cov.sh @@ -0,0 +1,6 @@ +mkdir -p cov && cd cov && +rm * +gcc --coverage -g -O0 ../boot.c +./a.out < ../boot.c > /dev/null +gcov a-boot.c +python3 -m gcovr --html-details --html-theme github.green -o report.html -r .. \ No newline at end of file