[RFC]: Migrate from tape to in-house @stdlib/test/harness

Aperta
#10,365 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
20/100
Tipo di issue
Refactoring
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
javascript, node.js

Direzione di ricerca

Inizia leggendo il @stdlib/test/harness proposto insieme ai pattern esistenti di @stdlib/bench/harness, quindi esamina i file di test di lib, package.json, il Makefile di stdlib e tools/harness.js. Confronta l’attuale esecuzione dei test basata su tape e l’output TAP con l’harness proposto; il lavoro è completato quando l’ambito della migrazione, le asserzioni supportate e la validazione CI sono concordati e funzionano per tutti i test interessati.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Description

This RFC proposes

Proposal: Migrate stdlib Tests to In-House @stdlib/test/harness

This proposal delivers a tape-equivalent in-house test runner as @stdlib/test/harness, directly porting its minimal TAP API while matching @stdlib/bench/harness patterns. It eliminates the tape dep, supports only stdlib's used assertions (equal, strictEqual, ok, deepEqual, pass, fail, plan, end, test), and adds @stdlib/string/format interpolation—no parallelism, grouping, or extras like mocha/jest.

Before/After Test File

Before (tape):

'use strict';

var tape = require( 'tape' );
var foo = require( './../lib' );

tape( 'main export is a function', function test( t ) {
	t.ok( true, 'should be true' );
	t.strictEqual( typeof foo, 'function', 'main export is a function' );
	t.end();
});

tape( 'computes correctly', function test( t ) {
	t.plan( 2 );
	t.equal( foo( 3 ), 9, 'returns 9' );
	t.deepEqual( foo(  ),, 'deep equal' );[1][2][3]
	t.end();
After (@stdlib/test/harness):

After (@stdlib/test/harness):

```javascript
'use strict';

var test = require( '@stdlib/test/harness' );
var foo = require( './../lib' );

test( 'main export is a function', function test( t ) {
	t.ok( true, 'should be true' );
	t.strictEqual( typeof foo, 'function', 'main export is %s', 'function' );
	t.end();
});

test( 'computes correctly', function test( t ) {
	t.plan( 2 );
	t.equal( foo( 3 ), 9, 'returns %d', 9 );
	t.deepEqual( foo(  ),, 'deep equal' );[1][2][3]
	t.end();
});

Changes: Swap require('tape') → require('@stdlib/test/harness'). Assertions identical—no renames/refactors. Interpolation optional (%s/%d/%j via @stdlib/string/format).

Study of References

Reviewed tape source (tape-testing/tape): TAP stream via events, nested tests, async end(), assertion tracking. Compared to @stdlib/bench/harness: Similar b.bench()/test(), exports harness/stream factory, stdout TAP—no deps. Stdlib tests (e.g., Makefile/package.json scans): Use ~6 assertions max, plain TAP, no advanced tape features. Impl ports tape's core (test context, assert/incr count, TAP lines) to ~400 LOC Node streams.

Automation Strategy

  • Publish @stdlib/test/harness (bench mirror: libtests, Makefile).
  • Global replace: grep -rl "require('tape')" lib/ | xargs sed -i "s|require('tape')|require('@stdlib/test\/harness')|g" (handles escapes).
  • Glob run: Update stdlib Makefile: $(QUIET) $(NODE) $(TOOLS_DIR)/harness.js $(shell find lib -name 'test.*.js').
  • Validate: CI diff old/new TAP (tape | harness); fix interpolation mismatches via optional post-sed (regex scan t.equal/ok args).
  • Coverage: Stick with istanbul (nyc/c8 drops Node 10-12 compat).
Related Issues

[Idea]: develop a project test runner

Questions

No.

Other

No.

Checklist
  • I have read and understood the Code of Conduct.
  • Searched for existing issues and pull requests.
  • The issue name begins with RFC:.
Lingua principale
JavaScript
Stelle
6k
Fork
1.3k
Merge medio
1g 21h
PR unite (30g)
224

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di stdlib-js/stdlib

Tutte le issue di stdlib-js/stdlib

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.