as-test 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/as-test.yml +3 -0
- package/CHANGELOG.md +4 -1
- package/README.md +73 -67
- package/as-test.config.json +7 -10
- package/assembly/__tests__/array.spec.ts +19 -0
- package/assembly/__tests__/math.spec.ts +16 -0
- package/assembly/__tests__/sleep.spec.ts +28 -0
- package/assembly/index.ts +181 -165
- package/assembly/src/expectation.ts +119 -112
- package/assembly/src/log.ts +19 -0
- package/assembly/src/suite.ts +99 -0
- package/assembly/src/tests.ts +10 -0
- package/assembly/tsconfig.json +1 -1
- package/assembly/util/helpers.ts +0 -33
- package/assembly/util/term.ts +55 -0
- package/assets/img/download.png +0 -0
- package/bin/about.js +135 -0
- package/bin/build.js +72 -131
- package/bin/index.js +70 -112
- package/bin/init.js +211 -39
- package/bin/reporter.js +1 -0
- package/bin/run.js +226 -68
- package/bin/types.js +25 -31
- package/bin/util.js +44 -20
- package/cli/build.ts +70 -109
- package/cli/index.ts +148 -159
- package/cli/init.ts +235 -34
- package/cli/reporter.ts +1 -0
- package/cli/run.ts +266 -57
- package/cli/types.ts +6 -11
- package/cli/util.ts +35 -0
- package/package.json +6 -2
- package/run/package.json +27 -0
- package/tests/array.run.js +7 -0
- package/tests/math.run.js +7 -0
- package/tests/sleep.run.js +7 -0
- package/transform/lib/coverage.js +325 -319
- package/transform/lib/index.js +51 -31
- package/transform/lib/index.js.map +1 -1
- package/transform/lib/mock.js +61 -55
- package/transform/lib/mock.js.map +1 -1
- package/transform/package.json +1 -1
- package/transform/src/index.ts +22 -3
- package/transform/src/mock.ts +1 -1
- package/asconfig.json +0 -31
- package/assembly/__tests__/example.spec.ts +0 -79
- package/assembly/reporters/tap.ts +0 -30
- package/assembly/src/group.ts +0 -44
- package/assembly/src/node.ts +0 -13
- package/test.config.json +0 -0
- package/tests/test.tap +0 -14
- package/unision +0 -38
- package/unision.pub +0 -1
- package/utils.ts +0 -1
package/cli/util.ts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from "fs";
|
|
2
|
+
import { Config } from "./types.js";
|
|
3
|
+
import chalk from "chalk";
|
|
4
|
+
import { delimiter, join } from "path";
|
|
5
|
+
|
|
1
6
|
export function formatTime(ms: number): string {
|
|
2
7
|
if (ms < 0) {
|
|
3
8
|
throw new Error("Time should be a non-negative number.");
|
|
@@ -28,3 +33,33 @@ export function formatTime(ms: number): string {
|
|
|
28
33
|
|
|
29
34
|
return `${us}us`;
|
|
30
35
|
}
|
|
36
|
+
|
|
37
|
+
export function loadConfig(CONFIG_PATH: string, warn: boolean = false): Config {
|
|
38
|
+
if (!existsSync(CONFIG_PATH)) {
|
|
39
|
+
if (warn)
|
|
40
|
+
console.log(
|
|
41
|
+
`${chalk.bgMagentaBright(" WARN ")}${chalk.dim(":")} Could not locate config file in the current directory! Continuing with default config.`,
|
|
42
|
+
);
|
|
43
|
+
return new Config();
|
|
44
|
+
} else {
|
|
45
|
+
return Object.assign(
|
|
46
|
+
new Config(),
|
|
47
|
+
JSON.parse(readFileSync(CONFIG_PATH).toString()),
|
|
48
|
+
) as Config;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function getExec(exec: string): string | null {
|
|
53
|
+
const PATH = process.env.PATH.split(delimiter);
|
|
54
|
+
|
|
55
|
+
for (const pathDir of PATH) {
|
|
56
|
+
const fullPath = join(
|
|
57
|
+
pathDir,
|
|
58
|
+
exec + (process.platform === "win32" ? ".exe" : ""),
|
|
59
|
+
);
|
|
60
|
+
if (existsSync(fullPath)) {
|
|
61
|
+
return fullPath;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return null;
|
|
65
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "as-test",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Testing framework for AssemblyScript. Compatible with WASI or Bindings ",
|
|
5
5
|
"types": "assembly/index.ts",
|
|
6
6
|
"author": "Jairus Tanaka",
|
|
@@ -11,12 +11,14 @@
|
|
|
11
11
|
"pretest": "node ./bin/index.js build",
|
|
12
12
|
"build:transform": "tsc -p ./transform",
|
|
13
13
|
"build:cli": "tsc -p cli",
|
|
14
|
+
"build:run": "tsc -p run",
|
|
14
15
|
"prettier": "prettier -w .",
|
|
15
16
|
"prepublish": "npm run build:cli && npm run build:transform && npm run test"
|
|
16
17
|
},
|
|
17
18
|
"devDependencies": {
|
|
18
19
|
"@assemblyscript/wasi-shim": "^0.1.0",
|
|
19
20
|
"@types/node": "^20.14.10",
|
|
21
|
+
"as-sleep": "^0.0.2",
|
|
20
22
|
"as-test": "./",
|
|
21
23
|
"assemblyscript": "^0.27.29",
|
|
22
24
|
"assemblyscript-prettier": "^3.0.1",
|
|
@@ -29,7 +31,9 @@
|
|
|
29
31
|
"as-variant": "^0.4.1",
|
|
30
32
|
"chalk": "^5.3.0",
|
|
31
33
|
"glob": "^11.0.0",
|
|
32
|
-
"jest": "^29.7.0"
|
|
34
|
+
"jest": "^29.7.0",
|
|
35
|
+
"json-as": "^0.9.14",
|
|
36
|
+
"typer-diff": "^1.1.1"
|
|
33
37
|
},
|
|
34
38
|
"overrides": {
|
|
35
39
|
"assemblyscript": "$assemblyscript",
|
package/run/package.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@as-test/run",
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"description": "Testing framework for AssemblyScript. Compatible with WASI or Bindings ",
|
|
5
|
+
"main": "./lib/index.js",
|
|
6
|
+
"author": "Jairus Tanaka",
|
|
7
|
+
"contributors": [],
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"scripts": {},
|
|
10
|
+
"devDependencies": {
|
|
11
|
+
"typescript": "^5.5.3"
|
|
12
|
+
},
|
|
13
|
+
"dependencies": {},
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "git+https://github.com/JairusSW/as-test.git"
|
|
17
|
+
},
|
|
18
|
+
"keywords": [],
|
|
19
|
+
"bugs": {
|
|
20
|
+
"url": "https://github.com/JairusSW/as-test/issues"
|
|
21
|
+
},
|
|
22
|
+
"homepage": "https://github.com/JairusSW/as-test#readme",
|
|
23
|
+
"type": "module",
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"@JairusSW:registry": "https://npm.pkg.github.com"
|
|
26
|
+
}
|
|
27
|
+
}
|