Skip to content

Commit 54f1ea8

Browse files
committed
cost-tracking: add testing infrastructure
In this commit we add the infrastructure necessary to test the runtime's cost tracking. We take advantage of the tests that already exist to check the interpreter and the runtime match in the results that they produce, and add an assertion that the tracked costs should also be equivalent. To trigger the cost tracking tests, a new feature `test-cost-tracking` is added. By default cost tracking checks are *not* included, to preserve current behavior. We also add the tests to the CI infrastructure, by adding a new matrix field controlling if we test with cost tracking or not. Resolves: #636
1 parent a01af9f commit 54f1ea8

File tree

10 files changed

+458
-134
lines changed

10 files changed

+458
-134
lines changed

.github/workflows/ci.yaml

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ jobs:
5252
strategy:
5353
matrix:
5454
clarity_version: [1, 2, 3]
55-
name: Clarity::V${{ matrix.clarity_version }} Artifacts
55+
cost_tracking: [false, true]
56+
57+
name: Clarity::V${{ matrix.clarity_version }} Artifacts${{ matrix.cost_tracking && ' (cost-tracking)' || ''}}
5658
steps:
5759
- name: Checkout PR
5860
uses: actions/checkout@v4
@@ -69,21 +71,22 @@ jobs:
6971
- name: Create archive of test binaries
7072
run: |
7173
cargo llvm-cov nextest-archive \
72-
--features test-clarity-v${{ matrix.clarity_version }} \
74+
--features test-clarity-v${{ matrix.clarity_version }}\
75+
${{ matrix.cost_tracking && ',test-cost-tracking' || ''}} \
7376
--workspace \
74-
--archive-file nextest-archive-v${{ matrix.clarity_version }}.tar.zst
77+
--archive-file nextest-archive-v${{ matrix.clarity_version }}-${{ matrix.cost_tracking }}.tar.zst
7578
7679
- name: Upload test binaries
7780
uses: actions/upload-artifact@v4
7881
with:
79-
name: nextest-archive-v${{ matrix.clarity_version }}
80-
path: nextest-archive-v${{ matrix.clarity_version }}.tar.zst
82+
name: nextest-archive-v${{ matrix.clarity_version }}-${{ matrix.cost_tracking }}
83+
path: nextest-archive-v${{ matrix.clarity_version }}-${{ matrix.cost_tracking }}.tar.zst
8184
if-no-files-found: error
8285

8386
- name: Upload standard.wasm file
8487
uses: actions/upload-artifact@v4
8588
with:
86-
name: standard-v${{ matrix.clarity_version }}.wasm
89+
name: standard-v${{ matrix.clarity_version }}-${{ matrix.cost_tracking }}.wasm
8790
path: ${{github.workspace}}/clar2wasm/src/standard/standard.wasm
8891
if-no-files-found: error
8992

@@ -96,7 +99,8 @@ jobs:
9699
fail-fast: false
97100
matrix:
98101
clarity_version: [1, 2, 3]
99-
name: Clarity::V${{ matrix.clarity_version }} Tests
102+
cost_tracking: [false, true]
103+
name: Clarity::V${{ matrix.clarity_version }} Tests${{ matrix.cost_tracking && ' (cost-tracking)' || ''}}
100104
steps:
101105
- name: Checkout PR
102106
uses: actions/checkout@v4
@@ -113,27 +117,27 @@ jobs:
113117
- name: Download standard.wasm file
114118
uses: actions/download-artifact@v4
115119
with:
116-
name: standard-v${{ matrix.clarity_version }}.wasm
120+
name: standard-v${{ matrix.clarity_version }}-${{ matrix.cost_tracking }}.wasm
117121
path: ${{github.workspace}}/clar2wasm/src/standard/
118122

119123
- name: Download archive
120124
uses: actions/download-artifact@v4
121125
with:
122-
name: nextest-archive-v${{ matrix.clarity_version }}
126+
name: nextest-archive-v${{ matrix.clarity_version }}-${{ matrix.cost_tracking }}
123127

124128
- name: Run tests and output coverage
125129
shell: bash
126130
run: |
127131
cargo llvm-cov nextest \
128-
--archive-file nextest-archive-v${{ matrix.clarity_version }}.tar.zst \
132+
--archive-file nextest-archive-v${{ matrix.clarity_version }}-${{ matrix.cost_tracking }}.tar.zst \
129133
--codecov \
130-
--output-path codecov-v${{ matrix.clarity_version }}.json
134+
--output-path codecov-v${{ matrix.clarity_version }}-${{ matrix.cost_tracking }}.json
131135
132136
- name: Upload codecov.json
133137
uses: actions/upload-artifact@v4
134138
with:
135-
name: code-coverage-v${{ matrix.clarity_version }}
136-
path: codecov-v${{ matrix.clarity_version }}.json
139+
name: code-coverage-v${{ matrix.clarity_version }}-${{ matrix.cost_tracking }}
140+
path: codecov-v${{ matrix.clarity_version }}-${{ matrix.cost_tracking }}.json
137141
if-no-files-found: error
138142

139143
# Code coverage

clar2wasm/Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,17 @@ wat = "1.0.74"
2323
[features]
2424
flamegraph = []
2525
pb = []
26+
2627
# Test-specific features
28+
29+
# Clarity version to test - default v2
2730
test-clarity-v1 = []
2831
test-clarity-v2 = []
2932
test-clarity-v3 = []
3033

34+
# Whether to test cost tracking code
35+
test-cost-tracking = []
36+
3137
[dev-dependencies]
3238
criterion = "0.5"
3339
proptest = "1.2.0"

0 commit comments

Comments
 (0)