From 9522d1acab9e4b9deefbff7fbb3e63f839ab1ffd Mon Sep 17 00:00:00 2001 From: Terastar-Paperclip <279373186+Terastar-Paperclip@users.noreply.github.com> Date: Mon, 18 May 2026 23:07:25 -0400 Subject: [PATCH] =?UTF-8?q?feat(compat):=20wire=20compat/formats=20=C2=A74?= =?UTF-8?q?=20attestation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds TestContractFormats sibling to the existing TestContractDates, running formats.RunContract against the same five data-producing subcommands. Bumps github.com/quantcli/common/compat to the version that includes the formats bundle (QUA-15) and the SkipDataPath / SupportedFormats affordances (QUA-21, QUA-28). - SupportedFormats: ["markdown","json"] declares the codec subset crono actually implements; CSVHasHeader skips with a named reason rather than failing. - SkipDataPath: true opts out of the JSONIsArray/CSVHasHeader/ DefaultIsMarkdown data-path subtests because crono's data path requires CRONOMETER_USERNAME/PASSWORD which the compat CI job does not provide. Parse-level subtests (HelpDocumentsFormatFlag, UnknownFormatFails, FlagValidationIsHermetic) still attest the §4 surface. - CI compat job's -run filter expands to TestContract(Dates|Formats). Reuses the existing compat job; no new workflow. Verified locally (CRONO_EXPORT_BIN=/tmp/crono-export): TestContractDates 20/20 PASS (5 subcommands × 4 subtests) TestContractFormats 15 PASS / 15 SKIP (5 × {3 parse PASS + 3 data-path SKIP}) Refs: QUA-19. Co-Authored-By: Paperclip --- .github/workflows/ci.yml | 2 +- compat_contract_test.go | 48 +++++++++++++++++++++++++++++++++------- go.mod | 2 +- go.sum | 4 ++-- 4 files changed, 44 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 988724a..38150ad 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -44,4 +44,4 @@ jobs: env: # Path the compat-tagged test reads from os.Getenv. CRONO_EXPORT_BIN: /tmp/crono-export - run: go test -tags=compat -run TestContractDates ./... + run: go test -tags=compat -run 'TestContract(Dates|Formats)' ./... diff --git a/compat_contract_test.go b/compat_contract_test.go index 904afe1..076fed0 100644 --- a/compat_contract_test.go +++ b/compat_contract_test.go @@ -17,8 +17,21 @@ import ( "github.com/quantcli/common/compat" "github.com/quantcli/common/compat/dates" + "github.com/quantcli/common/compat/formats" ) +// cronoSubcommands is the §3/§4 surface for crono — each subcommand +// owns its own --since/--until and --format flags. Shared between the +// dates and formats bundles so a single source-of-truth list keeps +// the two suites in sync. +var cronoSubcommands = []string{ + "biometrics", + "exercises", + "nutrition", + "servings", + "notes", +} + func TestContractDates(t *testing.T) { bin := os.Getenv("CRONO_EXPORT_BIN") if bin == "" { @@ -29,13 +42,32 @@ func TestContractDates(t *testing.T) { // subcommand under a `subcommand=NAME/...` subtree so any single // regression surfaces as a named subtest failure. dates.RunContract(t, compat.Runner{ - Binary: bin, - Subcommands: []string{ - "biometrics", - "exercises", - "nutrition", - "servings", - "notes", - }, + Binary: bin, + Subcommands: cronoSubcommands, + }) +} + +func TestContractFormats(t *testing.T) { + bin := os.Getenv("CRONO_EXPORT_BIN") + if bin == "" { + t.Skip("CRONO_EXPORT_BIN not set; skipping compat suite") + } + // crono implements --format markdown (default) and --format json + // today; CSV is not yet wired (see cmd/format.go chosenFormat). + // SupportedFormats: ["markdown","json"] skips CSVHasHeader with a + // named reason rather than failing it. + // + // SkipDataPath: true opts out of JSONIsArray / CSVHasHeader / + // DefaultIsMarkdown — crono's data path requires + // CRONOMETER_USERNAME/PASSWORD which the compat CI job does not + // provide, so the data-path subtests would fail at "not logged in" + // before the codec assertions could run. The parse-level subtests + // (HelpDocumentsFormatFlag, UnknownFormatFails, + // FlagValidationIsHermetic) still attest the §4 surface. + formats.RunContract(t, compat.Runner{ + Binary: bin, + Subcommands: cronoSubcommands, + SupportedFormats: []string{"markdown", "json"}, + SkipDataPath: true, }) } diff --git a/go.mod b/go.mod index a2fd26b..e3457bc 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/quantcli/crono-export-cli go 1.25.10 require ( - github.com/quantcli/common/compat v0.0.0-20260510225630-4c588c19cd1b + github.com/quantcli/common/compat v0.0.0-20260511224412-1cf4a39648c5 github.com/spf13/cobra v1.10.2 ) diff --git a/go.sum b/go.sum index 3753e29..f8a38fd 100644 --- a/go.sum +++ b/go.sum @@ -1,8 +1,8 @@ github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= -github.com/quantcli/common/compat v0.0.0-20260510225630-4c588c19cd1b h1:fO7EfkEqzLRC8Ev22jIq05fPs+JwAB7bCDy6FA+GA5k= -github.com/quantcli/common/compat v0.0.0-20260510225630-4c588c19cd1b/go.mod h1:VBC/zEphSZgCZS1rhWsR3A8EWYSbTkP/MwqWHL7266s= +github.com/quantcli/common/compat v0.0.0-20260511224412-1cf4a39648c5 h1:UW6c2rz3bbk2Ju0lGv+QqmuU7+SkIQMFkBJPSr+LDGc= +github.com/quantcli/common/compat v0.0.0-20260511224412-1cf4a39648c5/go.mod h1:VBC/zEphSZgCZS1rhWsR3A8EWYSbTkP/MwqWHL7266s= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/spf13/cobra v1.10.2 h1:DMTTonx5m65Ic0GOoRY2c16WCbHxOOw6xxezuLaBpcU= github.com/spf13/cobra v1.10.2/go.mod h1:7C1pvHqHw5A4vrJfjNwvOdzYu0Gml16OCs2GRiTUUS4=