From d6814788f2f9084c0252d87c370713aa70c5bcd37691379da90d168356af3c82 Mon Sep 17 00:00:00 2001 From: Sergey Matveev Date: Wed, 26 Nov 2025 19:14:20 +0300 Subject: [PATCH] No need in hex output --- c/lib/cm/default.schema.keks.do | 2 +- go/default.schema.keks.do | 2 +- tcl/keks.tcl | 3 +- tcl/mk-fuzz-inputs | 2 +- tcl/schema.t/generic.t | 310 ++++++++++++-------------------- tcl/schema.t/specs-our.t | 32 ++-- tcl/schema.t/specs-wheres.t | 26 +-- tcl/schema.tcl | 3 +- tcl/test-vector.tcl | 3 +- 9 files changed, 146 insertions(+), 237 deletions(-) diff --git a/c/lib/cm/default.schema.keks.do b/c/lib/cm/default.schema.keks.do index 4134f0b..8decf8c 100644 --- a/c/lib/cm/default.schema.keks.do +++ b/c/lib/cm/default.schema.keks.do @@ -4,4 +4,4 @@ cd ../../../tcl/schemas echo ../schema.tcl $n sed -n "s/^schema-include \(.*\)$/\1/p" <$n } | xargs redo-ifchange -TCLLIBPATH=.. ../schema.tcl $n | xxd -r -p +TCLLIBPATH=.. ../schema.tcl $n diff --git a/go/default.schema.keks.do b/go/default.schema.keks.do index 8fbe538..8333e93 100644 --- a/go/default.schema.keks.do +++ b/go/default.schema.keks.do @@ -4,4 +4,4 @@ cd ../tcl/schemas echo ../schema.tcl $n sed -n "s/^schema-include \(.*\)$/\1/p" <$n } | xargs redo-ifchange -TCLLIBPATH=.. ../schema.tcl $n | xxd -r -p +TCLLIBPATH=.. ../schema.tcl $n diff --git a/tcl/keks.tcl b/tcl/keks.tcl index 4062a09..54c1138 100755 --- a/tcl/keks.tcl +++ b/tcl/keks.tcl @@ -356,5 +356,6 @@ if {[info exists argv0] && ([file tail [info script]] eq [file tail $argv0])} { set buf "" set in [read stdin] eval $in - puts [binary encode hex $buf] + fconfigure stdout -translation binary + puts -nonewline $buf } diff --git a/tcl/mk-fuzz-inputs b/tcl/mk-fuzz-inputs index 65f1eb1..7947d06 100755 --- a/tcl/mk-fuzz-inputs +++ b/tcl/mk-fuzz-inputs @@ -1,7 +1,7 @@ #!/bin/sh -e dump() { - echo "$@" | keks.tcl | xxd -r -p + echo "$@" | keks.tcl } dump 'BIN ""' >bin-empty diff --git a/tcl/schema.t/generic.t b/tcl/schema.t/generic.t index 341dc9b..7051bbb 100755 --- a/tcl/schema.t/generic.t +++ b/tcl/schema.t/generic.t @@ -9,23 +9,20 @@ export TCLLIBPATH=$root cat >schema.tcl <schema.keks -$root/keks.tcl >data.keks.hex <schema.keks +$root/keks.tcl >data.keks <data.keks test_expect_success "type ok" "$SCHEMA_VALIDATE schema.keks e data.keks.hex <data.keks <data.keks test_expect_success "type ok" "$SCHEMA_VALIDATE schema.keks e data.keks.hex <data.keks <data.keks test_expect_success "type !ok" "! $SCHEMA_VALIDATE schema.keks e schema.tcl <schema.keks -$root/keks.tcl >data.keks.hex <schema.keks +$root/keks.tcl >data.keks <data.keks test_expect_success "set ok" "$SCHEMA_VALIDATE schema.keks e data.keks.hex <data.keks <data.keks test_expect_success "set !ok" "! $SCHEMA_VALIDATE schema.keks e data.keks.hex <data.keks <data.keks test_expect_success "set macro" "$SCHEMA_VALIDATE schema.keks e schema.tcl <schema.keks -$root/keks.tcl >data.keks.hex <schema.keks +$root/keks.tcl >data.keks <data.keks test_expect_success "map various" "$SCHEMA_VALIDATE schema.keks e schema.tcl <schema.keks -$root/keks.tcl >data.keks.hex <schema.keks +$root/keks.tcl >data.keks <data.keks test_expect_success "map !of int" "! $SCHEMA_VALIDATE schema.keks e data.keks.hex <data.keks <data.keks test_expect_success "map of int" "$SCHEMA_VALIDATE schema.keks e schema.tcl <schema.keks -$root/keks.tcl >data.keks.hex <schema.keks +$root/keks.tcl >data.keks <data.keks test_expect_success "map of int schema" "$SCHEMA_VALIDATE schema.keks e schema.tcl <schema.keks -$root/keks.tcl >data.keks.hex <schema.keks +$root/keks.tcl >data.keks <data.keks test_expect_success "list various" "$SCHEMA_VALIDATE schema.keks e schema.tcl <schema.keks -$root/keks.tcl >data.keks.hex <schema.keks +$root/keks.tcl >data.keks <data.keks test_expect_success "list !of int" "! $SCHEMA_VALIDATE schema.keks e data.keks.hex <data.keks <data.keks test_expect_success "list of int" "$SCHEMA_VALIDATE schema.keks e schema.tcl <schema.keks -$root/keks.tcl >data.keks.hex <schema.keks +$root/keks.tcl >data.keks <data.keks test_expect_success "list of int schema" "$SCHEMA_VALIDATE schema.keks e schema.keks -$root/keks.tcl >data.keks.hex <schema.keks +$root/keks.tcl >data.keks <data.keks test_expect_success "list take ok" "$SCHEMA_VALIDATE schema.keks e data.keks.hex <data.keks <data.keks test_expect_success "list take bad range" "! $SCHEMA_VALIDATE schema.keks e schema.tcl <schema.keks -$root/keks.tcl >data.keks.hex <schema.keks +$root/keks.tcl >data.keks <data.keks test_expect_success "!only schema" "! $SCHEMA_VALIDATE schema.keks e data.keks.hex <data.keks <data.keks test_expect_success "only schema" "$SCHEMA_VALIDATE schema.keks e schema.keks -$root/keks.tcl >data.keks.hex <schema.keks +$root/keks.tcl >data.keks <data.keks test_expect_success "map exists" "$SCHEMA_VALIDATE schema.keks e data.keks.hex <data.keks <data.keks test_expect_success "map !exists" "! $SCHEMA_VALIDATE schema.keks e schema.tcl <schema.keks -$root/keks.tcl >data.keks.hex <schema.keks +$root/keks.tcl >data.keks <data.keks test_expect_success "map optional" "$SCHEMA_VALIDATE schema.keks e data.keks.hex <data.keks <data.keks test_expect_success "map optional !exists" "$SCHEMA_VALIDATE schema.keks e data.keks.hex <data.keks <data.keks test_expect_success "map optional bad type" "! $SCHEMA_VALIDATE schema.keks e schema.tcl <schema.keks -$root/keks.tcl >data.keks.hex <schema.keks +$root/keks.tcl >data.keks <data.keks test_expect_success "map !!exists" "! $SCHEMA_VALIDATE schema.keks e data.keks.hex <data.keks <data.keks test_expect_success "map !exists" "$SCHEMA_VALIDATE schema.keks e schema.tcl <schema.keks -$root/keks.tcl >data.keks.hex <schema.keks +$root/keks.tcl >data.keks <data.keks test_expect_success "map !len=~ without optional" " ! $SCHEMA_VALIDATE schema.keks e data.keks.hex <data.keks <data.keks test_expect_success "map !len=~ with optional" " ! $SCHEMA_VALIDATE schema.keks e data.keks.hex <data.keks <data.keks test_expect_success "map !len=~" "$SCHEMA_VALIDATE schema.keks e schema.tcl <0}} EOF -$root/schema.tcl schema.tcl | xxd -r -p >schema.keks -$root/keks.tcl >data.keks.hex <schema.keks +$root/keks.tcl >data.keks <data.keks test_expect_success "int !>0" "! $SCHEMA_VALIDATE schema.keks e data.keks.hex <data.keks <data.keks test_expect_success "int >0" "$SCHEMA_VALIDATE schema.keks e schema.tcl <-1000}} EOF -$root/schema.tcl schema.tcl | xxd -r -p >schema.keks -$root/keks.tcl >data.keks.hex <schema.keks +$root/keks.tcl >data.keks <data.keks test_expect_success "int !>-999" "! $SCHEMA_VALIDATE schema.keks e data.keks.hex <data.keks <data.keks test_expect_success "int >-999" "$SCHEMA_VALIDATE schema.keks e -999" "$SCHEMA_VALIDATE schema.keks e schema.tcl <0}} EOF -$root/schema.tcl schema.tcl | xxd -r -p >schema.keks -$root/keks.tcl >data.keks.hex <schema.keks +$root/keks.tcl >data.keks <data.keks test_expect_success "str !>0" "! $SCHEMA_VALIDATE schema.keks e data.keks.hex <data.keks <data.keks test_expect_success "str >0" "$SCHEMA_VALIDATE schema.keks e 0" "$SCHEMA_VALIDATE schema.keks e schema.tcl <0}} EOF -$root/schema.tcl schema.tcl | xxd -r -p >schema.keks -$root/keks.tcl >data.keks.hex <schema.keks +$root/keks.tcl >data.keks <data.keks test_expect_success "list !>0" "! $SCHEMA_VALIDATE schema.keks e data.keks.hex <data.keks <data.keks test_expect_success "list >0" "$SCHEMA_VALIDATE schema.keks e 0" "$SCHEMA_VALIDATE schema.keks e schema.tcl <0}} EOF -$root/schema.tcl schema.tcl | xxd -r -p >schema.keks -$root/keks.tcl >data.keks.hex <schema.keks +$root/keks.tcl >data.keks <data.keks test_expect_success "map !>0" "! $SCHEMA_VALIDATE schema.keks e data.keks.hex <data.keks <data.keks test_expect_success "map >0" "$SCHEMA_VALIDATE schema.keks e 0" "$SCHEMA_VALIDATE schema.keks e schema.tcl <schema.keks -$root/keks.tcl >data.keks.hex <schema.keks +$root/keks.tcl >data.keks <data.keks test_expect_success "map len=0" "$SCHEMA_VALIDATE schema.keks e schema.tcl <schema.keks -$root/keks.tcl >data.keks.hex <schema.keks +$root/keks.tcl >data.keks <data.keks test_expect_success "list len=0" "$SCHEMA_VALIDATE schema.keks e schema.tcl <schema.keks -$root/keks.tcl >data.keks.hex <schema.keks +$root/keks.tcl >data.keks <data.keks test_expect_success "str len=0" "$SCHEMA_VALIDATE schema.keks e schema.tcl <schema.keks -$root/keks.tcl >data.keks.hex <schema.keks +$root/keks.tcl >data.keks <data.keks test_expect_success "int len=0" "$SCHEMA_VALIDATE schema.keks e schema.tcl <schema.keks -$root/keks.tcl >data.keks.hex <schema.keks +$root/keks.tcl >data.keks <data.keks test_expect_success "map len=3" "$SCHEMA_VALIDATE schema.keks e schema.tcl <schema.keks -$root/keks.tcl >data.keks.hex <schema.keks +$root/keks.tcl >data.keks <data.keks test_expect_success "list len=3" "$SCHEMA_VALIDATE schema.keks e schema.tcl <schema.keks -$root/keks.tcl >data.keks.hex <schema.keks +$root/keks.tcl >data.keks <data.keks test_expect_success "str len=3" "$SCHEMA_VALIDATE schema.keks e schema.tcl <schema.keks -$root/keks.tcl >data.keks.hex <schema.keks +$root/keks.tcl >data.keks <data.keks test_expect_success "int len=0" "$SCHEMA_VALIDATE schema.keks e schema.tcl <schema.keks -$root/keks.tcl >data.keks.hex <schema.keks +$root/keks.tcl >data.keks <data.keks test_expect_success "str =" "$SCHEMA_VALIDATE schema.keks e data.keks.hex <data.keks <data.keks test_expect_success "str !=" "! $SCHEMA_VALIDATE schema.keks e schema.tcl <schema.keks -$root/keks.tcl >data.keks.hex <schema.keks +$root/keks.tcl >data.keks <data.keks test_expect_success "str cyrillic =" "$SCHEMA_VALIDATE schema.keks e schema.tcl <schema.keks -$root/keks.tcl >data.keks.hex <schema.keks +$root/keks.tcl >data.keks <data.keks test_expect_success "hexlet =" "$SCHEMA_VALIDATE schema.keks e data.keks.hex <data.keks <data.keks test_expect_success "hexlet !=" "! $SCHEMA_VALIDATE schema.keks e schema.tcl <schema.keks -$root/keks.tcl >data.keks.hex <schema.keks +$root/keks.tcl >data.keks <data.keks test_expect_success "magic =" "$SCHEMA_VALIDATE schema.keks e data.keks.hex <data.keks <data.keks test_expect_success "magic !=" "! $SCHEMA_VALIDATE schema.keks e schema.keks -$root/keks.tcl >data.keks.hex <schema.keks +$root/keks.tcl >data.keks <data.keks test_expect_success "fpr !exists" "$SCHEMA_VALIDATE schema.keks e data.keks.hex <data.keks <data.keks test_expect_success "fpr bad type" "! $SCHEMA_VALIDATE schema.keks e data.keks.hex <data.keks <data.keks test_expect_success "fpr ok" "$SCHEMA_VALIDATE schema.keks e schema.tcl <schema.keks -$root/keks.tcl >data.keks.hex <schema.keks +$root/keks.tcl >data.keks <data.keks test_expect_success "tai64 ok" "$SCHEMA_VALIDATE schema.keks e data.keks.hex <data.keks <data.keks test_expect_success "tai64 !utc" "$SCHEMA_VALIDATE schema.keks e schema.tcl <schema.keks -$root/keks.tcl >data.keks.hex <schema.keks +$root/keks.tcl >data.keks <data.keks test_expect_success "tai64 !!utc" "! $SCHEMA_VALIDATE schema.keks e schema.tcl <schema.keks -$root/keks.tcl >data.keks.hex <schema.keks +$root/keks.tcl >data.keks <data.keks test_expect_success "tai64 prec=s" "$SCHEMA_VALIDATE schema.keks e data.keks.hex <data.keks <data.keks test_expect_success "tai64 !prec=s" "! $SCHEMA_VALIDATE schema.keks e schema.tcl <schema.keks -$root/keks.tcl >data.keks.hex <schema.keks +$root/keks.tcl >data.keks <data.keks test_expect_success "tai64 prec=ms" "$SCHEMA_VALIDATE schema.keks e data.keks.hex <data.keks <data.keks test_expect_success "tai64 !prec=ms" "! $SCHEMA_VALIDATE schema.keks e schema.tcl <schema.keks -$root/keks.tcl >data.keks.hex <schema.keks +$root/keks.tcl >data.keks <data.keks test_expect_success "tai64 prec=us" "$SCHEMA_VALIDATE schema.keks e data.keks.hex <data.keks <data.keks test_expect_success "tai64 !prec=us" "! $SCHEMA_VALIDATE schema.keks e schema.tcl <schema.keks -$root/keks.tcl >data.keks.hex <schema.keks +$root/keks.tcl >data.keks <data.keks test_expect_success "tai64 prec=ns" "$SCHEMA_VALIDATE schema.keks e data.keks.hex <data.keks <data.keks test_expect_success "tai64 prec=ns" "$SCHEMA_VALIDATE schema.keks e data.keks.hex <data.keks <data.keks test_expect_success "tai64 !prec=ns" "! $SCHEMA_VALIDATE schema.keks e schema.tcl <schema.keks -$root/keks.tcl >data.keks.hex <schema.keks +$root/keks.tcl >data.keks <data.keks test_expect_success "tai64 prec=ps" "$SCHEMA_VALIDATE schema.keks e data.keks.hex <data.keks <data.keks test_expect_success "tai64 prec=ps" "$SCHEMA_VALIDATE schema.keks e data.keks.hex <data.keks <data.keks test_expect_success "tai64 !prec=ps" "! $SCHEMA_VALIDATE schema.keks e schema.tcl <schema.keks -$root/keks.tcl >data.keks.hex <schema.keks +$root/keks.tcl >data.keks <data.keks test_expect_success "tai64 prec=fs" "$SCHEMA_VALIDATE schema.keks e data.keks.hex <data.keks <data.keks test_expect_success "tai64 !prec=fs" "! $SCHEMA_VALIDATE schema.keks e schema.tcl <schema.keks -$root/keks.tcl >data.keks.hex <schema.keks +$root/keks.tcl >data.keks <data.keks test_expect_success "tai64 prec=fs" "$SCHEMA_VALIDATE schema.keks e schema.keks.hex <schema.keks <schema.keks -$root/keks.tcl >data.keks.hex <data.keks <data.keks test_expect_success "manual int ranges" "$SCHEMA_VALIDATE schema.keks e our.schema.keks +$root/schema.tcl our.schema.tcl >our.schema.keks -$root/keks.tcl >data.keks.hex <data.keks <data.keks test_expect_success "ok" "$SCHEMA_VALIDATE our.schema.keks our data.keks.hex <data.keks <data.keks test_expect_success "no comment" "$SCHEMA_VALIDATE our.schema.keks our data.keks.hex <data.keks <data.keks test_expect_success "empty comment" "$SCHEMA_VALIDATE our.schema.keks our data.keks.hex <data.keks <data.keks test_expect_success "fpr longer" "! $SCHEMA_VALIDATE our.schema.keks our data.keks.hex <data.keks <data.keks test_expect_success "fpr shorter" "! $SCHEMA_VALIDATE our.schema.keks our data.keks.hex <data.keks <data.keks test_expect_success "v empty" "$SCHEMA_VALIDATE our.schema.keks our data.keks.hex <data.keks <data.keks test_expect_success "a empty" "! $SCHEMA_VALIDATE our.schema.keks our data.keks.hex <data.keks <data.keks test_expect_success "a bad type" "! $SCHEMA_VALIDATE our.schema.keks our data.keks.hex <data.keks <data.keks test_expect_success "fpr no" "! $SCHEMA_VALIDATE our.schema.keks our data.keks.hex <data.keks <data.keks test_expect_success "a no" "! $SCHEMA_VALIDATE our.schema.keks our 0}} EOF -$root/schema.tcl wheres.schema.tcl | xxd -r -p >wheres.schema.keks +$root/schema.tcl wheres.schema.tcl >wheres.schema.keks -$root/keks.tcl >data.keks.hex <data.keks <data.keks test_expect_success "wheres empty" "! $SCHEMA_VALIDATE wheres.schema.keks wheres data.keks.hex <data.keks <data.keks test_expect_success "where empty" "! $SCHEMA_VALIDATE wheres.schema.keks wheres data.keks.hex <data.keks <data.keks test_expect_success "ok" "$SCHEMA_VALIDATE wheres.schema.keks wheres data.keks.hex <data.keks <data.keks test_expect_success "lat negative" "$SCHEMA_VALIDATE wheres.schema.keks wheres data.keks.hex <data.keks <data.keks test_expect_success "lon negative" "$SCHEMA_VALIDATE wheres.schema.keks wheres data.keks.hex <data.keks <data.keks test_expect_success "oob lat" "! $SCHEMA_VALIDATE wheres.schema.keks wheres data.keks.hex <data.keks <data.keks test_expect_success "oob lon" "! $SCHEMA_VALIDATE wheres.schema.keks wheres data.keks.hex <data.keks <data.keks test_expect_success "lon bad len" "! $SCHEMA_VALIDATE wheres.schema.keks wheres