Skip to content

Commit 7fe1bef

Browse files
authored
feat: introduce entryFiles in config to remove precompile transform (#88)
1 parent 54d652a commit 7fe1bef

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+386
-1240
lines changed

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
/dist
66

77
/build*
8-
/transform/*.mjs
9-
/transform/tsconfig.tsbuildinfo
108

119
/coverage
1210
/coverage-ts

.prettierignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
/coverage-ts
33
/dist
44
/node_modules
5-
/transform/*.mjs
65
/tests/ts/fixture
76
/third_party
87
/tests/cpp/lit/expectInstrument**/*.json

as-test.config.js

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,15 @@
1+
/**
2+
* @type {import("./config.d.ts").Config}
3+
*/
14
export default {
2-
/** file include in test */
35
include: ["assembly", "tests/as"],
4-
5-
/** optional: file exclude */
66
exclude: [],
7-
8-
/** optional: assemblyscript compile flag, default is --exportStart _start -O0 */
97
flags: "",
10-
11-
/**
12-
* optional: import functions
13-
* @param {ImportsArgument} runtime
14-
* @returns
15-
*/
168
imports(runtime) {
179
return {};
1810
},
19-
20-
/** optional: template file path, default "coverage" */
2111
temp: "coverage",
22-
23-
/** optional: report file path, default "coverage" */
2412
output: "coverage",
25-
26-
/** optional: test result output format, default "table" */
2713
mode: ["html", "json", "table"],
28-
2914
isolated: false,
3015
};

bin/cli.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,17 @@ const getBoolean = (optionValue, configValue) => {
8888
const isolatedInConfig = getBoolean(options.isolated, config.isolated);
8989
const isolated = isolatedInConfig ?? false;
9090

91+
const entryFiles = config.entryFiles ?? null;
92+
9193
/**
9294
* @type {import("../dist/interface.d.ts").TestOption}
9395
*/
9496
const testOption = {
9597
includes,
9698
excludes,
9799
testFiles,
100+
entryFiles,
101+
98102
testNamePattern: testNamePattern,
99103
collectCoverage,
100104
onlyFailures,

config.d.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Imports } from "./dist/interface.d.ts";
1+
import type { Imports } from "./dist/interface.d.ts";
22

33
export type OutputMode = "html" | "json" | "table";
44

@@ -7,14 +7,16 @@ export declare class Config {
77
include: string[];
88
/** Files to exclude from testing and coverage statistics, has higher priority than include */
99
exclude?: string[];
10+
/** entry files for the whole projects, used to collect all source code information. default value is `${include}/index.ts` */
11+
entryFiles?: string[];
1012

1113
/** whether to collect coverage information, default is true */
1214
collectCoverage?: boolean;
1315

1416
/** create an wasm instance for each test files. default is false (will be true in next major version) */
1517
isolated?: boolean;
1618

17-
/** assemblyscript compile flag, default is --exportStart _start --sourceMap --debug -O0 */
19+
/** assemblyscript compile flag, default is --exportStart __unit_test_start --sourceMap --debug -O0 */
1820
flags?: string;
1921
imports?: Imports;
2022

docs/release-note.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66

77
- Changed the default value of `isolated` from `true` to `false`.
88

9+
🛠️ Improvements
10+
11+
- Introduce new configuration `entryFiles` to reach all source code. ([#88](https://github.com/wasm-ecosystem/assemblyscript-unittest-framework/pull/88))
12+
913
## 1.4.1
1014

1115
🚀 Highlight Features

docs/technical-details/code-debug-info.md

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,4 @@
1919
}
2020
```
2121

22-
```ts
23-
interface CodeDebugInfo {
24-
debugFiles: string[];
25-
debugInfos: Record<string, FunctionDebugInfo>;
26-
}
27-
28-
interface FunctionDebugInfo {
29-
index: number;
30-
branchInfo: Branch[];
31-
lineInfo: LineInfos;
32-
}
33-
34-
type LineRange = [FileIndex, LineIndex, ColumnIndex][][];
35-
type LineInfos = LineRange[][];
36-
type FileIndex = number;
37-
type LineIndex = number;
38-
type ColumnIndex = number;
39-
type Branch = [number, number];
40-
```
22+
The schema corresponding to json can be found in interface `DebugInfo` in `src/interface.ts`.

eslint.config.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export default [
1010
{
1111
rules: {
1212
"unicorn/no-array-for-each": "off",
13+
"sonarjs/fixme-tag": "off",
1314
},
1415
},
1516
];

instrumentation/BasicBlockAnalysis.hpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,6 @@ namespace wasmInstrumentation {
1515
///
1616
class BasicBlockAnalysis final {
1717
public:
18-
///
19-
/// @brief Add include file to debug info analysis
20-
///
21-
/// @param include
22-
inline void addInclude(const std::string &&include) noexcept {
23-
includes.emplace_back(include);
24-
}
25-
2618
///
2719
/// @brief Add exclude file to debug info analysis
2820
///

instrumentation/CoverageInstru.cpp

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,6 @@ void CoverageInstru::innerAnalysis(BasicBlockAnalysis &basicBlockAnalysis) const
1111
Json::Reader jsonReader;
1212
Json::Value includesJsonValue;
1313
Json::Value excludesJsonValue;
14-
if (!config->includes.empty()) {
15-
jsonReader.parse(std::string(config->includes), includesJsonValue);
16-
if (includesJsonValue.isArray()) {
17-
const uint32_t includesJsonSize = includesJsonValue.size();
18-
for (uint32_t i = 0U; i < includesJsonSize; ++i) {
19-
basicBlockAnalysis.addInclude(includesJsonValue[i].asString());
20-
}
21-
}
22-
}
2314
if (!config->excludes.empty()) {
2415
jsonReader.parse(std::string(config->excludes), excludesJsonValue);
2516
if (excludesJsonValue.isArray()) {
@@ -181,8 +172,8 @@ extern "C" EMSCRIPTEN_KEEPALIVE wasmInstrumentation::InstrumentationResponse
181172
wasm_instrument(char const *const fileName, char const *const targetName,
182173
char const *const reportFunction, char const *const sourceMap,
183174
char const *const expectInfoOutputFilePath,
184-
char const *const debugInfoOutputFilePath, char const *const includes,
185-
char const *const excludes, bool skipLib, bool collectCoverage) noexcept {
175+
char const *const debugInfoOutputFilePath, char const *const excludes, bool skipLib,
176+
bool collectCoverage) noexcept {
186177

187178
wasmInstrumentation::InstrumentationConfig config;
188179
config.fileName = fileName;
@@ -191,7 +182,6 @@ wasm_instrument(char const *const fileName, char const *const targetName,
191182
config.sourceMap = sourceMap;
192183
config.expectInfoOutputFilePath = expectInfoOutputFilePath;
193184
config.debugInfoOutputFilePath = debugInfoOutputFilePath;
194-
config.includes = includes;
195185
config.excludes = excludes;
196186
config.skipLib = skipLib;
197187
config.collectCoverage = collectCoverage;

0 commit comments

Comments
 (0)