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/bin/about.js
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
export function about() {
|
|
3
|
+
console.log(
|
|
4
|
+
chalk.bold.blueBright("as-test") +
|
|
5
|
+
" is a testing framework for AssemblyScript. " +
|
|
6
|
+
chalk.dim("(v" + version + ")") +
|
|
7
|
+
"\n",
|
|
8
|
+
);
|
|
9
|
+
console.log(
|
|
10
|
+
chalk.bold("Usage: as-test") +
|
|
11
|
+
" " +
|
|
12
|
+
chalk.dim("<command>") +
|
|
13
|
+
" " +
|
|
14
|
+
chalk.bold.blueBright("[...flags]") +
|
|
15
|
+
" " +
|
|
16
|
+
chalk.bold("[...args]") +
|
|
17
|
+
" " +
|
|
18
|
+
chalk.dim("(alias: ast)") +
|
|
19
|
+
"\n",
|
|
20
|
+
);
|
|
21
|
+
console.log(chalk.bold("Commands:"));
|
|
22
|
+
console.log(
|
|
23
|
+
" " +
|
|
24
|
+
chalk.bold.blueBright("run") +
|
|
25
|
+
" " +
|
|
26
|
+
chalk.dim("<my-test.spec.ts>") +
|
|
27
|
+
" " +
|
|
28
|
+
"Run unit tests with selected runtime",
|
|
29
|
+
);
|
|
30
|
+
console.log(
|
|
31
|
+
" " +
|
|
32
|
+
chalk.bold.blueBright("build") +
|
|
33
|
+
" " +
|
|
34
|
+
chalk.dim("<my-test.spec.ts>") +
|
|
35
|
+
" " +
|
|
36
|
+
"Build unit tests and compile",
|
|
37
|
+
);
|
|
38
|
+
console.log(
|
|
39
|
+
" " +
|
|
40
|
+
chalk.bold.blueBright("test") +
|
|
41
|
+
" " +
|
|
42
|
+
chalk.dim("<my-test.spec.ts>") +
|
|
43
|
+
" " +
|
|
44
|
+
"Build and run unit tests with selected runtime" +
|
|
45
|
+
"\n",
|
|
46
|
+
);
|
|
47
|
+
console.log(
|
|
48
|
+
" " +
|
|
49
|
+
chalk.bold.magentaBright("init") +
|
|
50
|
+
" " +
|
|
51
|
+
chalk.strikethrough.dim("") +
|
|
52
|
+
" " +
|
|
53
|
+
"Initialize an empty testing template",
|
|
54
|
+
);
|
|
55
|
+
console.log(
|
|
56
|
+
" " +
|
|
57
|
+
chalk.strikethrough.bold.magentaBright("config") +
|
|
58
|
+
" " +
|
|
59
|
+
chalk.strikethrough.dim("as-test.config.json") +
|
|
60
|
+
" " +
|
|
61
|
+
"Specify the configuration file",
|
|
62
|
+
);
|
|
63
|
+
console.log(
|
|
64
|
+
" " +
|
|
65
|
+
chalk.strikethrough.bold.magentaBright("reporter") +
|
|
66
|
+
" " +
|
|
67
|
+
chalk.strikethrough.dim("<tap>") +
|
|
68
|
+
" " +
|
|
69
|
+
"Specify the test reporter to use",
|
|
70
|
+
);
|
|
71
|
+
console.log(
|
|
72
|
+
" " +
|
|
73
|
+
chalk.strikethrough.bold.magentaBright("use") +
|
|
74
|
+
" " +
|
|
75
|
+
chalk.strikethrough.dim("wasmtime") +
|
|
76
|
+
" " +
|
|
77
|
+
"Specify the runtime to use" +
|
|
78
|
+
"\n",
|
|
79
|
+
);
|
|
80
|
+
console.log(chalk.bold("Flags:"));
|
|
81
|
+
console.log(
|
|
82
|
+
" " +
|
|
83
|
+
chalk.strikethrough.dim("run") +
|
|
84
|
+
" " +
|
|
85
|
+
chalk.strikethrough.bold.blue("--coverage") +
|
|
86
|
+
" " +
|
|
87
|
+
"Use code coverage",
|
|
88
|
+
);
|
|
89
|
+
console.log(
|
|
90
|
+
" " +
|
|
91
|
+
chalk.strikethrough.dim("run") +
|
|
92
|
+
" " +
|
|
93
|
+
chalk.strikethrough.bold.blue("--snapshot") +
|
|
94
|
+
" " +
|
|
95
|
+
"Take a snapshot of the tests",
|
|
96
|
+
);
|
|
97
|
+
console.log(
|
|
98
|
+
" " +
|
|
99
|
+
chalk.strikethrough.dim("use") +
|
|
100
|
+
" " +
|
|
101
|
+
chalk.strikethrough.bold.blue("--list") +
|
|
102
|
+
" " +
|
|
103
|
+
"List supported runtimes",
|
|
104
|
+
);
|
|
105
|
+
console.log(
|
|
106
|
+
" " +
|
|
107
|
+
chalk.strikethrough.dim("reporter") +
|
|
108
|
+
" " +
|
|
109
|
+
chalk.strikethrough.bold.blue("--list") +
|
|
110
|
+
" " +
|
|
111
|
+
"List supported reporters",
|
|
112
|
+
);
|
|
113
|
+
console.log(
|
|
114
|
+
" " +
|
|
115
|
+
chalk.strikethrough.dim("<command>") +
|
|
116
|
+
" " +
|
|
117
|
+
chalk.strikethrough.bold.blue("--help") +
|
|
118
|
+
" " +
|
|
119
|
+
"Print info about command" +
|
|
120
|
+
"\n",
|
|
121
|
+
);
|
|
122
|
+
console.log(
|
|
123
|
+
chalk.dim(
|
|
124
|
+
"If your using this, consider dropping a star, it would help a lot!",
|
|
125
|
+
) + "\n",
|
|
126
|
+
);
|
|
127
|
+
console.log(
|
|
128
|
+
"View the repo: " +
|
|
129
|
+
chalk.magenta("https://github.com/JairusSW/as-test"),
|
|
130
|
+
);
|
|
131
|
+
console.log(
|
|
132
|
+
"View the docs: " +
|
|
133
|
+
chalk.strikethrough.blue("https://docs.jairus.dev/as-test"),
|
|
134
|
+
);
|
|
135
|
+
}
|
package/bin/build.js
CHANGED
|
@@ -1,145 +1,86 @@
|
|
|
1
1
|
import { existsSync, readFileSync } from "fs";
|
|
2
|
-
import { Config } from "./types.js";
|
|
3
2
|
import { glob } from "glob";
|
|
4
3
|
import chalk from "chalk";
|
|
5
|
-
import {
|
|
6
|
-
import { formatTime } from "./util.js";
|
|
4
|
+
import { execSync } from "child_process";
|
|
7
5
|
import * as path from "path";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
" Could not locate
|
|
16
|
-
"\n",
|
|
17
|
-
);
|
|
18
|
-
config = new Config();
|
|
19
|
-
} else {
|
|
20
|
-
config = Object.assign(
|
|
21
|
-
new Config(),
|
|
22
|
-
JSON.parse(readFileSync(CONFIG_PATH).toString()),
|
|
23
|
-
);
|
|
24
|
-
console.log(chalk.dim("Loading config from: " + CONFIG_PATH) + "\n");
|
|
25
|
-
}
|
|
26
|
-
const ASCONFIG_PATH = path.join(process.cwd(), config.config);
|
|
27
|
-
if (!existsSync(ASCONFIG_PATH)) {
|
|
28
|
-
console.log(
|
|
29
|
-
chalk.bgMagentaBright(" WARN ") +
|
|
30
|
-
chalk.dim(":") +
|
|
31
|
-
' Could not locate asconfig.json file! If you do not want to provide a config, set "config": "none". Continuing with default config.' +
|
|
32
|
-
"\n",
|
|
33
|
-
);
|
|
34
|
-
}
|
|
35
|
-
const pkg = JSON.parse(readFileSync("./package.json").toString());
|
|
36
|
-
let buildCommands = [];
|
|
37
|
-
if (config.buildOptions.wasi) {
|
|
38
|
-
if (!existsSync("./node_modules/@assemblyscript/wasi-shim/asconfig.json")) {
|
|
39
|
-
console.log(
|
|
40
|
-
chalk.bgRed(" ERROR ") +
|
|
41
|
-
chalk.dim(":") +
|
|
42
|
-
" " +
|
|
43
|
-
"could not find @assemblyscript/wasi-shim! Add it to your dependencies to run with WASI!",
|
|
44
|
-
);
|
|
45
|
-
process.exit(1);
|
|
6
|
+
import { loadConfig } from "./util.js";
|
|
7
|
+
const CONFIG_PATH = path.join(process.cwd(), "./as-test.config.json");
|
|
8
|
+
const PKG_PATH = path.join(process.cwd(), "./package.json");
|
|
9
|
+
export async function build() {
|
|
10
|
+
let config = loadConfig(CONFIG_PATH, true);
|
|
11
|
+
const ASCONFIG_PATH = path.join(process.cwd(), config.config);
|
|
12
|
+
if (config.config && config.config !== "none" && !existsSync(ASCONFIG_PATH)) {
|
|
13
|
+
console.log(`${chalk.bgMagentaBright(" WARN ")}${chalk.dim(":")} Could not locate asconfig.json file! If you do not want to provide a config, set "config": "none"`);
|
|
46
14
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
console.log(
|
|
59
|
-
chalk.bold.bgMagentaBright(" WARN ") +
|
|
60
|
-
chalk.dim(": @assemblyscript/wasi-shim") +
|
|
61
|
-
" is not included in project dependencies!",
|
|
62
|
-
);
|
|
15
|
+
ensureDeps(config);
|
|
16
|
+
let pkgRunner = getPkgRunner();
|
|
17
|
+
const inputFiles = await glob(config.input);
|
|
18
|
+
let buildArgs = getBuildArgs(config);
|
|
19
|
+
for (const file of inputFiles) {
|
|
20
|
+
let cmd = `${pkgRunner} asc ${file}${buildArgs}`;
|
|
21
|
+
const outFile = `${config.outDir}/${file.slice(file.lastIndexOf("/") + 1).replace(".ts", ".wasm")}`;
|
|
22
|
+
if (config.outDir) {
|
|
23
|
+
cmd += " -o " + outFile;
|
|
24
|
+
}
|
|
25
|
+
buildFile(cmd);
|
|
63
26
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
82
|
-
console.log("");
|
|
83
|
-
const inputFiles = await glob(config.input);
|
|
84
|
-
for (const file of inputFiles) {
|
|
85
|
-
console.log(chalk.dim("Including " + file));
|
|
86
|
-
let command = `${packageManagerCommand} asc ${file}${args.length ? " " + args.join(" ") : ""}`;
|
|
87
|
-
if (config.config !== "none") {
|
|
88
|
-
command += " --config " + config.config;
|
|
27
|
+
}
|
|
28
|
+
function ensureDeps(config) {
|
|
29
|
+
const pkg = JSON.parse(readFileSync(PKG_PATH).toString());
|
|
30
|
+
if (config.buildOptions.target == "wasi") {
|
|
31
|
+
if (!existsSync("./node_modules/@assemblyscript/wasi-shim/asconfig.json")) {
|
|
32
|
+
console.log(`${chalk.bgRed(" ERROR ")}${chalk.dim(":")} could not find @assemblyscript/wasi-shim! Add it to your dependencies to run with WASI!`);
|
|
33
|
+
process.exit(1);
|
|
34
|
+
}
|
|
35
|
+
if (pkg.dependencies &&
|
|
36
|
+
!Object.keys(pkg.dependencies).includes("@assemblyscript/wasi-shim") &&
|
|
37
|
+
pkg.devDependencies &&
|
|
38
|
+
!Object.keys(pkg.devDependencies).includes("@assemblyscript/wasi-shim") &&
|
|
39
|
+
pkg.peerDependencies &&
|
|
40
|
+
!Object.keys(pkg.peerDependencies).includes("@assemblyscript/wasi-shim") &&
|
|
41
|
+
existsSync("./node_modules/@assemblyscript/wasi-shim/asconfig.json")) {
|
|
42
|
+
console.log(`${chalk.bold.bgMagentaBright(" WARN ")}${chalk.dim(":")} @assemblyscript/wasi-shim is not included in project dependencies!"`);
|
|
43
|
+
}
|
|
89
44
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
45
|
+
}
|
|
46
|
+
function getPkgRunner() {
|
|
47
|
+
switch (process.env.npm_config_user_agent) {
|
|
48
|
+
case "pnpm": {
|
|
49
|
+
return "pnpx";
|
|
50
|
+
}
|
|
51
|
+
case "yarn": {
|
|
52
|
+
return "yarn";
|
|
53
|
+
}
|
|
54
|
+
case "bun": {
|
|
55
|
+
return "bunx";
|
|
56
|
+
}
|
|
93
57
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
58
|
+
return "npx";
|
|
59
|
+
}
|
|
60
|
+
function buildFile(command) {
|
|
61
|
+
execSync(command, { stdio: "inherit" });
|
|
62
|
+
}
|
|
63
|
+
function getBuildArgs(config) {
|
|
64
|
+
let buildArgs = "";
|
|
65
|
+
buildArgs += " --transform as-test/transform --transform json-as/transform";
|
|
66
|
+
if (config.config && config.config !== "none") {
|
|
67
|
+
buildArgs += " --config " + config.config;
|
|
100
68
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
if (config.coverage.show) command += " --use COVERAGE_SHOW=1";
|
|
69
|
+
// Should also strip any bindings-enabling from asconfig
|
|
70
|
+
if (config.buildOptions.target == "bindings") {
|
|
71
|
+
buildArgs += " --bindings raw --exportRuntime --exportStart _start";
|
|
105
72
|
}
|
|
106
|
-
if (config.buildOptions.
|
|
107
|
-
|
|
73
|
+
else if (config.buildOptions.target == "wasi") {
|
|
74
|
+
buildArgs +=
|
|
75
|
+
" --config ./node_modules/@assemblyscript/wasi-shim/asconfig.json";
|
|
108
76
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
)
|
|
113
|
-
) {
|
|
114
|
-
command += " --exportStart";
|
|
77
|
+
else {
|
|
78
|
+
console.log(`${chalk.bgRed(" ERROR ")}${chalk.dim(":")} could determine target in config! Set target to 'bindings' or 'wasi'`);
|
|
79
|
+
process.exit(0);
|
|
115
80
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
return new Promise((resolve, _) => {
|
|
120
|
-
console.log(chalk.dim("Building: " + command));
|
|
121
|
-
exec(command, (err, stdout, stderr) => {
|
|
122
|
-
if (config.buildOptions.verbose) {
|
|
123
|
-
process.stdout.write(stdout);
|
|
124
|
-
}
|
|
125
|
-
if (err) {
|
|
126
|
-
process.stderr.write(stderr + "\n");
|
|
127
|
-
process.exit(1);
|
|
128
|
-
}
|
|
129
|
-
resolve();
|
|
130
|
-
});
|
|
131
|
-
});
|
|
132
|
-
};
|
|
133
|
-
if (config.buildOptions.parallel) {
|
|
134
|
-
console.log(chalk.dim("Building sources in parallel..."));
|
|
135
|
-
const start = performance.now();
|
|
136
|
-
let builders = [];
|
|
137
|
-
for (const command of buildCommands) {
|
|
138
|
-
builders.push(build(command));
|
|
81
|
+
if (config.buildOptions.args.length &&
|
|
82
|
+
config.buildOptions.args.find((v) => v.length > 0)) {
|
|
83
|
+
buildArgs += " " + config.buildOptions.args.join(" ");
|
|
139
84
|
}
|
|
140
|
-
|
|
141
|
-
console.log(
|
|
142
|
-
chalk.dim("Compiled in " + formatTime(performance.now() - start)) + "\n",
|
|
143
|
-
);
|
|
144
|
-
}
|
|
85
|
+
return buildArgs;
|
|
145
86
|
}
|
package/bin/index.js
CHANGED
|
@@ -7,38 +7,51 @@ const _args = process.argv.slice(2);
|
|
|
7
7
|
const flags = [];
|
|
8
8
|
const args = [];
|
|
9
9
|
const COMMANDS = ["run", "build", "test", "init"];
|
|
10
|
-
const version = "0.
|
|
10
|
+
const version = "0.3.0";
|
|
11
11
|
for (const arg of _args) {
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
if (arg.startsWith("-"))
|
|
13
|
+
flags.push(arg);
|
|
14
|
+
else
|
|
15
|
+
args.push(arg);
|
|
14
16
|
}
|
|
15
17
|
if (!args.length) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
18
|
+
if (flags.includes("--version") || flags.includes("-v")) {
|
|
19
|
+
console.log("as-test v" + version.toString());
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
info();
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
else if (COMMANDS.includes(args[0])) {
|
|
26
|
+
const command = args.shift();
|
|
27
|
+
if (command === "build") {
|
|
28
|
+
build();
|
|
29
|
+
}
|
|
30
|
+
else if (command === "run") {
|
|
31
|
+
run();
|
|
32
|
+
}
|
|
33
|
+
else if (command === "test") {
|
|
34
|
+
build().then(() => {
|
|
35
|
+
run();
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
else if (command === "init") {
|
|
39
|
+
init(args);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
console.log(chalk.bgRed(" ERROR ") +
|
|
44
|
+
chalk.dim(":") +
|
|
45
|
+
" " +
|
|
46
|
+
chalk.bold("Unknown command: ") +
|
|
47
|
+
args[0]);
|
|
48
|
+
}
|
|
49
|
+
function info() {
|
|
50
|
+
console.log(chalk.bold.blueBright("as-test") +
|
|
36
51
|
" is a testing framework for AssemblyScript. " +
|
|
37
52
|
chalk.dim("(v" + version + ")") +
|
|
38
|
-
"\n"
|
|
39
|
-
)
|
|
40
|
-
console.log(
|
|
41
|
-
chalk.bold("Usage: as-test") +
|
|
53
|
+
"\n");
|
|
54
|
+
console.log(chalk.bold("Usage: as-test") +
|
|
42
55
|
" " +
|
|
43
56
|
chalk.dim("<command>") +
|
|
44
57
|
" " +
|
|
@@ -47,142 +60,87 @@ not ok 2 should be strictly equal
|
|
|
47
60
|
chalk.bold("[...args]") +
|
|
48
61
|
" " +
|
|
49
62
|
chalk.dim("(alias: ast)") +
|
|
50
|
-
"\n"
|
|
51
|
-
);
|
|
63
|
+
"\n");
|
|
52
64
|
console.log(chalk.bold("Commands:"));
|
|
53
|
-
console.log(
|
|
54
|
-
" " +
|
|
65
|
+
console.log(" " +
|
|
55
66
|
chalk.bold.blueBright("run") +
|
|
56
67
|
" " +
|
|
57
68
|
chalk.dim("<my-test.spec.ts>") +
|
|
58
69
|
" " +
|
|
59
|
-
"Run unit tests with selected runtime"
|
|
60
|
-
|
|
61
|
-
console.log(
|
|
62
|
-
" " +
|
|
70
|
+
"Run unit tests with selected runtime");
|
|
71
|
+
console.log(" " +
|
|
63
72
|
chalk.bold.blueBright("build") +
|
|
64
73
|
" " +
|
|
65
74
|
chalk.dim("<my-test.spec.ts>") +
|
|
66
75
|
" " +
|
|
67
|
-
"Build unit tests and compile"
|
|
68
|
-
|
|
69
|
-
console.log(
|
|
70
|
-
" " +
|
|
76
|
+
"Build unit tests and compile");
|
|
77
|
+
console.log(" " +
|
|
71
78
|
chalk.bold.blueBright("test") +
|
|
72
79
|
" " +
|
|
73
80
|
chalk.dim("<my-test.spec.ts>") +
|
|
74
81
|
" " +
|
|
75
82
|
"Build and run unit tests with selected runtime" +
|
|
76
|
-
"\n"
|
|
77
|
-
|
|
78
|
-
console.log(
|
|
79
|
-
" " +
|
|
83
|
+
"\n");
|
|
84
|
+
console.log(" " +
|
|
80
85
|
chalk.bold.magentaBright("init") +
|
|
81
86
|
" " +
|
|
82
87
|
chalk.strikethrough.dim("") +
|
|
83
88
|
" " +
|
|
84
|
-
"Initialize an empty testing template"
|
|
85
|
-
|
|
86
|
-
console.log(
|
|
87
|
-
" " +
|
|
89
|
+
"Initialize an empty testing template");
|
|
90
|
+
console.log(" " +
|
|
88
91
|
chalk.strikethrough.bold.magentaBright("config") +
|
|
89
92
|
" " +
|
|
90
93
|
chalk.strikethrough.dim("as-test.config.json") +
|
|
91
94
|
" " +
|
|
92
|
-
"Specify the configuration file"
|
|
93
|
-
|
|
94
|
-
console.log(
|
|
95
|
-
" " +
|
|
95
|
+
"Specify the configuration file");
|
|
96
|
+
console.log(" " +
|
|
96
97
|
chalk.strikethrough.bold.magentaBright("reporter") +
|
|
97
98
|
" " +
|
|
98
99
|
chalk.strikethrough.dim("<tap>") +
|
|
99
100
|
" " +
|
|
100
|
-
"Specify the test reporter to use"
|
|
101
|
-
|
|
102
|
-
console.log(
|
|
103
|
-
" " +
|
|
101
|
+
"Specify the test reporter to use");
|
|
102
|
+
console.log(" " +
|
|
104
103
|
chalk.strikethrough.bold.magentaBright("use") +
|
|
105
104
|
" " +
|
|
106
105
|
chalk.strikethrough.dim("wasmtime") +
|
|
107
106
|
" " +
|
|
108
107
|
"Specify the runtime to use" +
|
|
109
|
-
"\n"
|
|
110
|
-
);
|
|
108
|
+
"\n");
|
|
111
109
|
console.log(chalk.bold("Flags:"));
|
|
112
|
-
console.log(
|
|
113
|
-
" " +
|
|
110
|
+
console.log(" " +
|
|
114
111
|
chalk.strikethrough.dim("run") +
|
|
115
112
|
" " +
|
|
116
113
|
chalk.strikethrough.bold.blue("--coverage") +
|
|
117
114
|
" " +
|
|
118
|
-
"Use code coverage"
|
|
119
|
-
|
|
120
|
-
console.log(
|
|
121
|
-
" " +
|
|
115
|
+
"Use code coverage");
|
|
116
|
+
console.log(" " +
|
|
122
117
|
chalk.strikethrough.dim("run") +
|
|
123
118
|
" " +
|
|
124
119
|
chalk.strikethrough.bold.blue("--snapshot") +
|
|
125
120
|
" " +
|
|
126
|
-
"Take a snapshot of the tests"
|
|
127
|
-
|
|
128
|
-
console.log(
|
|
129
|
-
" " +
|
|
121
|
+
"Take a snapshot of the tests");
|
|
122
|
+
console.log(" " +
|
|
130
123
|
chalk.strikethrough.dim("use") +
|
|
131
124
|
" " +
|
|
132
125
|
chalk.strikethrough.bold.blue("--list") +
|
|
133
126
|
" " +
|
|
134
|
-
"List supported runtimes"
|
|
135
|
-
|
|
136
|
-
console.log(
|
|
137
|
-
" " +
|
|
127
|
+
"List supported runtimes");
|
|
128
|
+
console.log(" " +
|
|
138
129
|
chalk.strikethrough.dim("reporter") +
|
|
139
130
|
" " +
|
|
140
131
|
chalk.strikethrough.bold.blue("--list") +
|
|
141
132
|
" " +
|
|
142
|
-
"List supported reporters"
|
|
143
|
-
|
|
144
|
-
console.log(
|
|
145
|
-
" " +
|
|
133
|
+
"List supported reporters");
|
|
134
|
+
console.log(" " +
|
|
146
135
|
chalk.strikethrough.dim("<command>") +
|
|
147
136
|
" " +
|
|
148
137
|
chalk.strikethrough.bold.blue("--help") +
|
|
149
138
|
" " +
|
|
150
139
|
"Print info about command" +
|
|
151
|
-
"\n"
|
|
152
|
-
);
|
|
153
|
-
console.log(
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
);
|
|
158
|
-
console.log(
|
|
159
|
-
"View the repo: " +
|
|
160
|
-
chalk.magenta("https://github.com/JairusSW/as-test"),
|
|
161
|
-
);
|
|
162
|
-
console.log(
|
|
163
|
-
"View the docs: " +
|
|
164
|
-
chalk.strikethrough.blue("https://docs.jairus.dev/as-test"),
|
|
165
|
-
);
|
|
166
|
-
}
|
|
167
|
-
} else if (COMMANDS.includes(args[0])) {
|
|
168
|
-
const command = args.shift();
|
|
169
|
-
if (command === "build") {
|
|
170
|
-
build(args);
|
|
171
|
-
} else if (command === "run") {
|
|
172
|
-
run();
|
|
173
|
-
} else if (command === "test") {
|
|
174
|
-
build(args).then(() => {
|
|
175
|
-
run();
|
|
176
|
-
});
|
|
177
|
-
} else if (command === "init") {
|
|
178
|
-
init(args);
|
|
179
|
-
}
|
|
180
|
-
} else {
|
|
181
|
-
console.log(
|
|
182
|
-
chalk.bgRed(" ERROR ") +
|
|
183
|
-
chalk.dim(":") +
|
|
184
|
-
" " +
|
|
185
|
-
chalk.bold("Unknown command: ") +
|
|
186
|
-
args[0],
|
|
187
|
-
);
|
|
140
|
+
"\n");
|
|
141
|
+
console.log(chalk.dim("If your using this, consider dropping a star, it would help a lot!") + "\n");
|
|
142
|
+
console.log("View the repo: " +
|
|
143
|
+
chalk.magenta("https://github.com/JairusSW/as-test"));
|
|
144
|
+
console.log("View the docs: " +
|
|
145
|
+
chalk.strikethrough.blue("https://docs.jairus.dev/as-test"));
|
|
188
146
|
}
|