This is an automated email from the ASF dual-hosted git repository.
tisonkun pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/datasketches-tck.git
The following commit(s) were added to refs/heads/main by this push:
new 53d164a feat: migrate snapshot generators to Go (#3)
53d164a is described below
commit 53d164afcfa0019f5868310fb5e254dca8b0d523
Author: tison <[email protected]>
AuthorDate: Mon Aug 10 03:48:57 2026 +0800
feat: migrate snapshot generators to Go (#3)
Signed-off-by: tison <[email protected]>
---
.editorconfig | 3 +
.github/workflows/check.yml | 43 ++++++++
.gitignore | 4 +-
.golangci.yml | 21 ++++
.mise/tasks/check | 40 +++++++
README.md | 3 +-
cmd/tck/__snapshots__/output_test.snap | 26 +++++
cmd/tck/__snapshots__/root_test.snap | 18 ++++
cmd/tck/main.go | 32 ++++++
cmd/tck/main_test.go | 39 +++++++
cmd/tck/output.go | 141 +++++++++++++++++++++++++
cmd/tck/output_test.go | 83 +++++++++++++++
cmd/tck/root.go | 60 +++++++++++
cmd/tck/root_test.go | 48 +++++++++
cmd/tck/snapshots.go | 176 +++++++++++++++++++++++++++++++
go.mod | 50 +++++++++
go.sum | 68 ++++++++++++
internal/snapshots/cpp.go | 57 ++++++++++
internal/snapshots/diff.go | 181 ++++++++++++++++++++++++++++++++
internal/snapshots/diff_test.go | 118 +++++++++++++++++++++
internal/snapshots/files.go | 93 +++++++++++++++++
internal/snapshots/generator.go | 95 +++++++++++++++++
internal/snapshots/go.go | 39 +++++++
internal/snapshots/java.go | 86 +++++++++++++++
internal/snapshots/reconcile.go | 184 +++++++++++++++++++++++++++++++++
internal/snapshots/runner.go | 61 +++++++++++
internal/snapshots/stability.go | 102 ++++++++++++++++++
internal/snapshots/stability_test.go | 58 +++++++++++
mise.toml | 33 ++++++
pyproject.toml | 27 -----
serialization/cpp/generator.py | 101 ------------------
serialization/go/generator.py | 92 -----------------
serialization/java/generator.py | 98 ------------------
tools/tck/__init__.py | 49 ---------
uv.lock | 167 ------------------------------
35 files changed, 1957 insertions(+), 539 deletions(-)
diff --git a/.editorconfig b/.editorconfig
index 2990175..57d638a 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -23,6 +23,9 @@ indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
+[*.go]
+indent_style = tab
+
[*.toml]
indent_size = tab
tab_width = 2
diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml
new file mode 100644
index 0000000..8d81272
--- /dev/null
+++ b/.github/workflows/check.yml
@@ -0,0 +1,43 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+name: Check
+
+on:
+ pull_request:
+ branches: [main]
+ push:
+ branches: [main]
+
+permissions:
+ contents: read
+
+concurrency:
+ group: ${{ github.workflow }}-${{ github.event_name }}-${{
github.event.number || github.run_id }}
+ cancel-in-progress: true
+
+jobs:
+ required:
+ name: Required checks
+ runs-on: ubuntu-24.04
+ timeout-minutes: 10
+ steps:
+ - uses: actions/checkout@v7
+
+ - name: Setup mise
+ uses: jdx/mise-action@5228313ee0372e111a38da051671ca30fc5a96db # v3.6.3
+
+ - name: Check Go
+ run: mise run check
diff --git a/.gitignore b/.gitignore
index 493ffe3..15f4d1c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -16,9 +16,7 @@
# under the License.
# Temporary files
-tmp_datasketches_java/
-tmp_datasketches_cpp/
-tmp_datasketches_go/
+tmp_datasketches_*/
# VSCode project files
.vscode
diff --git a/.golangci.yml b/.golangci.yml
new file mode 100644
index 0000000..1999e26
--- /dev/null
+++ b/.golangci.yml
@@ -0,0 +1,21 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+version: "2"
+
+linters:
+ default: standard
+ enable:
+ - testifylint
diff --git a/.mise/tasks/check b/.mise/tasks/check
new file mode 100755
index 0000000..e03c6ce
--- /dev/null
+++ b/.mise/tasks/check
@@ -0,0 +1,40 @@
+#!/usr/bin/env bash
+#MISE description="Run Go checks"
+
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+set -euo pipefail
+
+task_directory="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
+repository_root="$(git -C "$task_directory" rev-parse --show-toplevel)"
+cd "$repository_root"
+
+unformatted="$(
+ git ls-files -z --cached --others --exclude-standard -- '*.go' |
+ while IFS= read -r -d '' file; do
+ if [[ -f "$file" ]]; then
+ gofmt -l "$file"
+ fi
+ done
+)"
+if [[ -n "$unformatted" ]]; then
+ echo "The following Go files need formatting:" >&2
+ echo "$unformatted" >&2
+ exit 1
+fi
+
+golangci-lint run
+CI=true go test ./...
diff --git a/README.md b/README.md
index 22fe05a..7ea3004 100644
--- a/README.md
+++ b/README.md
@@ -2,7 +2,7 @@
This repository provides a Technology Compatibility Kit for the DataSketches
library.
-A Technology Compatibility Kit (TCK) a suite of tests that at least nominally
checks a particular DataSketches implementation for compliance.
+A Technology Compatibility Kit (TCK) is a suite of tests that checks a
particular DataSketches implementation for compatibility.
## Overview
@@ -21,4 +21,3 @@ If you are interested in making contributions to this site,
please see our [Comm
## License
Licensed under the Apache License, Version 2.0:
http://www.apache.org/licenses/LICENSE-2.0
-
diff --git a/cmd/tck/__snapshots__/output_test.snap
b/cmd/tck/__snapshots__/output_test.snap
new file mode 100644
index 0000000..4521ec0
--- /dev/null
+++ b/cmd/tck/__snapshots__/output_test.snap
@@ -0,0 +1,26 @@
+
+[TestPrintResultAllowsOnlyUnstableModifications - 1]
+╭────────┬───────────┬───────┬──────────────────┬─────────────────────────╮
+│ CHANGE │ STABILITY │ CHECK │ SNAPSHOT │ CONTENT (SIZE · SHA256) │
+├────────┼───────────┼───────┼──────────────────┼─────────────────────────┤
+│ M │ unstable │ allow │ probabilistic.sk │ old 12 B · aaaaaaaaaaaa │
+│ │ │ │ │ new 12 B · bbbbbbbbbbbb │
+╰────────┴───────────┴───────┴──────────────────┴─────────────────────────╯
+Summary: 0 added · 1 modified (1 probabilistic) · 0 deleted
+! Snapshot set and stable contents are unchanged; 1 probabilistic content
modification is allowed.
+
+---
+
+[TestPrintResultIncludesDetailedFileChanges - 1]
+╭────────┬───────────┬───────┬─────────────┬─────────────────────────╮
+│ CHANGE │ STABILITY │ CHECK │ SNAPSHOT │ CONTENT (SIZE · SHA256) │
+├────────┼───────────┼───────┼─────────────┼─────────────────────────┤
+│ A │ stable │ block │ added.sk │ new 16 B · bbbbbbbbbbbb │
+│ M │ unstable │ allow │ modified.sk │ old 12 B · aaaaaaaaaaaa │
+│ │ │ │ │ new 16 B · bbbbbbbbbbbb │
+│ D │ stable │ block │ deleted.sk │ old 12 B · aaaaaaaaaaaa │
+╰────────┴───────────┴───────┴─────────────┴─────────────────────────╯
+Summary: 1 added · 1 modified (1 probabilistic) · 1 deleted
+✗ serialization/go/snapshots has 2 blocking changes.
+
+---
diff --git a/cmd/tck/__snapshots__/root_test.snap
b/cmd/tck/__snapshots__/root_test.snap
new file mode 100644
index 0000000..101cf9e
--- /dev/null
+++ b/cmd/tck/__snapshots__/root_test.snap
@@ -0,0 +1,18 @@
+
+[TestRunPrintsSnapshotsHelp - 1]
+Generate, compare, and update serialization snapshots
+
+Usage:
+ tck snapshots [flags]
+ tck snapshots [command]
+
+Available Commands:
+ check Check the snapshot set and stable snapshot contents
+ update Replace committed snapshots with newly generated snapshots
+
+Flags:
+ -h, --help help for snapshots
+
+Use "tck snapshots [command] --help" for more information about a command.
+
+---
diff --git a/cmd/tck/main.go b/cmd/tck/main.go
new file mode 100644
index 0000000..7218e54
--- /dev/null
+++ b/cmd/tck/main.go
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package main
+
+import (
+ "context"
+ "os"
+ "os/signal"
+ "syscall"
+)
+
+func main() {
+ ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt,
syscall.SIGTERM)
+ code := run(ctx, os.Args[1:], os.Stdout, os.Stderr)
+ stop()
+ os.Exit(code)
+}
diff --git a/cmd/tck/main_test.go b/cmd/tck/main_test.go
new file mode 100644
index 0000000..afce061
--- /dev/null
+++ b/cmd/tck/main_test.go
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package main
+
+import (
+ "log"
+ "os"
+ "testing"
+
+ "github.com/gkampitakis/go-snaps/snaps"
+)
+
+func TestMain(m *testing.M) {
+ exitCode := m.Run()
+ dirty, err := snaps.Clean(m, snaps.CleanOpts{Sort: true})
+ if err != nil {
+ log.Printf("clean snapshots: %v", err)
+ os.Exit(1)
+ }
+ if dirty {
+ exitCode = 1
+ }
+ os.Exit(exitCode)
+}
diff --git a/cmd/tck/output.go b/cmd/tck/output.go
new file mode 100644
index 0000000..8676101
--- /dev/null
+++ b/cmd/tck/output.go
@@ -0,0 +1,141 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package main
+
+import (
+ "encoding/hex"
+ "fmt"
+ "io"
+ "path/filepath"
+ "strings"
+
+ "github.com/apache/datasketches-tck/internal/snapshots"
+ "github.com/jedib0t/go-pretty/v6/table"
+ "github.com/jedib0t/go-pretty/v6/text"
+)
+
+func printResult(output io.Writer, root string, mode snapshots.Mode, result
snapshots.Result) error {
+ target := displayPath(root, result.Target)
+ if len(result.Changes) == 0 {
+ _, err := fmt.Fprintf(output, "✓ %s is up to date.\n", target)
+ return err
+ }
+
+ counts := make(map[snapshots.ChangeStatus]int)
+ unstableModified := 0
+ changeTable := table.NewWriter()
+ changeTable.SetStyle(table.StyleRounded)
+ changeTable.SetColumnConfigs([]table.ColumnConfig{{
+ Name: "Snapshot", WidthMax: 60, WidthMaxEnforcer: text.WrapHard,
+ }})
+ changeTable.AppendHeader(table.Row{"Change", "Stability", "Check",
"Snapshot", "Content (size · sha256)"})
+ for _, change := range result.Changes {
+ counts[change.Status]++
+ if change.Status == snapshots.ChangeModified &&
change.Stability == snapshots.Unstable {
+ unstableModified++
+ }
+ changeTable.AppendRow(table.Row{
+ change.Status,
+ change.Stability,
+ checkDisposition(change),
+ change.Path,
+ changeDetails(change),
+ })
+ }
+
+ if _, err := fmt.Fprintln(output, changeTable.Render()); err != nil {
+ return err
+ }
+ if _, err := fmt.Fprintf(
+ output,
+ "Summary: %d added · %d modified (%d probabilistic) · %d
deleted\n",
+ counts[snapshots.ChangeAdded],
+ counts[snapshots.ChangeModified],
+ unstableModified,
+ counts[snapshots.ChangeDeleted],
+ ); err != nil {
+ return err
+ }
+
+ switch {
+ case mode == snapshots.ModeUpdate:
+ _, err := fmt.Fprintf(output, "✓ Updated %s.\n", target)
+ return err
+ case result.HasBlockingChanges():
+ count := result.BlockingChangeCount()
+ _, err := fmt.Fprintf(output, "✗ %s has %d blocking %s.\n",
target, count, plural(count, "change", "changes"))
+ return err
+ default:
+ _, err := fmt.Fprintf(
+ output,
+ "! Snapshot set and stable contents are unchanged; %d
probabilistic content %s allowed.\n",
+ unstableModified,
+ plural(unstableModified, "modification is",
"modifications are"),
+ )
+ return err
+ }
+}
+
+func changeDetails(change snapshots.Change) string {
+ switch change.Status {
+ case snapshots.ChangeAdded:
+ return "new " + formatMetadata(change.After)
+ case snapshots.ChangeDeleted:
+ return "old " + formatMetadata(change.Before)
+ case snapshots.ChangeModified:
+ return "old " + formatMetadata(change.Before) + "\nnew " +
formatMetadata(change.After)
+ default:
+ return "unknown"
+ }
+}
+
+func formatMetadata(metadata *snapshots.FileMetadata) string {
+ if metadata == nil {
+ return "—"
+ }
+ return fmt.Sprintf(
+ "%d B · %s",
+ metadata.Size,
+ hex.EncodeToString(metadata.SHA256[:6]),
+ )
+}
+
+func checkDisposition(change snapshots.Change) string {
+ if change.IsBlocking() {
+ return "block"
+ }
+ return "allow"
+}
+
+func plural(count int, singular, multiple string) string {
+ if count == 1 {
+ return singular
+ }
+ return multiple
+}
+
+func displayPath(root, filename string) string {
+ relative, err := filepath.Rel(root, filename)
+ if err != nil || relative == ".." || filepath.IsAbs(relative) {
+ return filename
+ }
+ if strings.HasPrefix(relative, ".."+string(filepath.Separator)) {
+ return filename
+ }
+ return filepath.ToSlash(relative)
+}
diff --git a/cmd/tck/output_test.go b/cmd/tck/output_test.go
new file mode 100644
index 0000000..3552291
--- /dev/null
+++ b/cmd/tck/output_test.go
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package main
+
+import (
+ "bytes"
+ "path/filepath"
+ "testing"
+
+ "github.com/apache/datasketches-tck/internal/snapshots"
+ "github.com/gkampitakis/go-snaps/snaps"
+ "github.com/stretchr/testify/require"
+)
+
+func TestPrintResultIncludesDetailedFileChanges(t *testing.T) {
+ t.Parallel()
+
+ root := t.TempDir()
+ before := testMetadata(12, 0xaa)
+ after := testMetadata(16, 0xbb)
+ result := snapshots.Result{
+ Target: filepath.Join(root, "serialization", "go", "snapshots"),
+ Changes: []snapshots.Change{
+ {
+ Status: snapshots.ChangeAdded, Stability:
snapshots.Stable,
+ Path: "added.sk", After: &after,
+ },
+ {
+ Status: snapshots.ChangeModified, Stability:
snapshots.Unstable,
+ Path: "modified.sk", Before: &before, After:
&after,
+ },
+ {
+ Status: snapshots.ChangeDeleted, Stability:
snapshots.Stable,
+ Path: "deleted.sk", Before: &before,
+ },
+ },
+ }
+
+ var output bytes.Buffer
+ require.NoError(t, printResult(&output, root, snapshots.ModeCheck,
result))
+ snaps.WithConfig(snaps.Raw()).MatchSnapshot(t, output.String())
+}
+
+func TestPrintResultAllowsOnlyUnstableModifications(t *testing.T) {
+ t.Parallel()
+
+ before := testMetadata(12, 0xaa)
+ after := testMetadata(12, 0xbb)
+ result := snapshots.Result{
+ Target: "snapshots",
+ Changes: []snapshots.Change{{
+ Status: snapshots.ChangeModified, Stability:
snapshots.Unstable,
+ Path: "probabilistic.sk", Before: &before, After:
&after,
+ }},
+ }
+
+ var output bytes.Buffer
+ require.NoError(t, printResult(&output, ".", snapshots.ModeCheck,
result))
+ snaps.WithConfig(snaps.Raw()).MatchSnapshot(t, output.String())
+}
+
+func testMetadata(size int64, fill byte) snapshots.FileMetadata {
+ metadata := snapshots.FileMetadata{Size: size}
+ for index := range metadata.SHA256 {
+ metadata.SHA256[index] = fill
+ }
+ return metadata
+}
diff --git a/cmd/tck/root.go b/cmd/tck/root.go
new file mode 100644
index 0000000..bc1d58f
--- /dev/null
+++ b/cmd/tck/root.go
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package main
+
+import (
+ "context"
+ "errors"
+ "io"
+
+ "github.com/spf13/cobra"
+)
+
+func run(ctx context.Context, args []string, stdout, stderr io.Writer) int {
+ command := newRootCommand()
+ command.SetArgs(args)
+ command.SetOut(stdout)
+ command.SetErr(stderr)
+
+ err := command.ExecuteContext(ctx)
+ if err == nil {
+ return 0
+ }
+ if errors.Is(err, errSnapshotsOutOfDate) {
+ return 1
+ }
+
+ command.PrintErrf("Error: %v\n", err)
+ return 1
+}
+
+func newRootCommand() *cobra.Command {
+ command := &cobra.Command{
+ Use: "tck",
+ Short: "Generate and validate DataSketches
serialization snapshots",
+ Args: cobra.NoArgs,
+ SilenceErrors: true,
+ SilenceUsage: true,
+ RunE: func(command *cobra.Command, _ []string) error {
+ return command.Help()
+ },
+ }
+ command.CompletionOptions.DisableDefaultCmd = true
+ command.AddCommand(newSnapshotsCommand())
+ return command
+}
diff --git a/cmd/tck/root_test.go b/cmd/tck/root_test.go
new file mode 100644
index 0000000..5741851
--- /dev/null
+++ b/cmd/tck/root_test.go
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package main
+
+import (
+ "bytes"
+ "testing"
+
+ "github.com/gkampitakis/go-snaps/snaps"
+ "github.com/stretchr/testify/require"
+)
+
+func TestRunPrintsSnapshotsHelp(t *testing.T) {
+ t.Parallel()
+
+ var output bytes.Buffer
+ var stderr bytes.Buffer
+ require.Equal(t, 0, run(t.Context(), []string{"snapshots"}, &output,
&stderr))
+ require.Empty(t, stderr.String())
+ snaps.WithConfig(snaps.Raw()).MatchSnapshot(t, output.String())
+}
+
+func TestRunRejectsUnsupportedLanguage(t *testing.T) {
+ t.Parallel()
+
+ var output bytes.Buffer
+ var stderr bytes.Buffer
+ exitCode := run(t.Context(), []string{"snapshots", "check", "python"},
&output, &stderr)
+
+ require.Equal(t, 1, exitCode)
+ require.Empty(t, output.String())
+ require.Contains(t, stderr.String(), `invalid argument "python" for
"tck snapshots check"`)
+}
diff --git a/cmd/tck/snapshots.go b/cmd/tck/snapshots.go
new file mode 100644
index 0000000..0df9b74
--- /dev/null
+++ b/cmd/tck/snapshots.go
@@ -0,0 +1,176 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package main
+
+import (
+ "context"
+ "errors"
+ "fmt"
+ "os"
+ "os/exec"
+ "path/filepath"
+ "strings"
+
+ "github.com/apache/datasketches-tck/internal/snapshots"
+ "github.com/spf13/cobra"
+)
+
+var errSnapshotsOutOfDate = errors.New("snapshots contain blocking changes")
+
+func newSnapshotsCommand() *cobra.Command {
+ command := &cobra.Command{
+ Use: "snapshots",
+ Short: "Generate, compare, and update serialization snapshots",
+ Args: cobra.NoArgs,
+ RunE: func(command *cobra.Command, _ []string) error {
+ return command.Help()
+ },
+ }
+ command.AddCommand(
+ newSnapshotReconcileCommand(snapshots.ModeCheck),
+ newSnapshotReconcileCommand(snapshots.ModeUpdate),
+ )
+ return command
+}
+
+func newSnapshotReconcileCommand(mode snapshots.Mode) *cobra.Command {
+ verb := string(mode)
+ validLanguages := append(snapshots.Languages(), "all")
+ return &cobra.Command{
+ Use: verb + " <cpp|go|java|all>",
+ Short: reconcileDescription(mode),
+ Long: reconcileDetails(mode),
+ Args: cobra.MatchAll(cobra.ExactArgs(1),
cobra.OnlyValidArgs),
+ ValidArgs: validLanguages,
+ RunE: func(command *cobra.Command, args []string) error {
+ return reconcileSnapshots(command, mode, args[0])
+ },
+ }
+}
+
+func reconcileSnapshots(command *cobra.Command, mode snapshots.Mode,
requestedLanguage string) error {
+ languages := []string{requestedLanguage}
+ if requestedLanguage == "all" {
+ languages = snapshots.Languages()
+ }
+
+ root, err := repositoryRoot(command.Context())
+ if err != nil {
+ return err
+ }
+
+ outOfDate := false
+ for index, language := range languages {
+ if index > 0 {
+ if _, err := fmt.Fprintln(command.OutOrStdout()); err
!= nil {
+ return fmt.Errorf("separate snapshot results:
%w", err)
+ }
+ }
+ if _, err := fmt.Fprintf(
+ command.OutOrStdout(),
+ "%s %s snapshots\n",
+ modeHeading(mode),
+ languageHeading(language),
+ ); err != nil {
+ return fmt.Errorf("print snapshot heading: %w", err)
+ }
+
+ result, err := snapshots.Reconcile(
+ command.Context(),
+ root,
+ language,
+ mode,
+ command.OutOrStdout(),
+ command.ErrOrStderr(),
+ )
+ if err != nil {
+ return err
+ }
+ if err := printResult(command.OutOrStdout(), root, mode,
result); err != nil {
+ return fmt.Errorf("print snapshot result: %w", err)
+ }
+ outOfDate = outOfDate || (mode == snapshots.ModeCheck &&
result.HasBlockingChanges())
+ }
+ if outOfDate {
+ return errSnapshotsOutOfDate
+ }
+ return nil
+}
+
+func reconcileDescription(mode snapshots.Mode) string {
+ switch mode {
+ case snapshots.ModeCheck:
+ return "Check the snapshot set and stable snapshot contents"
+ case snapshots.ModeUpdate:
+ return "Replace committed snapshots with newly generated
snapshots"
+ default:
+ panic(fmt.Sprintf("unsupported snapshot mode %q", mode))
+ }
+}
+
+func reconcileDetails(mode snapshots.Mode) string {
+ switch mode {
+ case snapshots.ModeCheck:
+ return "Generate snapshots and verify that the file set and
stable contents match. Content changes to existing probabilistic snapshots are
reported but do not fail the check."
+ case snapshots.ModeUpdate:
+ return "Generate snapshots and atomically replace the selected
committed snapshot directory with the complete generated file set."
+ default:
+ panic(fmt.Sprintf("unsupported snapshot mode %q", mode))
+ }
+}
+
+func modeHeading(mode snapshots.Mode) string {
+ switch mode {
+ case snapshots.ModeCheck:
+ return "Check"
+ case snapshots.ModeUpdate:
+ return "Update"
+ default:
+ panic(fmt.Sprintf("unsupported snapshot mode %q", mode))
+ }
+}
+
+func languageHeading(language string) string {
+ switch language {
+ case "cpp":
+ return "C++"
+ case "go":
+ return "Go"
+ case "java":
+ return "Java"
+ default:
+ return language
+ }
+}
+
+func repositoryRoot(ctx context.Context) (string, error) {
+ if configured := os.Getenv("TCK_REPOSITORY_ROOT"); configured != "" {
+ root, err := filepath.Abs(configured)
+ if err != nil {
+ return "", fmt.Errorf("resolve TCK_REPOSITORY_ROOT:
%w", err)
+ }
+ return root, nil
+ }
+
+ command := exec.CommandContext(ctx, "git", "rev-parse",
"--show-toplevel")
+ output, err := command.Output()
+ if err != nil {
+ return "", fmt.Errorf("resolve repository root with git: %w",
err)
+ }
+ return strings.TrimSpace(string(output)), nil
+}
diff --git a/go.mod b/go.mod
new file mode 100644
index 0000000..ad8dc28
--- /dev/null
+++ b/go.mod
@@ -0,0 +1,50 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+module github.com/apache/datasketches-tck
+
+go 1.26.0
+
+toolchain go1.26.5
+
+require (
+ github.com/gkampitakis/go-snaps v0.5.23
+ github.com/jedib0t/go-pretty/v6 v6.8.3
+ github.com/spf13/cobra v1.10.2
+ github.com/stretchr/testify v1.11.1
+)
+
+require (
+ github.com/davecgh/go-spew v1.1.1 // indirect
+ github.com/gkampitakis/ciinfo v0.3.4 // indirect
+ github.com/goccy/go-yaml v1.19.2 // indirect
+ github.com/inconshreveable/mousetrap v1.1.0 // indirect
+ github.com/kr/pretty v0.3.1 // indirect
+ github.com/kr/text v0.2.0 // indirect
+ github.com/maruel/natural v1.3.0 // indirect
+ github.com/mattn/go-runewidth v0.0.16 // indirect
+ github.com/pmezard/go-difflib v1.0.0 // indirect
+ github.com/rivo/uniseg v0.4.7 // indirect
+ github.com/rogpeppe/go-internal v1.13.1 // indirect
+ github.com/sergi/go-diff v1.4.0 // indirect
+ github.com/spf13/pflag v1.0.9 // indirect
+ github.com/tidwall/gjson v1.19.0 // indirect
+ github.com/tidwall/match v1.1.1 // indirect
+ github.com/tidwall/pretty v1.2.1 // indirect
+ github.com/tidwall/sjson v1.2.5 // indirect
+ golang.org/x/sys v0.30.0 // indirect
+ golang.org/x/text v0.22.0 // indirect
+ gopkg.in/yaml.v3 v3.0.1 // indirect
+)
diff --git a/go.sum b/go.sum
new file mode 100644
index 0000000..9bb4d11
--- /dev/null
+++ b/go.sum
@@ -0,0 +1,68 @@
+github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod
h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
+github.com/creack/pty v1.1.9/go.mod
h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
+github.com/davecgh/go-spew v1.1.0/go.mod
h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/davecgh/go-spew v1.1.1
h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
+github.com/davecgh/go-spew v1.1.1/go.mod
h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/gkampitakis/ciinfo v0.3.4
h1:5eBSibVuSMbb/H6Elc0IIEFbkzCJi3lm94n0+U7Z0KY=
+github.com/gkampitakis/ciinfo v0.3.4/go.mod
h1:1NIwaOcFChN4fa/B0hEBdAb6npDlFL8Bwx4dfRLRqAo=
+github.com/gkampitakis/go-snaps v0.5.23
h1:okh5QR48zpUjpWtu65AtqxdCY8huJq+dEDuUzd1PuKg=
+github.com/gkampitakis/go-snaps v0.5.23/go.mod
h1:uy3lVzCCRRsAwYqSocyw5fY8xRLCYEfqoOJNxr8HonM=
+github.com/goccy/go-yaml v1.19.2
h1:PmFC1S6h8ljIz6gMRBopkjP1TVT7xuwrButHID66PoM=
+github.com/goccy/go-yaml v1.19.2/go.mod
h1:XBurs7gK8ATbW4ZPGKgcbrY1Br56PdM69F7LkFRi1kA=
+github.com/inconshreveable/mousetrap v1.1.0
h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
+github.com/inconshreveable/mousetrap v1.1.0/go.mod
h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
+github.com/jedib0t/go-pretty/v6 v6.8.3
h1:yVSk5aemoYHCvcrtqyXklwqcgHQIQzmy/oUzFlmffSQ=
+github.com/jedib0t/go-pretty/v6 v6.8.3/go.mod
h1:YwC5CE4fJ1HFUDeivSV1r//AmANFHyqczZk+U6BDALU=
+github.com/kr/pretty v0.1.0/go.mod
h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
+github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
+github.com/kr/pretty v0.3.1/go.mod
h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
+github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
+github.com/kr/text v0.1.0/go.mod
h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
+github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
+github.com/kr/text v0.2.0/go.mod
h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
+github.com/maruel/natural v1.3.0
h1:VsmCsBmEyrR46RomtgHs5hbKADGRVtliHTyCOLFBpsg=
+github.com/maruel/natural v1.3.0/go.mod
h1:v+Rfd79xlw1AgVBjbO0BEQmptqb5HvL/k9GRHB7ZKEg=
+github.com/mattn/go-runewidth v0.0.16
h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc=
+github.com/mattn/go-runewidth v0.0.16/go.mod
h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
+github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod
h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
+github.com/pmezard/go-difflib v1.0.0
h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
+github.com/pmezard/go-difflib v1.0.0/go.mod
h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
+github.com/rivo/uniseg v0.2.0/go.mod
h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
+github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
+github.com/rivo/uniseg v0.4.7/go.mod
h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
+github.com/rogpeppe/go-internal v1.9.0/go.mod
h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
+github.com/rogpeppe/go-internal v1.13.1
h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII=
+github.com/rogpeppe/go-internal v1.13.1/go.mod
h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o=
+github.com/russross/blackfriday/v2 v2.1.0/go.mod
h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
+github.com/sergi/go-diff v1.4.0 h1:n/SP9D5ad1fORl+llWyN+D6qoUETXNZARKjyY2/KVCw=
+github.com/sergi/go-diff v1.4.0/go.mod
h1:A0bzQcvG0E7Rwjx0REVgAGH58e96+X0MeOfepqsbeW4=
+github.com/spf13/cobra v1.10.2 h1:DMTTonx5m65Ic0GOoRY2c16WCbHxOOw6xxezuLaBpcU=
+github.com/spf13/cobra v1.10.2/go.mod
h1:7C1pvHqHw5A4vrJfjNwvOdzYu0Gml16OCs2GRiTUUS4=
+github.com/spf13/pflag v1.0.9 h1:9exaQaMOCwffKiiiYk6/BndUBv+iRViNW+4lEMi0PvY=
+github.com/spf13/pflag v1.0.9/go.mod
h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
+github.com/stretchr/objx v0.1.0/go.mod
h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
+github.com/stretchr/testify v1.4.0/go.mod
h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
+github.com/stretchr/testify v1.11.1
h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
+github.com/stretchr/testify v1.11.1/go.mod
h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
+github.com/tidwall/gjson v1.14.2/go.mod
h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
+github.com/tidwall/gjson v1.19.0
h1:xwxm7n691Uf3u5OFjzngavjGTh55KX5q/9w9xHW88JU=
+github.com/tidwall/gjson v1.19.0/go.mod
h1:V37/opeE/JbLUOfH0QTXiNez2l0RUjYUhpT4szFQAfc=
+github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
+github.com/tidwall/match v1.1.1/go.mod
h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
+github.com/tidwall/pretty v1.2.0/go.mod
h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
+github.com/tidwall/pretty v1.2.1
h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4=
+github.com/tidwall/pretty v1.2.1/go.mod
h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
+github.com/tidwall/sjson v1.2.5 h1:kLy8mja+1c9jlljvWTlSazM7cKDRfJuR/bOJhcY5NcY=
+github.com/tidwall/sjson v1.2.5/go.mod
h1:Fvgq9kS/6ociJEDnK0Fk1cpYF4FIW6ZF7LAe+6jwd28=
+go.yaml.in/yaml/v3 v3.0.4/go.mod
h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
+golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc=
+golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
+golang.org/x/text v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM=
+golang.org/x/text v0.22.0/go.mod
h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY=
+gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod
h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
+gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15
h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
+gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod
h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
+gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
+gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
+gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
+gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
diff --git a/internal/snapshots/cpp.go b/internal/snapshots/cpp.go
new file mode 100644
index 0000000..bcc8d5b
--- /dev/null
+++ b/internal/snapshots/cpp.go
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package snapshots
+
+import (
+ "context"
+ "os"
+ "path/filepath"
+ "strings"
+)
+
+func generateCPP(
+ ctx context.Context,
+ paths generationPaths,
+ runner commandRunner,
+) error {
+ build := filepath.Join(paths.workspace, "build")
+ if err := os.Mkdir(build, 0o755); err != nil {
+ return err
+ }
+ if err := runner.run(
+ ctx,
+ "",
+ "cmake",
+ "-S", paths.source,
+ "-B", build,
+ "-DGENERATE=true",
+ "-DCMAKE_BUILD_TYPE=Release",
+ ); err != nil {
+ return err
+ }
+ if err := runner.run(ctx, "", "cmake", "--build", build, "--config",
"Release"); err != nil {
+ return err
+ }
+ if err := runner.run(ctx, "", "ctest", "--test-dir", build, "-C",
"Release", "--output-on-failure"); err != nil {
+ return err
+ }
+
+ return collectSnapshots(build, paths.destination, func(name string)
bool {
+ return strings.HasSuffix(name, "_cpp.sk")
+ })
+}
diff --git a/internal/snapshots/diff.go b/internal/snapshots/diff.go
new file mode 100644
index 0000000..bcc7594
--- /dev/null
+++ b/internal/snapshots/diff.go
@@ -0,0 +1,181 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package snapshots
+
+import (
+ "crypto/sha256"
+ "fmt"
+ "io"
+ "io/fs"
+ "os"
+ "path/filepath"
+ "sort"
+)
+
+type ChangeStatus string
+
+const (
+ ChangeAdded ChangeStatus = "A"
+ ChangeDeleted ChangeStatus = "D"
+ ChangeModified ChangeStatus = "M"
+)
+
+type FileMetadata struct {
+ Size int64
+ SHA256 [sha256.Size]byte
+}
+
+type Change struct {
+ Status ChangeStatus
+ Stability Stability
+ Path string
+ Before *FileMetadata
+ After *FileMetadata
+}
+
+// IsBlocking reports whether a change must fail snapshot check mode. Only a
+// content modification to an existing unstable snapshot is expected to vary;
+// additions and deletions change the compatibility corpus and always block.
+func (change Change) IsBlocking() bool {
+ return change.Status != ChangeModified || change.Stability != Unstable
+}
+
+type fileRecord struct {
+ filename string
+ metadata FileMetadata
+}
+
+func compareDirectories(
+ current, generated string,
+ stability func(string) Stability,
+) ([]Change, error) {
+ currentFiles, err := regularFiles(current)
+ if err != nil {
+ return nil, fmt.Errorf("inspect current snapshots: %w", err)
+ }
+ generatedFiles, err := regularFiles(generated)
+ if err != nil {
+ return nil, fmt.Errorf("inspect generated snapshots: %w", err)
+ }
+
+ paths := make(map[string]struct{},
len(currentFiles)+len(generatedFiles))
+ for path := range currentFiles {
+ paths[path] = struct{}{}
+ }
+ for path := range generatedFiles {
+ paths[path] = struct{}{}
+ }
+
+ names := make([]string, 0, len(paths))
+ for path := range paths {
+ names = append(names, path)
+ }
+ sort.Strings(names)
+
+ changes := make([]Change, 0)
+ for _, name := range names {
+ currentFile, inCurrent := currentFiles[name]
+ generatedFile, inGenerated := generatedFiles[name]
+ snapshotStability := stability(name)
+ switch {
+ case !inCurrent:
+ after := generatedFile.metadata
+ changes = append(changes, Change{
+ Status: ChangeAdded, Stability:
snapshotStability, Path: name, After: &after,
+ })
+ case !inGenerated:
+ before := currentFile.metadata
+ changes = append(changes, Change{
+ Status: ChangeDeleted, Stability:
snapshotStability, Path: name, Before: &before,
+ })
+ case currentFile.metadata != generatedFile.metadata:
+ before := currentFile.metadata
+ after := generatedFile.metadata
+ changes = append(changes, Change{
+ Status: ChangeModified, Stability:
snapshotStability, Path: name, Before: &before, After: &after,
+ })
+ }
+ }
+ return changes, nil
+}
+
+func regularFiles(directory string) (map[string]fileRecord, error) {
+ info, err := os.Lstat(directory)
+ if err != nil {
+ if os.IsNotExist(err) {
+ return map[string]fileRecord{}, nil
+ }
+ return nil, err
+ }
+ if !info.IsDir() || info.Mode()&os.ModeSymlink != 0 {
+ return nil, fmt.Errorf("%s is not a directory", directory)
+ }
+
+ files := make(map[string]fileRecord)
+ err = filepath.WalkDir(directory, func(filename string, entry
fs.DirEntry, walkErr error) error {
+ if walkErr != nil {
+ return walkErr
+ }
+ if filename == directory || entry.IsDir() {
+ return nil
+ }
+ if entry.Type()&os.ModeSymlink != 0 {
+ return fmt.Errorf("%s is a symbolic link", filename)
+ }
+
+ entryInfo, err := entry.Info()
+ if err != nil {
+ return err
+ }
+ if !entryInfo.Mode().IsRegular() {
+ return fmt.Errorf("%s is not a regular file", filename)
+ }
+
+ relative, err := filepath.Rel(directory, filename)
+ if err != nil {
+ return err
+ }
+ metadata, err := fileMetadata(filename, entryInfo.Size())
+ if err != nil {
+ return err
+ }
+ files[filepath.ToSlash(relative)] = fileRecord{filename:
filename, metadata: metadata}
+ return nil
+ })
+ if err != nil {
+ return nil, err
+ }
+ return files, nil
+}
+
+func fileMetadata(filename string, size int64) (FileMetadata, error) {
+ file, err := os.Open(filename)
+ if err != nil {
+ return FileMetadata{}, err
+ }
+ defer func() { _ = file.Close() }()
+
+ hash := sha256.New()
+ if _, err := io.Copy(hash, file); err != nil {
+ return FileMetadata{}, err
+ }
+
+ var digest [sha256.Size]byte
+ copy(digest[:], hash.Sum(nil))
+ return FileMetadata{Size: size, SHA256: digest}, nil
+}
diff --git a/internal/snapshots/diff_test.go b/internal/snapshots/diff_test.go
new file mode 100644
index 0000000..be011c9
--- /dev/null
+++ b/internal/snapshots/diff_test.go
@@ -0,0 +1,118 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package snapshots
+
+import (
+ "crypto/sha256"
+ "os"
+ "path/filepath"
+ "testing"
+
+ "github.com/stretchr/testify/require"
+)
+
+func TestCompareDirectoriesReportsDetailedChanges(t *testing.T) {
+ t.Parallel()
+
+ root := t.TempDir()
+ current := filepath.Join(root, "current")
+ generated := filepath.Join(root, "generated")
+ writeTestFile(t, filepath.Join(current, "deleted.sk"), "deleted")
+ writeTestFile(t, filepath.Join(current, "modified.sk"), "old")
+ writeTestFile(t, filepath.Join(current, "same.sk"), "same")
+ writeTestFile(t, filepath.Join(generated, "added.sk"), "added")
+ writeTestFile(t, filepath.Join(generated, "modified.sk"), "new")
+ writeTestFile(t, filepath.Join(generated, "same.sk"), "same")
+
+ changes, err := compareDirectories(current, generated, func(path
string) Stability {
+ if path == "modified.sk" {
+ return Unstable
+ }
+ return Stable
+ })
+
+ added := testFileMetadata("added")
+ deleted := testFileMetadata("deleted")
+ before := testFileMetadata("old")
+ after := testFileMetadata("new")
+ want := []Change{
+ {Status: ChangeAdded, Stability: Stable, Path: "added.sk",
After: &added},
+ {Status: ChangeDeleted, Stability: Stable, Path: "deleted.sk",
Before: &deleted},
+ {Status: ChangeModified, Stability: Unstable, Path:
"modified.sk", Before: &before, After: &after},
+ }
+ require.NoError(t, err)
+ require.Equal(t, want, changes)
+}
+
+func TestChangeIsBlocking(t *testing.T) {
+ t.Parallel()
+
+ tests := []struct {
+ name string
+ change Change
+ blocking bool
+ }{
+ {name: "stable addition", change: Change{Status: ChangeAdded,
Stability: Stable}, blocking: true},
+ {name: "unstable addition", change: Change{Status: ChangeAdded,
Stability: Unstable}, blocking: true},
+ {name: "stable modification", change: Change{Status:
ChangeModified, Stability: Stable}, blocking: true},
+ {name: "unstable modification", change: Change{Status:
ChangeModified, Stability: Unstable}, blocking: false},
+ {name: "stable deletion", change: Change{Status: ChangeDeleted,
Stability: Stable}, blocking: true},
+ {name: "unstable deletion", change: Change{Status:
ChangeDeleted, Stability: Unstable}, blocking: true},
+ }
+
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ t.Parallel()
+ require.Equal(t, test.blocking,
test.change.IsBlocking())
+ })
+ }
+}
+
+func TestReplaceDirectoryReplacesTheExactFileSet(t *testing.T) {
+ t.Parallel()
+
+ root := t.TempDir()
+ target := filepath.Join(root, "snapshots")
+ generated := filepath.Join(root, "generated")
+ writeTestFile(t, filepath.Join(target, "deleted.sk"), "deleted")
+ writeTestFile(t, filepath.Join(target, "modified.sk"), "old")
+ writeTestFile(t, filepath.Join(generated, "modified.sk"), "new")
+ writeTestFile(t, filepath.Join(generated, "nested", "added.sk"),
"added")
+
+ require.NoError(t, replaceDirectory(target, generated))
+ requireTestFile(t, filepath.Join(target, "modified.sk"), "new")
+ requireTestFile(t, filepath.Join(target, "nested", "added.sk"), "added")
+ require.NoFileExists(t, filepath.Join(target, "deleted.sk"))
+}
+
+func writeTestFile(t *testing.T, filename, content string) {
+ t.Helper()
+ require.NoError(t, os.MkdirAll(filepath.Dir(filename), 0o755))
+ require.NoError(t, os.WriteFile(filename, []byte(content), 0o644))
+}
+
+func requireTestFile(t *testing.T, filename, expected string) {
+ t.Helper()
+ content, err := os.ReadFile(filename)
+ require.NoError(t, err)
+ require.Equal(t, expected, string(content))
+}
+
+func testFileMetadata(content string) FileMetadata {
+ return FileMetadata{Size: int64(len(content)), SHA256:
sha256.Sum256([]byte(content))}
+}
diff --git a/internal/snapshots/files.go b/internal/snapshots/files.go
new file mode 100644
index 0000000..ecf9d08
--- /dev/null
+++ b/internal/snapshots/files.go
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package snapshots
+
+import (
+ "fmt"
+ "io"
+ "io/fs"
+ "os"
+ "path/filepath"
+)
+
+func collectSnapshots(source, destination string, include func(string) bool)
error {
+ info, err := os.Stat(source)
+ if err != nil {
+ return fmt.Errorf("inspect generated snapshots: %w", err)
+ }
+ if !info.IsDir() {
+ return fmt.Errorf("generated snapshot path %s is not a
directory", source)
+ }
+ if err := os.MkdirAll(destination, 0o755); err != nil {
+ return fmt.Errorf("create snapshot staging directory: %w", err)
+ }
+
+ seen := make(map[string]string)
+ err = filepath.WalkDir(source, func(filename string, entry fs.DirEntry,
walkErr error) error {
+ if walkErr != nil {
+ return walkErr
+ }
+ if entry.IsDir() {
+ return nil
+ }
+ if entry.Type()&os.ModeSymlink != 0 {
+ return fmt.Errorf("generated file %s is a symbolic
link", filename)
+ }
+ if !include(entry.Name()) {
+ return nil
+ }
+
+ entryInfo, err := entry.Info()
+ if err != nil {
+ return err
+ }
+ if !entryInfo.Mode().IsRegular() {
+ return fmt.Errorf("generated file %s is not regular",
filename)
+ }
+ if previous, found := seen[entry.Name()]; found {
+ return fmt.Errorf("duplicate generated snapshot %s in
%s and %s", entry.Name(), previous, filename)
+ }
+ seen[entry.Name()] = filename
+ return copyFile(filename, filepath.Join(destination,
entry.Name()))
+ })
+ if err != nil {
+ return fmt.Errorf("collect generated snapshots: %w", err)
+ }
+ if len(seen) == 0 {
+ return fmt.Errorf("no snapshots found under %s", source)
+ }
+ return nil
+}
+
+func copyFile(source, destination string) error {
+ input, err := os.Open(source)
+ if err != nil {
+ return err
+ }
+ defer func() { _ = input.Close() }()
+
+ output, err := os.OpenFile(destination,
os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0o644)
+ if err != nil {
+ return err
+ }
+ if _, err := io.Copy(output, input); err != nil {
+ _ = output.Close()
+ return err
+ }
+ return output.Close()
+}
diff --git a/internal/snapshots/generator.go b/internal/snapshots/generator.go
new file mode 100644
index 0000000..4d6786f
--- /dev/null
+++ b/internal/snapshots/generator.go
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package snapshots
+
+import (
+ "context"
+ "io"
+ "path/filepath"
+ "sort"
+)
+
+type generationPaths struct {
+ workspace string
+ source string
+ destination string
+}
+
+type generateFunc func(context.Context, generationPaths, commandRunner) error
+
+type generator struct {
+ repository string
+ commit string
+ requirements []string
+ generate generateFunc
+ stability func(string) Stability
+}
+
+var generators = map[string]generator{
+ "cpp": {
+ repository: "https://github.com/apache/datasketches-cpp.git",
+ commit: "401423367055acdf7502e8ed3126730a08039d91",
+ requirements: []string{"git", "cmake", "ctest"},
+ generate: generateCPP,
+ stability: cppStability,
+ },
+ "go": {
+ repository: "https://github.com/apache/datasketches-go.git",
+ commit: "730c0ca31e00b8becf8b70591ae8ca73954912d0",
+ requirements: []string{"git", "go", "make"},
+ generate: generateGo,
+ stability: goStability,
+ },
+ "java": {
+ repository: "https://github.com/apache/datasketches-java.git",
+ commit: "f3b334b380feee9f928500de9adb6bbf763fc104",
+ requirements: []string{"git", "java", "mvn"},
+ generate: generateJava,
+ stability: javaStability,
+ },
+}
+
+func Languages() []string {
+ languages := make([]string, 0, len(generators))
+ for language := range generators {
+ languages = append(languages, language)
+ }
+ sort.Strings(languages)
+ return languages
+}
+
+func (definition generator) run(
+ ctx context.Context,
+ workspace, destination string,
+ runner commandRunner,
+) error {
+ paths := generationPaths{
+ workspace: workspace,
+ source: filepath.Join(workspace, "source"),
+ destination: destination,
+ }
+ if err := cloneAtCommit(ctx, runner, definition.repository,
definition.commit, paths.source); err != nil {
+ return err
+ }
+ return definition.generate(ctx, paths, runner)
+}
+
+type commandRunner struct {
+ stdout io.Writer
+ stderr io.Writer
+}
diff --git a/internal/snapshots/go.go b/internal/snapshots/go.go
new file mode 100644
index 0000000..22b60ea
--- /dev/null
+++ b/internal/snapshots/go.go
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package snapshots
+
+import (
+ "context"
+ "path/filepath"
+ "strings"
+)
+
+func generateGo(
+ ctx context.Context,
+ paths generationPaths,
+ runner commandRunner,
+) error {
+ if err := runner.run(ctx, paths.source, "make",
"generate-go-snapshots"); err != nil {
+ return err
+ }
+
+ generated := filepath.Join(paths.source, "serialization_test_data",
"go_generated_files")
+ return collectSnapshots(generated, paths.destination, func(name string)
bool {
+ return strings.HasSuffix(name, "_go.sk")
+ })
+}
diff --git a/internal/snapshots/java.go b/internal/snapshots/java.go
new file mode 100644
index 0000000..0dd1068
--- /dev/null
+++ b/internal/snapshots/java.go
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package snapshots
+
+import (
+ "context"
+ "fmt"
+ "html"
+ "os"
+ "path/filepath"
+ "strings"
+)
+
+func generateJava(
+ ctx context.Context,
+ paths generationPaths,
+ runner commandRunner,
+) error {
+ toolchains, err := writeMavenToolchains(paths.workspace)
+ if err != nil {
+ return err
+ }
+ if err := runner.run(
+ ctx,
+ paths.source,
+ "mvn",
+ "--toolchains", toolchains,
+ "test",
+ "-P", "generate-java-files",
+ ); err != nil {
+ return err
+ }
+
+ generated := filepath.Join(paths.source, "serialization_test_data",
"java_generated_files")
+ return collectSnapshots(generated, paths.destination, func(name string)
bool {
+ return strings.HasSuffix(name, "_java.sk")
+ })
+}
+
+func writeMavenToolchains(workspace string) (string, error) {
+ javaHome := os.Getenv("JAVA_HOME")
+ if javaHome == "" {
+ return "", fmt.Errorf("JAVA_HOME must point to a JDK 25
installation; run the CLI through mise")
+ }
+ info, err := os.Stat(javaHome)
+ if err != nil {
+ return "", fmt.Errorf("inspect JAVA_HOME: %w", err)
+ }
+ if !info.IsDir() {
+ return "", fmt.Errorf("JAVA_HOME %s is not a directory",
javaHome)
+ }
+
+ filename := filepath.Join(workspace, "maven-toolchains.xml")
+ content := fmt.Sprintf(`<?xml version="1.0" encoding="UTF-8"?>
+<toolchains>
+ <toolchain>
+ <type>jdk</type>
+ <provides>
+ <version>25</version>
+ </provides>
+ <configuration>
+ <jdkHome>%s</jdkHome>
+ </configuration>
+ </toolchain>
+</toolchains>
+`, html.EscapeString(javaHome))
+ if err := os.WriteFile(filename, []byte(content), 0o600); err != nil {
+ return "", fmt.Errorf("write temporary Maven toolchains file:
%w", err)
+ }
+ return filename, nil
+}
diff --git a/internal/snapshots/reconcile.go b/internal/snapshots/reconcile.go
new file mode 100644
index 0000000..168e125
--- /dev/null
+++ b/internal/snapshots/reconcile.go
@@ -0,0 +1,184 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package snapshots
+
+import (
+ "context"
+ "errors"
+ "fmt"
+ "io"
+ "os"
+ "os/exec"
+ "path/filepath"
+)
+
+type Mode string
+
+const (
+ ModeCheck Mode = "check"
+ ModeUpdate Mode = "update"
+)
+
+type Result struct {
+ Target string
+ Changes []Change
+}
+
+func (result Result) HasBlockingChanges() bool {
+ return result.BlockingChangeCount() > 0
+}
+
+func (result Result) BlockingChangeCount() int {
+ count := 0
+ for _, change := range result.Changes {
+ if change.IsBlocking() {
+ count++
+ }
+ }
+ return count
+}
+
+func Reconcile(
+ ctx context.Context,
+ repositoryRoot, language string,
+ mode Mode,
+ stdout, stderr io.Writer,
+) (Result, error) {
+ if mode != ModeCheck && mode != ModeUpdate {
+ return Result{}, fmt.Errorf("unsupported reconciliation mode
%q", mode)
+ }
+ generator, found := generators[language]
+ if !found {
+ return Result{}, fmt.Errorf("unsupported snapshot language %q",
language)
+ }
+ for _, requirement := range generator.requirements {
+ if _, err := exec.LookPath(requirement); err != nil {
+ return Result{}, fmt.Errorf("required command %q is not
installed or not on PATH", requirement)
+ }
+ }
+
+ workspace, err := os.MkdirTemp("", "datasketches-tck-"+language+"-")
+ if err != nil {
+ return Result{}, fmt.Errorf("create generator workspace: %w",
err)
+ }
+ defer func() { _ = os.RemoveAll(workspace) }()
+
+ generated := filepath.Join(workspace, "generated")
+ runner := commandRunner{stdout: stdout, stderr: stderr}
+ if err := generator.run(ctx, workspace, generated, runner); err != nil {
+ return Result{}, fmt.Errorf("generate %s snapshots: %w",
language, err)
+ }
+
+ target := filepath.Join(repositoryRoot, "serialization", language,
"snapshots")
+ changes, err := compareDirectories(target, generated,
generator.stability)
+ if err != nil {
+ return Result{}, err
+ }
+
+ result := Result{Target: target, Changes: changes}
+ if mode == ModeUpdate && len(changes) > 0 {
+ if err := replaceDirectory(target, generated); err != nil {
+ return Result{}, err
+ }
+ }
+ return result, nil
+}
+
+func replaceDirectory(target, generated string) error {
+ parent := filepath.Dir(target)
+ if err := os.MkdirAll(parent, 0o755); err != nil {
+ return fmt.Errorf("create snapshot parent directory: %w", err)
+ }
+
+ transaction, err := os.MkdirTemp(parent,
"."+filepath.Base(target)+"-tck-")
+ if err != nil {
+ return fmt.Errorf("create snapshot update transaction: %w", err)
+ }
+ removeTransaction := true
+ defer func() {
+ if removeTransaction {
+ _ = os.RemoveAll(transaction)
+ }
+ }()
+
+ next := filepath.Join(transaction, "next")
+ if err := copyDirectory(generated, next); err != nil {
+ return fmt.Errorf("stage generated snapshots: %w", err)
+ }
+
+ previous := filepath.Join(transaction, "previous")
+ hadTarget := false
+ info, err := os.Lstat(target)
+ switch {
+ case err == nil:
+ if !info.IsDir() || info.Mode()&os.ModeSymlink != 0 {
+ return fmt.Errorf("replace snapshots: %s is not a
directory", target)
+ }
+ hadTarget = true
+ if err := os.Rename(target, previous); err != nil {
+ return fmt.Errorf("preserve current snapshots: %w", err)
+ }
+ case os.IsNotExist(err):
+ case err != nil:
+ return fmt.Errorf("inspect snapshots before update: %w", err)
+ }
+
+ if err := os.Rename(next, target); err != nil {
+ if !hadTarget {
+ return fmt.Errorf("install generated snapshots: %w",
err)
+ }
+ if restoreErr := os.Rename(previous, target); restoreErr == nil
{
+ return fmt.Errorf("install generated snapshots: %w",
err)
+ } else {
+ removeTransaction = false
+ return fmt.Errorf(
+ "install generated snapshots: %w; restoring
previous snapshots also failed: %v; previous files remain at %s",
+ err,
+ restoreErr,
+ previous,
+ )
+ }
+ }
+
+ if hadTarget {
+ if err := os.RemoveAll(previous); err != nil && !errors.Is(err,
os.ErrNotExist) {
+ return fmt.Errorf("remove previous snapshots after
update: %w", err)
+ }
+ }
+ return nil
+}
+
+func copyDirectory(source, destination string) error {
+ files, err := regularFiles(source)
+ if err != nil {
+ return err
+ }
+ if err := os.MkdirAll(destination, 0o755); err != nil {
+ return err
+ }
+ for relative, file := range files {
+ output := filepath.Join(destination,
filepath.FromSlash(relative))
+ if err := os.MkdirAll(filepath.Dir(output), 0o755); err != nil {
+ return err
+ }
+ if err := copyFile(file.filename, output); err != nil {
+ return err
+ }
+ }
+ return nil
+}
diff --git a/internal/snapshots/runner.go b/internal/snapshots/runner.go
new file mode 100644
index 0000000..91e3759
--- /dev/null
+++ b/internal/snapshots/runner.go
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package snapshots
+
+import (
+ "context"
+ "fmt"
+ "os/exec"
+ "strings"
+)
+
+func (runner commandRunner) run(ctx context.Context, directory, name string,
arguments ...string) error {
+ commandLine := strings.Join(append([]string{name}, arguments...), " ")
+ if _, err := fmt.Fprintf(runner.stdout, "$ %s\n", commandLine); err !=
nil {
+ return fmt.Errorf("write command trace: %w", err)
+ }
+
+ command := exec.CommandContext(ctx, name, arguments...)
+ command.Dir = directory
+ command.Stdout = runner.stdout
+ command.Stderr = runner.stderr
+ if err := command.Run(); err != nil {
+ return fmt.Errorf("run %s: %w", commandLine, err)
+ }
+ return nil
+}
+
+func cloneAtCommit(
+ ctx context.Context,
+ runner commandRunner,
+ repository, commit, destination string,
+) error {
+ if err := runner.run(ctx, "", "git", "init", "--quiet", destination);
err != nil {
+ return err
+ }
+ if err := runner.run(ctx, "", "git", "-C", destination, "remote",
"add", "origin", repository); err != nil {
+ return err
+ }
+ if err := runner.run(ctx, "", "git", "-C", destination, "fetch",
"--depth", "1", "--no-tags", "origin", commit); err != nil {
+ return err
+ }
+ if err := runner.run(ctx, "", "git", "-C", destination, "checkout",
"--quiet", "--detach", "FETCH_HEAD"); err != nil {
+ return err
+ }
+ return nil
+}
diff --git a/internal/snapshots/stability.go b/internal/snapshots/stability.go
new file mode 100644
index 0000000..7399c39
--- /dev/null
+++ b/internal/snapshots/stability.go
@@ -0,0 +1,102 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package snapshots
+
+import (
+ "path/filepath"
+ "regexp"
+ "strconv"
+ "strings"
+)
+
+type Stability string
+
+const (
+ Stable Stability = "stable"
+ Unstable Stability = "unstable"
+)
+
+var countPattern = regexp.MustCompile(`_n([0-9]+)(?:_|$)`)
+
+// The classifications below follow the project discussion at
+//
https://github.com/apache/datasketches-rust/issues/10#issuecomment-3663796398
+// and the repeated-generation inventory recorded at
+// https://www.mail-archive.com/dev%40datasketches.apache.org/msg04302.html.
+// They are intentionally source-specific: for example, the pinned Go KLL
+// generator enables its deterministic test offset, while C++ and Java do not.
+
+func cppStability(path string) Stability {
+ if cppOrJavaUnstable(filepath.Base(path)) {
+ return Unstable
+ }
+ return Stable
+}
+
+func javaStability(path string) Stability {
+ if cppOrJavaUnstable(filepath.Base(path)) {
+ return Unstable
+ }
+ return Stable
+}
+
+func goStability(path string) Stability {
+ name := filepath.Base(path)
+ switch {
+ case strings.HasPrefix(name, "bf_"):
+ return Unstable
+ case strings.HasPrefix(name, "req_float_") && countAtLeast(name, 100):
+ return Unstable
+ case strings.HasPrefix(name, "reservoir_") && strings.Contains(name,
"_sampling_"):
+ return Unstable
+ case varOptUnstable(name):
+ return Unstable
+ default:
+ return Stable
+ }
+}
+
+func cppOrJavaUnstable(name string) bool {
+ switch {
+ case strings.HasPrefix(name, "bf_"):
+ return true
+ case (strings.HasPrefix(name, "kll_") || strings.HasPrefix(name,
"quantiles_")) && countAtLeast(name, 1000):
+ return true
+ case strings.HasPrefix(name, "req_float_") && countAtLeast(name, 100):
+ return true
+ case varOptUnstable(name):
+ return true
+ default:
+ return false
+ }
+}
+
+func varOptUnstable(name string) bool {
+ if !strings.HasPrefix(name, "varopt_") {
+ return false
+ }
+ return strings.Contains(name, "_sampling_") || countAtLeast(name, 100)
+}
+
+func countAtLeast(name string, minimum int) bool {
+ match := countPattern.FindStringSubmatch(name)
+ if len(match) != 2 {
+ return false
+ }
+ count, err := strconv.Atoi(match[1])
+ return err == nil && count >= minimum
+}
diff --git a/internal/snapshots/stability_test.go
b/internal/snapshots/stability_test.go
new file mode 100644
index 0000000..bcd9836
--- /dev/null
+++ b/internal/snapshots/stability_test.go
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package snapshots
+
+import (
+ "testing"
+
+ "github.com/stretchr/testify/require"
+)
+
+func TestSnapshotStability(t *testing.T) {
+ t.Parallel()
+
+ tests := []struct {
+ name string
+ stability func(string) Stability
+ path string
+ expected Stability
+ }{
+ {name: "cpp deterministic theta", stability: cppStability,
path: "theta_n1000000_cpp.sk", expected: Stable},
+ {name: "cpp bloom filter seed", stability: cppStability, path:
"bf_n0_h3_cpp.sk", expected: Unstable},
+ {name: "cpp exact KLL", stability: cppStability, path:
"kll_long_n100_cpp.sk", expected: Stable},
+ {name: "cpp compacted KLL", stability: cppStability, path:
"kll_long_n1000_cpp.sk", expected: Unstable},
+ {name: "cpp exact REQ", stability: cppStability, path:
"req_float_n10_cpp.sk", expected: Stable},
+ {name: "cpp compacted REQ", stability: cppStability, path:
"req_float_n100_cpp.sk", expected: Unstable},
+ {name: "java compacted quantiles", stability: javaStability,
path: "quantiles_string_n1000_java.sk", expected: Unstable},
+ {name: "java varopt exact mode", stability: javaStability,
path: "varopt_sketch_long_n10_java.sk", expected: Stable},
+ {name: "java varopt sampling mode", stability: javaStability,
path: "varopt_sketch_long_n100_java.sk", expected: Unstable},
+ {name: "go deterministic test KLL", stability: goStability,
path: "kll_float_n1000000_go.sk", expected: Stable},
+ {name: "go bloom filter seed", stability: goStability, path:
"bf_byte_array_n10000_h3_go.sk", expected: Unstable},
+ {name: "go reservoir exact mode", stability: goStability, path:
"reservoir_items_long_exact_n128_k128_go.sk", expected: Stable},
+ {name: "go reservoir sampling mode", stability: goStability,
path: "reservoir_items_long_sampling_n1000_k128_go.sk", expected: Unstable},
+ {name: "go compacted REQ", stability: goStability, path:
"req_float_n100_go.sk", expected: Unstable},
+ {name: "go varopt union sampling", stability: goStability,
path: "varopt_union_double_sampling_go.sk", expected: Unstable},
+ }
+
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ t.Parallel()
+ require.Equal(t, test.expected,
test.stability(test.path), test.path)
+ })
+ }
+}
diff --git a/mise.toml b/mise.toml
new file mode 100644
index 0000000..e17c8f8
--- /dev/null
+++ b/mise.toml
@@ -0,0 +1,33 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+[tools]
+cmake = "4.4.2"
+go = "1.26.5"
+golangci-lint = "2.12.2"
+java = "temurin-25.0.2+10.0.LTS"
+maven = "3.9.16"
+
+[tasks.tck]
+description = "Run the repository-local DataSketches TCK CLI"
+dir = "{{ cwd }}"
+env = { TCK_REPOSITORY_ROOT = "{{ config_root }}" }
+run = 'go run "$MISE_PROJECT_ROOT/cmd/tck"'
+
+[tasks."test:update-snapshots"]
+description = "Update Go test snapshots"
+dir = "{{ config_root }}"
+env = { UPDATE_SNAPS = "always" }
+run = "go test -count=1 ./..."
diff --git a/pyproject.toml b/pyproject.toml
deleted file mode 100644
index 0bf73f0..0000000
--- a/pyproject.toml
+++ /dev/null
@@ -1,27 +0,0 @@
-[project]
-name = "datasketches-tck"
-version = "0.0.0"
-requires-python = ">=3.14,<3.15"
-classifiers = ["Private :: Do Not Upload"]
-dependencies = ["typer"]
-
-[dependency-groups]
-dev = [
- "pyright",
- "ruff",
-]
-
-[build-system]
-requires = ["uv_build>=0.11.31,<0.12"]
-build-backend = "uv_build"
-
-[tool.uv]
-required-version = ">=0.11.31"
-
-[tool.uv.build-backend]
-module-root = "tools"
-module-name = "tck"
-
-[tool.ruff]
-indent-width = 2
-target-version = "py314"
diff --git a/serialization/cpp/generator.py b/serialization/cpp/generator.py
deleted file mode 100755
index 8f2ecd8..0000000
--- a/serialization/cpp/generator.py
+++ /dev/null
@@ -1,101 +0,0 @@
-#!/usr/bin/env python3
-
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-import shutil
-
-import tck
-import typer
-
-
-def main():
- print("--- Generating C++ Test Data ---")
-
- # 1. Check prerequisites
- tck.check_command_installed("git")
- tck.check_command_installed("cmake")
- tck.check_command_installed("ctest")
-
- # 2. Define paths
- repository_dir = tck.repository_root()
- temp_dir = repository_dir / "tmp_datasketches_cpp"
- output_dir = repository_dir / "serialization" / "cpp" / "snapshots"
-
- # 3. Setup temporary directory
- if temp_dir.exists():
- print(f"Removing existing temporary directory: {temp_dir}")
- shutil.rmtree(temp_dir)
-
- temp_dir.mkdir()
-
- # 4. Clone repository
- repo_url = "https://github.com/apache/datasketches-cpp.git"
- commit = "401423367055acdf7502e8ed3126730a08039d91"
- tck.run_command(
- [
- "git",
- "clone",
- "--depth",
- "1",
- "--revision",
- commit,
- "--single-branch",
- repo_url,
- str(temp_dir),
- ]
- )
-
- # 5. Build and Run CMake
- build_dir = temp_dir / "build"
- build_dir.mkdir(exist_ok=True)
-
- # Configure: Add CMAKE_BUILD_TYPE for single-config generators (Ninja/Make)
- tck.run_command(
- ["cmake", "..", "-DGENERATE=true", "-DCMAKE_BUILD_TYPE=Release"],
cwd=build_dir
- )
-
- # Build: Release config
- tck.run_command(["cmake", "--build", ".", "--config", "Release"],
cwd=build_dir)
-
- # Test: Use ctest which is more portable than 'cmake --target test' (VS uses
RUN_TESTS)
- # --output-on-failure helps debug if a specific test fails
- tck.run_command(["ctest", "-C", "Release", "--output-on-failure"],
cwd=build_dir)
-
- # 6. Copy generated files
- # The instructions say: cp datasketches-cpp/build/*/test/*_cpp.sk
serialization_test_data/cpp_generated_files
- # We need to find where they are exactly.
- # It seems they might be in build/test/ or subdirectories depending on
generator.
-
- print(f"Copying files to {output_dir}")
- output_dir.mkdir(parents=True, exist_ok=True)
-
- files_copied = 0
-
- for file_path in build_dir.rglob("*_cpp.sk"):
- shutil.copy2(file_path, output_dir)
- print(f"Copied: {file_path.name}")
- files_copied += 1
-
- if files_copied == 0:
- print("Warning: No *_cpp.sk files were found to copy.")
- else:
- print(f"Successfully copied {files_copied} files.")
-
-
-if __name__ == "__main__":
- typer.run(main)
diff --git a/serialization/go/generator.py b/serialization/go/generator.py
deleted file mode 100755
index 6586f2c..0000000
--- a/serialization/go/generator.py
+++ /dev/null
@@ -1,92 +0,0 @@
-#!/usr/bin/env python3
-
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-import shutil
-import sys
-
-import tck
-import typer
-
-
-def main():
- print("--- Generating Go Test Data ---")
-
- # 1. Check prerequisites
- tck.check_command_installed("git")
- tck.check_command_installed("go")
- tck.check_command_installed("make")
-
- # 2. Define paths
- repository_dir = tck.repository_root()
- temp_dir = repository_dir / "tmp_datasketches_go"
- output_dir = repository_dir / "serialization" / "go" / "snapshots"
-
- # 3. Setup temporary directory
- if temp_dir.exists():
- print(f"Removing existing temporary directory: {temp_dir}")
- shutil.rmtree(temp_dir)
-
- temp_dir.mkdir()
-
- # 4. Clone repository
- repo_url = "https://github.com/apache/datasketches-go.git"
- commit = "730c0ca31e00b8becf8b70591ae8ca73954912d0"
- tck.run_command(
- [
- "git",
- "clone",
- "--depth",
- "1",
- "--revision",
- commit,
- "--single-branch",
- repo_url,
- str(temp_dir),
- ]
- )
-
- # 5. Generate files
- tck.run_command(["make", "generate-go-snapshots"], cwd=temp_dir)
-
- # 6. Copy generated files
- generated_files_dir = temp_dir / "serialization_test_data" /
"go_generated_files"
-
- if not generated_files_dir.exists():
- print(
- f"Error: Expected generated files directory not found at
{generated_files_dir}"
- )
- sys.exit(1)
-
- print(f"Copying files from {generated_files_dir} to {output_dir}")
- output_dir.mkdir(parents=True, exist_ok=True)
-
- files_copied = 0
- for file_path in generated_files_dir.glob("*.sk"):
- shutil.copy2(file_path, output_dir)
- print(f"Copied: {file_path.name}")
- files_copied += 1
-
- if files_copied == 0:
- print("Warning: No .sk files were found to copy.")
- else:
- print(f"Successfully copied {files_copied} files.")
-
-
-if __name__ == "__main__":
- typer.run(main)
diff --git a/serialization/java/generator.py b/serialization/java/generator.py
deleted file mode 100755
index 7fc6383..0000000
--- a/serialization/java/generator.py
+++ /dev/null
@@ -1,98 +0,0 @@
-#!/usr/bin/env python3
-
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-import os
-import shutil
-import sys
-
-import tck
-import typer
-
-
-def main():
- print("--- Generating Java Test Data ---")
-
- # 1. Check prerequisites
- tck.check_command_installed("git")
- tck.check_command_installed("java")
- mvn_cmd_name = "mvn"
- if os.name == "nt":
- mvn_cmd_name = "mvn.cmd"
- tck.check_command_installed(mvn_cmd_name)
-
- # 2. Define paths
- repository_dir = tck.repository_root()
- temp_dir = repository_dir / "tmp_datasketches_java"
- output_dir = repository_dir / "serialization" / "java" / "snapshots"
-
- # 3. Setup temporary directory
- if temp_dir.exists():
- print(f"Removing existing temporary directory: {temp_dir}")
- shutil.rmtree(temp_dir)
-
- temp_dir.mkdir()
-
- # 4. Clone repository
- repo_url = "https://github.com/apache/datasketches-java.git"
- branch = "9.0.0"
- tck.run_command(
- [
- "git",
- "clone",
- "--depth",
- "1",
- "--branch",
- branch,
- "--single-branch",
- repo_url,
- str(temp_dir),
- ]
- )
-
- # 5. Run Maven to generate files
- mvn_cmd = [mvn_cmd_name, "test", "-P", "generate-java-files"]
- use_shell = os.name == "nt" # Windows
- tck.run_command(mvn_cmd, cwd=temp_dir, shell=use_shell)
-
- # 6. Copy generated files
- generated_files_dir = temp_dir / "serialization_test_data" /
"java_generated_files"
-
- if not generated_files_dir.exists():
- print(
- f"Error: Expected generated files directory not found at
{generated_files_dir}"
- )
- sys.exit(1)
-
- print(f"Copying files from {generated_files_dir} to {output_dir}")
- output_dir.mkdir(parents=True, exist_ok=True)
-
- files_copied = 0
- for file_path in generated_files_dir.glob("*.sk"):
- shutil.copy2(file_path, output_dir)
- print(f"Copied: {file_path.name}")
- files_copied += 1
-
- if files_copied == 0:
- print("Warning: No .sk files were found to copy.")
- else:
- print(f"Successfully copied {files_copied} files.")
-
-
-if __name__ == "__main__":
- typer.run(main)
diff --git a/tools/tck/__init__.py b/tools/tck/__init__.py
deleted file mode 100644
index 9055ced..0000000
--- a/tools/tck/__init__.py
+++ /dev/null
@@ -1,49 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-import shutil
-import subprocess
-import sys
-from pathlib import Path
-
-
-def repository_root():
- """Returns the root directory of the repository."""
- return Path(__file__).resolve().parents[2]
-
-
-def check_command_installed(command):
- """Checks if a command is available in the system path."""
- if shutil.which(command) is None:
- print(f"Error: '{command}' is not installed or not in PATH.")
- sys.exit(1)
-
-
-def run_command(command, cwd=None, shell=False):
- """Runs a shell command, streaming output to stdout/stderr."""
- cmd_str = " ".join(command) if isinstance(command, list) else command
- print(f"Running: {cmd_str}")
- sys.stdout.flush() # Ensure 'Running' message appears before command output
- try:
- # Don't capture output; let it stream to sys.stdout/sys.stderr
- subprocess.check_call(command, cwd=cwd, stderr=subprocess.STDOUT,
shell=shell)
- except subprocess.CalledProcessError as e:
- print(f"Error running command: {e}")
- print("--- OUTPUT ---")
- print(e.stdout)
- print("--- END OUTPUT ---")
- sys.exit(1)
diff --git a/uv.lock b/uv.lock
deleted file mode 100644
index bf6eae9..0000000
--- a/uv.lock
+++ /dev/null
@@ -1,167 +0,0 @@
-version = 1
-revision = 3
-requires-python = "==3.14.*"
-
-[[package]]
-name = "annotated-doc"
-version = "0.0.4"
-source = { registry = "https://pypi.org/simple" }
-sdist = { url =
"https://files.pythonhosted.org/packages/57/ba/046ceea27344560984e26a590f90bc7f4a75b06701f653222458922b558c/annotated_doc-0.0.4.tar.gz",
hash =
"sha256:fbcda96e87e9c92ad167c2e53839e57503ecfda18804ea28102353485033faa4", size
= 7288, upload-time = "2025-11-10T22:07:42.062Z" }
-wheels = [
- { url =
"https://files.pythonhosted.org/packages/1e/d3/26bf1008eb3d2daa8ef4cacc7f3bfdc11818d111f7e2d0201bc6e3b49d45/annotated_doc-0.0.4-py3-none-any.whl",
hash =
"sha256:571ac1dc6991c450b25a9c2d84a3705e2ae7a53467b5d111c24fa8baabbed320", size
= 5303, upload-time = "2025-11-10T22:07:40.673Z" },
-]
-
-[[package]]
-name = "colorama"
-version = "0.4.6"
-source = { registry = "https://pypi.org/simple" }
-sdist = { url =
"https://files.pythonhosted.org/packages/d8/53/6f443c9a4a8358a93a6792e2acffb9d9d5cb0a5cfd8802644b7b1c9a02e4/colorama-0.4.6.tar.gz",
hash =
"sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44", size
= 27697, upload-time = "2022-10-25T02:36:22.414Z" }
-wheels = [
- { url =
"https://files.pythonhosted.org/packages/d1/d6/3965ed04c63042e047cb6a3e6ed1a63a35087b6a609aa3a15ed8ac56c221/colorama-0.4.6-py2.py3-none-any.whl",
hash =
"sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6", size
= 25335, upload-time = "2022-10-25T02:36:20.889Z" },
-]
-
-[[package]]
-name = "datasketches-tck"
-version = "0.0.0"
-source = { editable = "." }
-dependencies = [
- { name = "typer" },
-]
-
-[package.dev-dependencies]
-dev = [
- { name = "pyright" },
- { name = "ruff" },
-]
-
-[package.metadata]
-requires-dist = [{ name = "typer" }]
-
-[package.metadata.requires-dev]
-dev = [
- { name = "pyright" },
- { name = "ruff" },
-]
-
-[[package]]
-name = "markdown-it-py"
-version = "4.2.0"
-source = { registry = "https://pypi.org/simple" }
-dependencies = [
- { name = "mdurl" },
-]
-sdist = { url =
"https://files.pythonhosted.org/packages/06/ff/7841249c247aa650a76b9ee4bbaeae59370dc8bfd2f6c01f3630c35eb134/markdown_it_py-4.2.0.tar.gz",
hash =
"sha256:04a21681d6fbb623de53f6f364d352309d4094dd4194040a10fd51833e418d49", size
= 82454, upload-time = "2026-05-07T12:08:28.36Z" }
-wheels = [
- { url =
"https://files.pythonhosted.org/packages/b3/81/4da04ced5a082363ecfa159c010d200ecbd959ae410c10c0264a38cac0f5/markdown_it_py-4.2.0-py3-none-any.whl",
hash =
"sha256:9f7ebbcd14fe59494226453aed97c1070d83f8d24b6fc3a3bcf9a38092641c4a", size
= 91687, upload-time = "2026-05-07T12:08:27.182Z" },
-]
-
-[[package]]
-name = "mdurl"
-version = "0.1.2"
-source = { registry = "https://pypi.org/simple" }
-sdist = { url =
"https://files.pythonhosted.org/packages/d6/54/cfe61301667036ec958cb99bd3efefba235e65cdeb9c84d24a8293ba1d90/mdurl-0.1.2.tar.gz",
hash =
"sha256:bb413d29f5eea38f31dd4754dd7377d4465116fb207585f97bf925588687c1ba", size
= 8729, upload-time = "2022-08-14T12:40:10.846Z" }
-wheels = [
- { url =
"https://files.pythonhosted.org/packages/b3/38/89ba8ad64ae25be8de66a6d463314cf1eb366222074cfda9ee839c56a4b4/mdurl-0.1.2-py3-none-any.whl",
hash =
"sha256:84008a41e51615a49fc9966191ff91509e3c40b939176e643fd50a5c2196b8f8", size
= 9979, upload-time = "2022-08-14T12:40:09.779Z" },
-]
-
-[[package]]
-name = "nodeenv"
-version = "1.10.0"
-source = { registry = "https://pypi.org/simple" }
-sdist = { url =
"https://files.pythonhosted.org/packages/24/bf/d1bda4f6168e0b2e9e5958945e01910052158313224ada5ce1fb2e1113b8/nodeenv-1.10.0.tar.gz",
hash =
"sha256:996c191ad80897d076bdfba80a41994c2b47c68e224c542b48feba42ba00f8bb", size
= 55611, upload-time = "2025-12-20T14:08:54.006Z" }
-wheels = [
- { url =
"https://files.pythonhosted.org/packages/88/b2/d0896bdcdc8d28a7fc5717c305f1a861c26e18c05047949fb371034d98bd/nodeenv-1.10.0-py2.py3-none-any.whl",
hash =
"sha256:5bb13e3eed2923615535339b3c620e76779af4cb4c6a90deccc9e36b274d3827", size
= 23438, upload-time = "2025-12-20T14:08:52.782Z" },
-]
-
-[[package]]
-name = "pygments"
-version = "2.20.0"
-source = { registry = "https://pypi.org/simple" }
-sdist = { url =
"https://files.pythonhosted.org/packages/c3/b2/bc9c9196916376152d655522fdcebac55e66de6603a76a02bca1b6414f6c/pygments-2.20.0.tar.gz",
hash =
"sha256:6757cd03768053ff99f3039c1a36d6c0aa0b263438fcab17520b30a303a82b5f", size
= 4955991, upload-time = "2026-03-29T13:29:33.898Z" }
-wheels = [
- { url =
"https://files.pythonhosted.org/packages/f4/7e/a72dd26f3b0f4f2bf1dd8923c85f7ceb43172af56d63c7383eb62b332364/pygments-2.20.0-py3-none-any.whl",
hash =
"sha256:81a9e26dd42fd28a23a2d169d86d7ac03b46e2f8b59ed4698fb4785f946d0176", size
= 1231151, upload-time = "2026-03-29T13:29:30.038Z" },
-]
-
-[[package]]
-name = "pyright"
-version = "1.1.411"
-source = { registry = "https://pypi.org/simple" }
-dependencies = [
- { name = "nodeenv" },
- { name = "typing-extensions" },
-]
-sdist = { url =
"https://files.pythonhosted.org/packages/7e/ab/265f7dc69d28113ebba19092e57b075f41543b2ed048429c5f56e2b88eac/pyright-1.1.411.tar.gz",
hash =
"sha256:d885a0551f2e763b089a02702174e7f4ba77548cddabc972ab86d1f7f1b0f998", size
= 4112861, upload-time = "2026-06-25T02:14:06.37Z" }
-wheels = [
- { url =
"https://files.pythonhosted.org/packages/0a/49/385be530a6a5b78d1cbcd5c2e38debc8959a2fc6bdb716f4e581002979fc/pyright-1.1.411-py3-none-any.whl",
hash =
"sha256:dc7c72a8e2700c55baa127554040e067041ea53ccfd50bf96308cc4291c7d5d9", size
= 6181526, upload-time = "2026-06-25T02:14:04.691Z" },
-]
-
-[[package]]
-name = "rich"
-version = "15.0.0"
-source = { registry = "https://pypi.org/simple" }
-dependencies = [
- { name = "markdown-it-py" },
- { name = "pygments" },
-]
-sdist = { url =
"https://files.pythonhosted.org/packages/c0/8f/0722ca900cc807c13a6a0c696dacf35430f72e0ec571c4275d2371fca3e9/rich-15.0.0.tar.gz",
hash =
"sha256:edd07a4824c6b40189fb7ac9bc4c52536e9780fbbfbddf6f1e2502c31b068c36", size
= 230680, upload-time = "2026-04-12T08:24:00.75Z" }
-wheels = [
- { url =
"https://files.pythonhosted.org/packages/82/3b/64d4899d73f91ba49a8c18a8ff3f0ea8f1c1d75481760df8c68ef5235bf5/rich-15.0.0-py3-none-any.whl",
hash =
"sha256:33bd4ef74232fb73fe9279a257718407f169c09b78a87ad3d296f548e27de0bb", size
= 310654, upload-time = "2026-04-12T08:24:02.83Z" },
-]
-
-[[package]]
-name = "ruff"
-version = "0.16.0"
-source = { registry = "https://pypi.org/simple" }
-sdist = { url =
"https://files.pythonhosted.org/packages/4d/94/1e5e4967626faf12fa56999cd6222dff6992ceb086ad7945756baf70c7a7/ruff-0.16.0.tar.gz",
hash =
"sha256:e460aafd5495ec89efaa6ced2e4a9a581116451e1c88b9d37ef497e0f8e93982", size
= 4790557, upload-time = "2026-07-23T19:11:30.981Z" }
-wheels = [
- { url =
"https://files.pythonhosted.org/packages/4b/81/1c8818fee7ce1a04cd7d1b3172e0a8f8e4f1dc4feb7fc390e16daa8af323/ruff-0.16.0-py3-none-linux_armv6l.whl",
hash =
"sha256:e5115729eb08c585e5121978ba5d5b60caeae394ce21b9fb5e6cd33a1c6c9b1e", size
= 10754633, upload-time = "2026-07-23T19:10:46.415Z" },
- { url =
"https://files.pythonhosted.org/packages/23/df/beaf59c09d68db84304d555f188b276a77132a5d5b0b67a5c762aa143628/ruff-0.16.0-py3-none-macosx_10_12_x86_64.whl",
hash =
"sha256:3c954b1d580bfa035b41654f7858cc7e71d5fc3ac5b723dd62bd9133830ed522", size
= 10969164, upload-time = "2026-07-23T19:10:50.271Z" },
- { url =
"https://files.pythonhosted.org/packages/42/ce/741cd197496a1abbf51352710fd15ed995d2a2be87189c1da26a450d6e83/ruff-0.16.0-py3-none-macosx_11_0_arm64.whl",
hash =
"sha256:e01c21d10eb1b29f47b7454e1f4056db9a3f0260c646aa88457c610291db9f81", size
= 10488846, upload-time = "2026-07-23T19:10:52.639Z" },
- { url =
"https://files.pythonhosted.org/packages/52/2a/a2db8e88cade358f5cdcb05674a917751074109315d014eb6352d9a893f7/ruff-0.16.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl",
hash =
"sha256:6e364e5ed22ed8dc05082fd78e35308618260907ac2d3c1d637b2e682415b6c9", size
= 10889729, upload-time = "2026-07-23T19:10:54.89Z" },
- { url =
"https://files.pythonhosted.org/packages/42/65/62a771694ebd63029dc953e27dbad40e1588bd4860ff9fe881018fddaa49/ruff-0.16.0-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl",
hash =
"sha256:d327b8fc113a1d4421a04f3839d3752057c8dd1ee320223a6f3f52d04ada462a", size
= 10568275, upload-time = "2026-07-23T19:10:56.993Z" },
- { url =
"https://files.pythonhosted.org/packages/3f/e2/ced249fe8af5f086c5c58cc21cc3356d50f32f7401c5df87050c999620a7/ruff-0.16.0-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl",
hash =
"sha256:a9b50c55e263103586b3dcf5f73d479eb8cb5fdb6098fec59a62891dab653717", size
= 11385112, upload-time = "2026-07-23T19:10:59.615Z" },
- { url =
"https://files.pythonhosted.org/packages/87/0b/05154977a8fd69eeb6c103271f55403bfd8711f5c0f8ed07489d95a504e7/ruff-0.16.0-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl",
hash =
"sha256:0ff4a79ce3ec0172f3241943835de1c4cb4e2dcd07f0f8c2d02603dbbbee4b17", size
= 12207008, upload-time = "2026-07-23T19:11:02.154Z" },
- { url =
"https://files.pythonhosted.org/packages/fb/29/98225831a3a1eab0e02f4acc6ca6559a98611dcc68b6965ff4b7234627c1/ruff-0.16.0-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl",
hash =
"sha256:e95c448fca1fb2a18372a9440926c5a6ee789639bb975c72e7ae6d0b04218ab4", size
= 11650842, upload-time = "2026-07-23T19:11:04.557Z" },
- { url =
"https://files.pythonhosted.org/packages/91/66/6bd3cf90500653d55dc0ffc8507aa8300bd49d0214b2e8cb4d3fef2943ba/ruff-0.16.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
hash =
"sha256:4f11a8d11010301d0a398a2fdef67691feca7294da6aef55e2150e8fa2cd520b", size
= 11400718, upload-time = "2026-07-23T19:11:09.233Z" },
- { url =
"https://files.pythonhosted.org/packages/8e/a2/a54eb4eae05d66364050a5d3b8a9c5ef88196531b3cbe7109d873f87f819/ruff-0.16.0-py3-none-manylinux_2_31_riscv64.whl",
hash =
"sha256:48044c678e9cb8698246c99b14aaccfa6601dea7379eb48a6f8f73f7a6d86cd0", size
= 11426177, upload-time = "2026-07-23T19:11:11.994Z" },
- { url =
"https://files.pythonhosted.org/packages/1a/be/16e3eea4b2a478a496919f5e36f17c4559e54620bd3bbac5d6affa068006/ruff-0.16.0-py3-none-musllinux_1_2_aarch64.whl",
hash =
"sha256:7aa0959bad8eb8bef50340154fc9b58678dae31fa4293afa38b44b6e552c0213", size
= 10856126, upload-time = "2026-07-23T19:11:14.221Z" },
- { url =
"https://files.pythonhosted.org/packages/a2/84/252eb8b868a16eec7257c14f504f77537e734b2d69c762e639e588e304a3/ruff-0.16.0-py3-none-musllinux_1_2_armv7l.whl",
hash =
"sha256:28ea2b7df8ebf7f9da6b7d47b230ab48f387c0a29be3b474c4d0740e197bb9af", size
= 10571208, upload-time = "2026-07-23T19:11:16.378Z" },
- { url =
"https://files.pythonhosted.org/packages/21/09/817a482f542f7570cbb4554b26e896610c7114f539b1d9e2d2145bf6bef6/ruff-0.16.0-py3-none-musllinux_1_2_i686.whl",
hash =
"sha256:33a3dfac8c35f81498dea9181bccc2f4c4bc8f1521a1dd9406e77643e0f0fb09", size
= 11063329, upload-time = "2026-07-23T19:11:19.173Z" },
- { url =
"https://files.pythonhosted.org/packages/2e/23/9403c180ca1cb9b1f7335f5c3e5305c09d49ea5b345196682a36028bde4a/ruff-0.16.0-py3-none-musllinux_1_2_x86_64.whl",
hash =
"sha256:a5237a0bda500d30d81b8e07a6973a5cbc772864cbf746ae2f4e8a2e01c9f4ed", size
= 11489751, upload-time = "2026-07-23T19:11:21.74Z" },
- { url =
"https://files.pythonhosted.org/packages/b2/1d/1b2ef7bcde851c78d7f17f1cca13fd6dc695fc4b3d6197941e72cae5b132/ruff-0.16.0-py3-none-win32.whl",
hash =
"sha256:7fab76fa065c873f41ff744347c6e77bcc3dfec4bcc754dc26b63d23c0f7f5fb", size
= 10785885, upload-time = "2026-07-23T19:11:23.947Z" },
- { url =
"https://files.pythonhosted.org/packages/b2/a3/d5e4ef7a56be3f928ffb90b94c25ba7d3cb9c7fe0736aeaaedf361770712/ruff-0.16.0-py3-none-win_amd64.whl",
hash =
"sha256:429c117f022bf481fabd9d551e7a3952b24c65e6ef44337ea09d90bebef14472", size
= 11923141, upload-time = "2026-07-23T19:11:26.409Z" },
- { url =
"https://files.pythonhosted.org/packages/cb/9a/8415f2657cbe200f41a4531ccededf135505a92d4a012229121f885b26f9/ruff-0.16.0-py3-none-win_arm64.whl",
hash =
"sha256:14296fedcd2705c77ab8235439278bbb38f285cf7da5528b00b3e330c3d4872d", size
= 11273407, upload-time = "2026-07-23T19:11:28.705Z" },
-]
-
-[[package]]
-name = "shellingham"
-version = "1.5.4"
-source = { registry = "https://pypi.org/simple" }
-sdist = { url =
"https://files.pythonhosted.org/packages/58/15/8b3609fd3830ef7b27b655beb4b4e9c62313a4e8da8c676e142cc210d58e/shellingham-1.5.4.tar.gz",
hash =
"sha256:8dbca0739d487e5bd35ab3ca4b36e11c4078f3a234bfce294b0a0291363404de", size
= 10310, upload-time = "2023-10-24T04:13:40.426Z" }
-wheels = [
- { url =
"https://files.pythonhosted.org/packages/e0/f9/0595336914c5619e5f28a1fb793285925a8cd4b432c9da0a987836c7f822/shellingham-1.5.4-py2.py3-none-any.whl",
hash =
"sha256:7ecfff8f2fd72616f7481040475a65b2bf8af90a56c89140852d1120324e8686", size
= 9755, upload-time = "2023-10-24T04:13:38.866Z" },
-]
-
-[[package]]
-name = "typer"
-version = "0.27.0"
-source = { registry = "https://pypi.org/simple" }
-dependencies = [
- { name = "annotated-doc" },
- { name = "colorama", marker = "sys_platform == 'win32'" },
- { name = "rich" },
- { name = "shellingham" },
-]
-sdist = { url =
"https://files.pythonhosted.org/packages/37/78/fda3361b56efc27944f24225f6ecd13d96d6fcfe37bd0eb34e2f4c63f9fc/typer-0.27.0.tar.gz",
hash =
"sha256:629bd12ea5d13a17148125d9a264f949eb171fb3f120f9b04d85873cab054fa5", size
= 203430, upload-time = "2026-07-15T19:21:07.007Z" }
-wheels = [
- { url =
"https://files.pythonhosted.org/packages/40/03/26a383c9e58c213199d1aad1c3d353cfc22d4444ec6d2c0bf8ad02523843/typer-0.27.0-py3-none-any.whl",
hash =
"sha256:6f4b27631e47f077871b7dc30e933ec0131c1390fbe0e387ea5574b5bac9ccf1", size
= 122716, upload-time = "2026-07-15T19:21:05.553Z" },
-]
-
-[[package]]
-name = "typing-extensions"
-version = "4.16.0"
-source = { registry = "https://pypi.org/simple" }
-sdist = { url =
"https://files.pythonhosted.org/packages/f6/cc/6253133b5bb138fc3306cebfbda2c520f545d36b5be2c7255cc528bb45d6/typing_extensions-4.16.0.tar.gz",
hash =
"sha256:dc983d19a509c94dba722ee6abd33940f7c05a89e243c47e907eb4db6f1a43e5", size
= 113555, upload-time = "2026-07-02T08:40:05.92Z" }
-wheels = [
- { url =
"https://files.pythonhosted.org/packages/49/d3/b8441a820a491ddfc024b0b0cf0393375b75ea13866d9c66727e54c2fc80/typing_extensions-4.16.0-py3-none-any.whl",
hash =
"sha256:481caa481374e813c1b176ada14e97f1f67a4539ce9cfeb3f350d78d6370c2e8", size
= 45571, upload-time = "2026-07-02T08:40:04.659Z" },
-]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]