gkalashyan-akv commented on code in PR #15: URL: https://github.com/apache/iceberg-verification/pull/15#discussion_r4165996788
########## Makefile: ########## @@ -0,0 +1,76 @@ +# 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. + +SHELL := bash +PYTHON ?= python3 +PRETTIER := npx --yes [email protected] +FIXTURES := "table-spec/**/*.json" +VENV := .venv +VENV_PYTHON := $(VENV)/bin/python +VENV_STAMP := $(VENV)/.installed + +.PHONY: help install format lint validate test license check clean + +help: ## Show available targets + @grep -E '^[a-zA-Z_-]+:.*## ' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*## "}; {printf " %-10s %s\n", $$1, $$2}' + +$(VENV_STAMP): dev/requirements.txt + $(PYTHON) -m venv $(VENV) + $(VENV_PYTHON) -m pip install --quiet -r dev/requirements.txt + @touch $(VENV_STAMP) + +install: $(VENV_STAMP) ## Create .venv with the dev/ tooling dependencies + +format: ## Format the JSON fixtures in place + $(PRETTIER) --log-level warn --write $(FIXTURES) + +lint: ## Fail if any JSON fixture is not formatted + $(PRETTIER) --check $(FIXTURES) + +validate: $(VENV_STAMP) ## Validate every cases.json against the JSON Schemas + $(VENV_PYTHON) dev/validate-fixtures.py + +# Each malformed fixture is written into a scratch table-spec tree; the validator +# must reject every one. +test: $(VENV_STAMP) ## Check the validator rejects malformed fixtures + @set -e; \ + assert_reject() { \ + d="$$(mktemp -d)"; \ + mkdir -p "$$d/table-spec/types/x"; \ + printf '%s' "$$2" > "$$d/table-spec/types/x/cases.json"; \ + if $(VENV_PYTHON) dev/validate-fixtures.py "$$d" >/dev/null 2>&1; then \ + echo "FAILED: validator accepted a malformed fixture ($$1)"; rm -rf "$$d"; exit 1; \ Review Comment: Non-blocking test-harness improvement: this treats every nonzero exit as the expected rejection and discards the diagnostic, so an import error, syntax error, or failed interpreter launch also counts as a passing case. After installing the dependencies, I reproduced this with `make test VENV_PYTHON=/bin/false`: all eight cases print `ok: rejected` and make exits successfully, although no validation occurs. This behavior is inherited from the old inline helper; the current CI also runs `validate` first, which provides a useful control there. Now that `test` is a standalone target, could it include a known-valid fixture that must succeed and verify the expected validation diagnostic for each malformed case? That would keep a broken validator from producing a green self-test result and distinguish intended rejection from a crash. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
