AS-覆盖
AssemblyScript 工程的代码覆盖,这些工程使用几个简单的软件包来使您代码分支的覆盖程度可视化.
使用量
首先从 npm 安装 .
npm install @as-covers/core
下一步,在您的 Assembly 汇编中添加以下的转换和切入点 .
# uses multiple lines for clarity
asc node_modules/@as-covers/assembly/index.ts
--transform @as-covers/transform/lib/index.js
--explicitStart
这些会给您的网络组装二进制注入一些不可改变的封面点 .
下一步是即时化模块:
import { Covers } from "@as-covers/glue";
import * as fs from "fs";
import { instantiate } from "@assemblyscript/loader";
// import your web assembly binary
const binary = fs.readFileSync("build/untouched.wasm");
const covers = new Covers();
// Install your imports here
const imports = covers.installImports({});
(async function() {
const loader = await instantiate(binary, imports);
covers.registerLoader(loader);
loader.exports._start();
process.stdout.write(covers.stringify());
}());
封面被设计为与所应用的变换在多个二进制编译上工作. 每个封面点都无一例外地散开,这样您就可以用不同的测试文件测试代码覆盖.
记得每次打来之前都要登记装载器 _start() 方法.
许可证
MIT License
Copyright (c) 2021 Joshua Tenner <[email protected]>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.