@as-covers/assembly

中文文档
0.4.1发布于 2022/11/15MIT零依赖近 30 天下载 1万

AssemblyScript code coverage for as-covers

原始使用文档

AS-Covers

Code coverage for AssemblyScript projects that uses a few simple packages to make visualizing how well your code branches are covered.

Usage

First install from npm.

npm install @as-covers/core

Next, add the following transform and entry point to your AssemblyScript compilation.

# uses multiple lines for clarity
asc node_modules/@as-covers/assembly/index.ts
  --transform @as-covers/transform/lib/index.js
  --explicitStart

These will inject some immutable cover points into your web assembly binary.

The next step is to instantiate the module:

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());
}());

Covers is designed to work over multiple binary compilations with the transform applied. Each cover point is immutably hashed so that you can test code coverage with different test files.

Just remember to register the loader each time before calling the _start() method.

License

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.

版本与发布记录

@as-covers/assembly 共发布 9 个版本,首次发布于 2021/06/16;过去 12 个月发布了 0 个版本。

版本发布日期距今
0.4.1latest2022/11/153 年前
0.4.02022/11/143 年前
0.3.12022/08/284 年前
0.3.02022/08/204 年前
0.2.02021/06/245 年前
0.1.02021/06/195 年前

关于 @as-covers/assembly 的常见问题

@as-covers/assembly 是什么?

AssemblyScript code coverage for as-covers

如何安装 @as-covers/assembly?

在项目目录运行 npm install @as-covers/assembly,或使用 pnpm add / yarn add / bun add。

@as-covers/assembly 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/as-covers__assembly 是否存在。

@as-covers/assembly 可以商用吗?

@as-covers/assembly 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@as-covers/assembly 的下载量有多少?

根据 npm 官方下载统计,@as-covers/assembly 在 2026/10/07 – 2026/11/05 这 30 天内被下载 10,077 次,日均约 336 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@as-covers/assembly 还在维护吗?

最新版本 0.4.1 发布于 2022/11/15(3 年前);至今共发布 9 个版本,其中过去 12 个月发布了 0 个;首次发布于 2021/06/16。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。