Skip to content

Commit

Permalink
fix: bring back compute coverage options (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
djm07073 authored Dec 6, 2024
1 parent 2f690dd commit f0a56d8
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 10 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,6 @@ jobs:
- run: npm install
- run: npm run build
- run: npm run test
- run: npm run test-test
- run: npm run lint

3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,7 @@ node_modules/

dist/
build/
# generated file by movevm
.trace
.coverage_map.mvcov
doc/
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,5 +123,6 @@ export interface TestOptions {
reportStatistics?: boolean
reportStorageOnError?: boolean
ignoreCompileWarnings?: boolean
computeCoverage?: boolean
}
```
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@initia/builder.js",
"version": "0.2.6",
"version": "0.2.7",
"description": "The JavaScript Move Builder for Initia",
"license": "MIT",
"author": "Initia Foundation",
Expand Down Expand Up @@ -29,7 +29,8 @@
"scripts": {
"lint": "npx eslint . --fix",
"build": "tsc --build",
"test": "jest --no-cache",
"test": "jest --no-cache --testPathIgnorePatterns test.spec.ts",
"test-test": "jest test.spec.ts",
"prepare": "husky install"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion src/builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ export class MoveBuilder {
report_statistics: options?.reportStatistics || false,
report_storage_on_error: options?.reportStorageOnError || false,
ignore_compile_warnings: options?.ignoreCompileWarnings || false,
compute_coverage: false,
compute_coverage: options?.computeCoverage || false,
})
.toBytes()
)
Expand Down
5 changes: 5 additions & 0 deletions src/types/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,9 @@ export interface TestOptions {
* Ignore compiler's warning, and continue run tests.(default false)
*/
ignoreCompileWarnings?: boolean

/**
* Collect coverage information for later use with the various `move coverage` subcommands
*/
computeCoverage?: boolean
}
15 changes: 8 additions & 7 deletions test/test.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,21 @@ describe('test move package', () => {
const contractDir = path.resolve(__dirname, 'contract/simple')
const builder = new MoveBuilder(contractDir, {})

it('executes tests successfully', async () => {
const testResult = await builder.test({
filter: 'test_simple',
})
expect(testResult).toEqual('ok')
}, 100000000)

it('executes tests with options', async () => {
const testResult = await builder.test({
filter: 'test_simple2',
reportStatistics: true,
reportStorageOnError: true,
ignoreCompileWarnings: true,
computeCoverage: true,
})
expect(testResult).toEqual('ok')
await builder.clean({})
}, 100000000)

it('executes tests without options', async () => {
const testResult = await builder.test({})
expect(testResult).toEqual('ok')
await builder.clean({})
}, 100000000)
})

0 comments on commit f0a56d8

Please sign in to comment.