Skip to content

Commit

Permalink
release: v0.3.4
Browse files Browse the repository at this point in the history
  • Loading branch information
JairusSW committed Aug 12, 2024
1 parent 4bb8505 commit e8c1981
Show file tree
Hide file tree
Showing 14 changed files with 26 additions and 34 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ v0.2.1 - Remove accidental logging
v0.3.0 - Pass metadata through terminal - Support for multiple files - Better reporting - Timing for suites - Terminal utilities
v0.3.1 - Add screenshot of completed tests to readme
v0.3.2 - Add `mockImport` to override imported functions
v0.3.3 - Allow `mockImport`'s return type to be any
v0.3.3 - Allow `mockImport`'s return type to be any
v0.3.4 - Fix: import functions were not received after visitSource()
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
| _ || __| ___|_ _|| __|| __||_ _|
| ||__ ||___| | | | __||__ | | |
|__|__||_____| |_| |_____||_____| |_|
v0.3.3
v0.3.4
</pre>
</h5>

Expand Down
2 changes: 1 addition & 1 deletion bin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const _args = process.argv.slice(2);
const flags = [];
const args = [];
const COMMANDS = ["run", "build", "test", "init"];
const version = "0.3.3";
const version = "0.3.4";
for (const arg of _args) {
if (arg.startsWith("-")) flags.push(arg);
else args.push(arg);
Expand Down
5 changes: 2 additions & 3 deletions bin/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export async function init(args) {
input: process.stdin,
output: process.stdout,
});
console.log(chalk.bold("as-test init v0.3.3") + "\n");
console.log(chalk.bold("as-test init v0.3.4") + "\n");
console.log(chalk.dim("[1/3]") + " select a target [wasi/bindings]");
const target = await ask(chalk.dim(" -> "), rl);
if (!TARGETS.includes(target)) {
Expand Down Expand Up @@ -174,7 +174,6 @@ const exports = instantiate(module, {});`,
existsSync(PKG_PATH) ? readFileSync(PKG_PATH).toString() : "{}",
);
if (!pkg["scripts"]) pkg["scripts"] = {};
if (pkg.scripts["test"]) process.exit(0);
if (!pkg.scripts["pretest"]) {
pkg.scripts["pretest"] = "as-test build";
pkg.scripts["test"] = "as-test run";
Expand All @@ -183,7 +182,7 @@ const exports = instantiate(module, {});`,
}
if (!pkg["devDependencies"]) pkg["devDependencies"] = {};
if (!pkg["devDependencies"]["as-test"])
pkg["devDependencies"]["as-test"] = "^0.3.3";
pkg["devDependencies"]["as-test"] = "^0.3.4";
if (target == "bindings") {
pkg["type"] = "module";
}
Expand Down
2 changes: 1 addition & 1 deletion bin/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export async function run() {
chalk.bold.blueBright(`|__|__||_____| |_| |_____||_____| |_| `),
);
console.log(
chalk.dim("\n------------------- v0.3.3 -------------------\n"),
chalk.dim("\n------------------- v0.3.4 -------------------\n"),
);
}
for (const plugin of Object.keys(config.plugins)) {
Expand Down
2 changes: 1 addition & 1 deletion cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const args: string[] = [];

const COMMANDS: string[] = ["run", "build", "test", "init"];

const version = "0.3.3";
const version = "0.3.4";

for (const arg of _args) {
if (arg.startsWith("-")) flags.push(arg);
Expand Down
4 changes: 2 additions & 2 deletions cli/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export async function init(args: string[]) {
input: process.stdin,
output: process.stdout,
});
console.log(chalk.bold("as-test init v0.3.3") + "\n");
console.log(chalk.bold("as-test init v0.3.4") + "\n");
console.log(chalk.dim("[1/3]") + " select a target [wasi/bindings]");
const target = await ask(chalk.dim(" -> "), rl);
if (!TARGETS.includes(target)) {
Expand Down Expand Up @@ -192,7 +192,7 @@ const exports = instantiate(module, {});`,
}
if (!pkg["devDependencies"]) pkg["devDependencies"] = {};
if (!pkg["devDependencies"]["as-test"])
pkg["devDependencies"]["as-test"] = "^0.3.3";
pkg["devDependencies"]["as-test"] = "^0.3.4";
if (target == "bindings") {
pkg["type"] = "module";
}
Expand Down
2 changes: 1 addition & 1 deletion cli/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export async function run() {
chalk.bold.blueBright(`|__|__||_____| |_| |_____||_____| |_| `),
);
console.log(
chalk.dim("\n------------------- v0.3.3 -------------------\n"),
chalk.dim("\n------------------- v0.3.4 -------------------\n"),
);
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "as-test",
"version": "0.3.3",
"version": "0.3.4",
"description": "Testing framework for AssemblyScript. Compatible with WASI or Bindings ",
"types": "assembly/index.ts",
"author": "Jairus Tanaka",
Expand Down
2 changes: 1 addition & 1 deletion run/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@as-test/run",
"version": "0.3.3",
"version": "0.3.4",
"description": "Testing framework for AssemblyScript. Compatible with WASI or Bindings ",
"main": "./lib/index.js",
"author": "Jairus Tanaka",
Expand Down
15 changes: 6 additions & 9 deletions transform/lib/mock.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion transform/lib/mock.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion transform/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@as-test/transform",
"version": "0.3.3",
"version": "0.3.4",
"description": "Testing framework for AssemblyScript. Compatible with WASI or Bindings ",
"main": "./lib/index.js",
"author": "Jairus Tanaka",
Expand Down
15 changes: 5 additions & 10 deletions transform/src/mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export class MockTransform extends BaseVisitor {

if (name == "mockImport") {
this.importMocked.add((node.args[0] as StringLiteralExpression).value);
return;
}
if (name != "mockFn") return;
const ov = toString(node.args[0]);
Expand Down Expand Up @@ -77,21 +78,19 @@ export class MockTransform extends BaseVisitor {
super.visitFunctionDeclaration(node, isDefault);
}
visitSource(node: Source): void {
if (node.isLibrary || isStdlib(node)) {
if (!node.normalizedPath.startsWith("~lib/as-test")) {
return;
}
}
this.mocked = new Set<string>();
this.currentSource = node;
this.importFns = [];
super.visitSource(node);

for (const node of this.importFns) {
let path = "";
const dec = node.decorators?.find(
(v) => (v.name as IdentifierExpression).text == "external",
);
if (dec.args[0] && dec.args[1])
if (!dec) {
path = "env." + node.name.text;
} else if (dec.args[0] && dec.args[1])
path = dec.args
.map((v) => (v as StringLiteralExpression).value)
.join(".");
Expand All @@ -101,7 +100,6 @@ export class MockTransform extends BaseVisitor {
"." +
(dec.args[0] as StringLiteralExpression).value;
else path = this.currentSource.simplePath + "." + node.name.text;

if (!this.importMocked.has(path)) return;

let args: Expression[] = [
Expand Down Expand Up @@ -147,8 +145,6 @@ export class MockTransform extends BaseVisitor {
node.range,
);

newFn.signature = node.signature;

const stmts = this.currentSource.statements;
let index = -1;
for (let i = 0; i < stmts.length; i++) {
Expand All @@ -164,6 +160,5 @@ export class MockTransform extends BaseVisitor {
if (index === -1) return;
stmts.splice(index, 1, newFn);
}
this.importFns = [];
}
}

0 comments on commit e8c1981

Please sign in to comment.