// The catalogue matches spec §69 exactly, in order, as TestCatalogueMatchesSpec // of datekeys-go. The spec is read from the Go repository next to this one, at // the tag of the version of the spec that this package implements, so that // uncommitted changes there never count. @TestOn('vm') library; import 'dart:convert'; import 'dart:io'; import 'package:datekeys/datekeys.dart'; import 'package:test/test.dart'; void main() { final repo = Directory('../datekeys-go'); test( 'the catalogue is the list of ERR_ lines of spec §69, in order', () { final path = 'spec-v$specVersion:spec/DateKeys_Protocol_Specification_v$specVersion.md'; final r = Process.runSync( 'git', ['-C', repo.path, 'show', path], stdoutEncoding: utf8, stderrEncoding: utf8, ); expect(r.exitCode, 0, reason: '${r.stderr}'); final spec = r.stdout as String; final start = spec.indexOf('## 69. Errores normativos'); final end = spec.indexOf('## 70.'); expect(start, isNonNegative, reason: 'section 69 not found'); expect(end, greaterThan(start), reason: 'section 70 not found'); final want = [ for (final line in spec.substring(start, end).split('\n')) if (line.trim().startsWith('ERR_')) line.trim(), ]; expect(want, isNotEmpty); expect([for (final c in ErrorCode.values) c.code], want); }, skip: repo.existsSync() ? false : '../datekeys-go is missing: the spec is read from it', ); }