forked from near/near-sdk-as
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimports.js
98 lines (93 loc) · 3.47 KB
/
imports.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
const v8 = require('v8');
v8.setFlagsFromString('--experimental-wasm-bigint');
let rust = require("near-mock-vm");
let path = require("path");
let posixRelativePath = require("./bindgen/dist/utils").posixRelativePath;
function createImports(memory, createImports, instantiateSync, binary) {
let wasm;
const runner = rust.VMRunner.create(memory);
const _imports = runner.createImports();
wasm = instantiateSync(binary, createImports(_imports));
// Save reference to the instance
runner.wasm = wasm.exports || wasm;
return wasm;
}
module.exports = {
/**
* A set of globs passed to the glob package that qualify typescript files for testing.
*/
include: ["assembly/__tests__/**/*.spec.ts"],
/**
* A set of globs passed to the glob package that quality files to be added to each test.
*/
add: ["assembly/__tests__/**/*.include.ts"],
/**
* All the compiler flags needed for this test suite. Make sure that a binary file is output.
*/
flags: {
"--debug": [],
/**
* This is required. Do not change this.
* The filename is ignored, but required by the compiler.
* */
"--binaryFile": ["output.wasm"],
/** To enable wat file output, use the following flag. The filename is ignored, but required by the compiler. */
// "--textFile": ["output.wat"],
/** To select an appropriate runtime, use the --runtime compiler flag. */
"--runtime": ["stub"], // Acceptable values are: full, half, stub (arena),
"--baseDir": process.cwd(),
"--runPasses": ["inlining,dce"],
"--config": path.join(__dirname, "asp.asconfig.json"),
// "--showConfig": []
},
/**
* A set of regexp that will disclude source files from testing.
*/
disclude: [/node_modules/],
/**
* Add your required AssemblyScript imports here.
*/
imports: createImports,
/**
* All performance statistics reporting can be configured here.
*/
performance: {
/** Enable performance statistics gathering for every test. */
enabled: false,
/** Set the maximum number of samples to run for every test. */
maxSamples: 10000,
/** Set the maximum test run time in milliseconds for every test. */
maxTestRunTime: 2000,
/** Report the median time in the default reporter for every test. */
reportMedian: true,
/** Report the average time in milliseconds for every test. */
reportAverage: true,
/** Report the standard deviation for every test. */
reportStandardDeviation: false,
/** Report the maximum run time in milliseconds for every test. */
reportMax: false,
/** Report the minimum run time in milliseconds for every test. */
reportMin: false,
},
/**
* Add a custom reporter here if you want one. The following example is in typescript.
*
* @example
* import { TestReporter, TestGroup, TestResult, TestContext } from "as-pect";
*
* export class CustomReporter extends TestReporter {
* // implement each abstract method here
* public abstract onStart(suite: TestContext): void;
* public abstract onGroupStart(group: TestGroup): void;
* public abstract onGroupFinish(group: TestGroup): void;
* public abstract onTestStart(group: TestGroup, result: TestResult): void;
* public abstract onTestFinish(group: TestGroup, result: TestResult): void;
* public abstract onFinish(suite: TestContext): void;
* }
*/
// reporter: new CustomReporter(),
/**
* Specify if the binary wasm file should be written to the file system.
*/
outputBinary: false
};