Skip to content

Commit

Permalink
test: test.failing only for off-spec
Browse files Browse the repository at this point in the history
  • Loading branch information
turadg committed Jan 24, 2025
1 parent c584c2c commit 6fbb689
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 12 deletions.
17 changes: 14 additions & 3 deletions packages/SwingSet/test/vo-test-harness/dvo-test-harness.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { makeSpy } from '@agoric/swingset-liveslots/tools/vo-test-harness.js';
import { test, runDVOTest } from '../../tools/dvo-test-harness.js';

function bfile(name) {
Expand All @@ -6,17 +7,27 @@ function bfile(name) {

async function dvoTestTest(t, mode) {
function testLogCheck(_t, phase, log) {
t.deepEqual(log, ['start test', phase, 'test thing', { mode }, 'end test']);
t.deepEqual(log, [
'start test',
phase,
`fail during "${phase}"`,
{ mode },
'end test',
]);
}
await runDVOTest(t, testLogCheck, bfile('vat-dvo-test-test.js'), { mode });
}

test.failing('fail during "before" phase', async t => {
test('fail during "before" phase', async t => {
const tSpy = makeSpy(t);
await dvoTestTest(t, 'before');
t.is(tSpy.failureMessage, 'fail during "before"');
});

test.failing('fail during "after" phase', async t => {
test('fail during "after" phase', async t => {
const tSpy = makeSpy(t);
await dvoTestTest(t, 'after');
t.is(tSpy.failureMessage, 'fail during "after"');
});

test('succeed', async t => {
Expand Down
22 changes: 13 additions & 9 deletions packages/swingset-liveslots/test/vo-test-harness.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import test from 'ava';
import { runVOTest } from '../tools/vo-test-harness.js';
import { makeSpy, runVOTest } from '../tools/vo-test-harness.js';

async function voTestTest(t, mode) {
let makeThing;
Expand Down Expand Up @@ -36,8 +36,6 @@ async function voTestTest(t, mode) {
await runVOTest(t, prepare, makeTestThing, testTestThing);
}

// Note: these first two are not marked "test.failing" because
// something is wrong and we need to fix it. Rather, they are
// confirming that the voTestTest harness would catch problems during
// downstream tests that use the harness, if those problems arose in
// the "before" or "after" phases, and reported by the downstream test
Expand All @@ -47,20 +45,26 @@ async function voTestTest(t, mode) {
// fails, otherwise the harness is not doing its job, and is hiding
// real test failures in some downstream client package.

test.failing('fail during "before" phase', async t => {
await voTestTest(t, 'before');
test('fail during "before" phase', async t => {
const tSpy = makeSpy(t);
await voTestTest(tSpy, 'before');
t.is(tSpy.failureMessage, 'deliberate failure in before phase');
});

test.failing('fail during "after" phase', async t => {
await voTestTest(t, 'after');
test('fail during "after" phase', async t => {
const tSpy = makeSpy(t);
await voTestTest(tSpy, 'after');
t.is(tSpy.failureMessage, 'deliberate failure in after phase');
});

// Similarly, this test makes sure that our harness can detect when
// the downstream test misbehaves and holds on to the object they were
// supposed to drop.

test.failing('fail due to held object', async t => {
await voTestTest(t, 'hold');
test('fail due to held object', async t => {
const tSpy = makeSpy(t);
await voTestTest(tSpy, 'hold');
t.is(tSpy.falsyMessage, 'somebody continues to hold test object');
});

test.serial('succeed', async t => {
Expand Down

0 comments on commit 6fbb689

Please sign in to comment.