From e0f26f72cc50a1e818623c957fe464d96531b92f Mon Sep 17 00:00:00 2001 From: Juan Cruz Viotti Date: Mon, 26 Aug 2024 19:20:05 -0400 Subject: [PATCH] Revisit `metaschema` command tests Signed-off-by: Juan Cruz Viotti --- src/command_metaschema.cc | 9 +++++---- test/metaschema_pass_cwd.sh | 12 +++++++++++- test/metaschema_pass_single.sh | 7 ++++++- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/command_metaschema.cc b/src/command_metaschema.cc index 44e97cf5..af51e439 100644 --- a/src/command_metaschema.cc +++ b/src/command_metaschema.cc @@ -45,12 +45,13 @@ auto sourcemeta::jsonschema::cli::metaschema( sourcemeta::jsontoolkit::SchemaCompilerEvaluationMode::Fast, std::ref(output))) { log_verbose(options) - << entry.first.string() - << ": The schema is valid with respect to its metaschema\n"; + << "ok: " << std::filesystem::weakly_canonical(entry.first).string() + << "\n matches " << dialect.value() << "\n"; } else { print(output, std::cerr); - std::cerr << entry.first.string() - << ": The schema is NOT valid with respect to its metaschema\n"; + std::cerr << "fail: " + << std::filesystem::weakly_canonical(entry.first).string() + << "\n"; result = false; } } diff --git a/test/metaschema_pass_cwd.sh b/test/metaschema_pass_cwd.sh index 7d647b8a..5a0d189d 100755 --- a/test/metaschema_pass_cwd.sh +++ b/test/metaschema_pass_cwd.sh @@ -21,4 +21,14 @@ cat << 'EOF' > "$TMP/schema_2.json" } EOF -"$1" metaschema --verbose +cd "$TMP" +"$1" metaschema --verbose > "$TMP/output.txt" 2>&1 + +cat << EOF > "$TMP/expected.txt" +ok: $(realpath "$TMP")/schema_1.json + matches http://json-schema.org/draft-04/schema# +ok: $(realpath "$TMP")/schema_2.json + matches http://json-schema.org/draft-04/schema# +EOF + +diff "$TMP/output.txt" "$TMP/expected.txt" diff --git a/test/metaschema_pass_single.sh b/test/metaschema_pass_single.sh index 9244e4b2..a0c1f098 100755 --- a/test/metaschema_pass_single.sh +++ b/test/metaschema_pass_single.sh @@ -14,4 +14,9 @@ cat << 'EOF' > "$TMP/schema.json" } EOF -"$1" metaschema "$TMP/schema.json" +"$1" metaschema "$TMP/schema.json" > "$TMP/output.txt" 2>&1 + +cat << EOF > "$TMP/expected.txt" +EOF + +diff "$TMP/output.txt" "$TMP/expected.txt"