From 95833d8628890151907b334b2c37d536026baeba Mon Sep 17 00:00:00 2001 From: Marten Hildell Date: Sun, 18 Oct 2026 16:54:31 +0200 Subject: [PATCH 1/2] No compiler notices: flatxml at 5da7bdc, dead code removed, shadowing names renamed Building the command or any test printed notices: flatxml's unused union_of (gone at 5da7bdc), short_name_of and all_skipped (unused), read_options' unused parameter, from_dir in relocate shadowing modelfile's function, a test's src helper shadowed by pathindex, an unused import and two needless mut copies in tests. builtin_files is read by the test alone, so gen_builtin.vsh now writes it into builtin_test.v rather than the library. Co-Authored-By: Claude Opus 5.5 --- CLAUDE.md | 4 +-- arxmodel/builtin.v | 11 +------ arxmodel/builtin_test.v | 11 +++++++ arxmodel/export.v | 12 ++++---- arxmodel/open_test.v | 62 ++++++++++++++++++++-------------------- arxmodel/references.v | 20 +++---------- arxmodel/spec_test.v | 10 +++---- arxmodel/validate_test.v | 1 - cmd/arxmodel/main.v | 12 ++------ cmd/arxmodel/serve.v | 2 +- flatxml/VENDORED | 2 +- flatxml/xsd/resolve.v | 17 ++--------- scripts/gen_builtin.vsh | 37 +++++++++++++++++------- 13 files changed, 93 insertions(+), 108 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index 0b840fe..96a2476 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -43,5 +43,5 @@ v -prod -o bin/arxmodel cmd/arxmodel # the command V3 only; `.v-version` and `.vc-version` pin the toolchain. No `$embed_file`: V3 embeds one only in a -prod build and otherwise reads the build machine's path at run time, so a program vendoring arxmodel fails on its users' machines. The built-in texts are `arxmodel/builtin.v`, generated by -`scripts/gen_builtin.vsh` and pinned to their files by `builtin_test.v`. flatxml is vendored in `flatxml/` by -`scripts/vendor_flatxml.sh`, never edited by hand. +`scripts/gen_builtin.vsh` with `builtin_test.v`, which pins them to their files. flatxml is +vendored in `flatxml/` by `scripts/vendor_flatxml.sh`, never edited by hand. diff --git a/arxmodel/builtin.v b/arxmodel/builtin.v index 97bcdb3..f96c20e 100644 --- a/arxmodel/builtin.v +++ b/arxmodel/builtin.v @@ -302,7 +302,7 @@ const identity_text = '# arxmodel\'s built-in identity rules: how the elements o '# order counts: a reorder is reported. The order of named elements does not count.\n' // flatxml/VENDORED -const flatxml_vendored_text = 'flatxml 83da97ee878cfbe77d0341cc274c57c736f05a52\n' + +const flatxml_vendored_text = 'flatxml 5da7bdc134343ae52239cd1ef2e57231f4becaf0\n' + 'source https://github.com/MartenH/flatxml\n' + 'The library folder at that commit, without its tests. Do not edit; re-vendor.\n' @@ -314,12 +314,3 @@ const vmod_text = 'Module {\n' + '\tlicense: \'MIT\'\n' + '\tdependencies: []\n' + '}\n' - -// builtin_files is every built-in text by the file it was made from. -const builtin_files = { - 'arxmodel/policy.toml': default_policy_text - 'arxmodel/automat.policy.toml': automat_policy_text - 'arxmodel/identity.toml': identity_text - 'flatxml/VENDORED': flatxml_vendored_text - 'v.mod': vmod_text -} diff --git a/arxmodel/builtin_test.v b/arxmodel/builtin_test.v index 773f5b7..62e9182 100644 --- a/arxmodel/builtin_test.v +++ b/arxmodel/builtin_test.v @@ -2,6 +2,17 @@ module arxmodel import os +// GENERATED by scripts/gen_builtin.vsh with builtin.v; do not edit. + +// builtin_files is every built-in text by the file it was made from. +const builtin_files = { + 'arxmodel/policy.toml': default_policy_text + 'arxmodel/automat.policy.toml': automat_policy_text + 'arxmodel/identity.toml': identity_text + 'flatxml/VENDORED': flatxml_vendored_text + 'v.mod': vmod_text +} + // The generated texts ARE the files they were made from: change one and forget // scripts/gen_builtin.vsh, and this fails rather than the library carrying the old text. fn test_the_builtin_texts_are_the_files() { diff --git a/arxmodel/export.v b/arxmodel/export.v index 07ae59a..021b23a 100644 --- a/arxmodel/export.v +++ b/arxmodel/export.v @@ -101,16 +101,16 @@ fn relocate(location string, from string, to string) (string, string) { if to == '-' { return location, 'xsi:schemaLocation names ${location} as ${from} does, relative to that file' } - from_dir := os.real_path(os.dir(from)) - to_dir := os.real_path(os.dir(os.abs_path(to))) - if from_dir == to_dir { + src_dir := os.real_path(os.dir(from)) + dst_dir := os.real_path(os.dir(os.abs_path(to))) + if src_dir == dst_dir { return location, '' } - target := os.join_path(from_dir, location) + target := os.join_path(src_dir, location) if !os.exists(target) { - return location, 'xsi:schemaLocation names ${location} as ${from} does: no such file beside it to locate from ${to_dir}' + return location, 'xsi:schemaLocation names ${location} as ${from} does: no such file beside it to locate from ${dst_dir}' } - return relative_path(to_dir, os.real_path(target)), '' + return relative_path(dst_dir, os.real_path(target)), '' } // relative_path is the path of target from directory dir, both absolute. diff --git a/arxmodel/open_test.v b/arxmodel/open_test.v index e69ca49..3835831 100644 --- a/arxmodel/open_test.v +++ b/arxmodel/open_test.v @@ -3,7 +3,7 @@ module arxmodel import flatxml import os -fn src(path string, body string) Source { +fn source_of(path string, body string) Source { return Source{path, body.bytes()} } @@ -18,7 +18,7 @@ const open_b = '' fn test_open_indexes_a_model_split_over_files() { - mut o := open_sources([src('a.arxml', open_a), src('b.arxml', open_b)])! + mut o := open_sources([source_of('a.arxml', open_a), source_of('b.arxml', open_b)])! defer { o.free() } @@ -37,7 +37,7 @@ fn test_open_indexes_a_model_split_over_files() { } fn test_open_follows_absolute_references_only() { - mut o := open_sources([src('a.arxml', open_a), src('b.arxml', open_b)])! + mut o := open_sources([source_of('a.arxml', open_a), source_of('b.arxml', open_b)])! defer { o.free() } @@ -61,7 +61,7 @@ fn test_open_follows_absolute_references_only() { } fn test_open_refuses_a_document_that_does_not_parse() { - open_sources([src('bad.arxml', '')]) or { + open_sources([source_of('bad.arxml', '')]) or { assert err.msg().contains('bad.arxml') return } @@ -72,7 +72,7 @@ fn test_open_keeps_the_order_written_and_lists_what_one_file_repeats() { text := 'P' + 'ZA' + 'Z1' - mut o := open_sources([src('a.arxml', text)])! + mut o := open_sources([source_of('a.arxml', text)])! defer { o.free() } @@ -124,7 +124,7 @@ fn test_a_model_file_refuses_what_it_does_not_know() { } fn test_open_by_a_schema_dir_that_governs_nothing_is_an_error() { - open_sources([src('a.arxml', open_a)], schema_dir: os.temp_dir()) or { + open_sources([source_of('a.arxml', open_a)], schema_dir: os.temp_dir()) or { assert err.msg().contains('no schema governs') || err.msg().contains('namespace'), err.msg() return } @@ -170,7 +170,7 @@ fn named_count(o &Opened, local string) int { fn test_values_of_a_definition_given_twice_merge_whatever_the_prefix() { // a definition given twice is keyed by its values' content: the content's element names are // local names, so a prefix does not keep one value apart from itself - mut o := open_sources([src('a.arxml', ecuc('', ['1', '2'])), src('b.arxml', ecuc('ar', ['1', '2']))])! + mut o := open_sources([source_of('a.arxml', ecuc('', ['1', '2'])), source_of('b.arxml', ecuc('ar', ['1', '2']))])! defer { o.free() } @@ -199,8 +199,8 @@ fn test_by_the_schema_a_value_is_identified_by_its_definition_whatever_the_prefi defer { os.rm(policy) or {} } - mut o := open_sources([src('a.arxml', vk_setting_doc('', '1')), - src('b.arxml', vk_setting_doc('l', '1'))], schema_dir: os.join_path(@VMODROOT, 'testdata', 'schemas'), policy: policy)! + mut o := open_sources([source_of('a.arxml', vk_setting_doc('', '1')), + source_of('b.arxml', vk_setting_doc('l', '1'))], schema_dir: os.join_path(@VMODROOT, 'testdata', 'schemas'), policy: policy)! defer { o.free() } @@ -216,8 +216,8 @@ fn test_the_policy_filters_apply_to_what_open_found() { defer { os.rm(policy) or {} } - mut o := open_sources([src('a.arxml', vk_setting_doc('', '1')), - src('b.arxml', vk_setting_doc('', '2'))], schema_dir: os.join_path(@VMODROOT, 'testdata', 'schemas'), policy: policy)! + mut o := open_sources([source_of('a.arxml', vk_setting_doc('', '1')), + source_of('b.arxml', vk_setting_doc('', '2'))], schema_dir: os.join_path(@VMODROOT, 'testdata', 'schemas'), policy: policy)! defer { o.free() } @@ -235,8 +235,8 @@ fn test_open_sources_reads_relative_filters_from_its_roots() { os.rm(policy) or {} } root := os.join_path(os.temp_dir(), 'arxmodel_roots_${os.getpid()}') - srcs := [src(os.join_path(root, 'a.arxml'), vk_setting_doc('', '1')), - src(os.join_path(root, 'b.arxml'), vk_setting_doc('', '2'))] + srcs := [source_of(os.join_path(root, 'a.arxml'), vk_setting_doc('', '1')), + source_of(os.join_path(root, 'b.arxml'), vk_setting_doc('', '2'))] schemas := os.join_path(@VMODROOT, 'testdata', 'schemas') mut o := open_sources(srcs, schema_dir: schemas, policy: policy, roots: [root])! defer { @@ -252,7 +252,7 @@ fn test_an_element_of_another_namespace_is_not_the_models() { text := 'P' + 'AQ' + '' - mut o := open_sources([src('a.arxml', text)])! + mut o := open_sources([source_of('a.arxml', text)])! defer { o.free() } @@ -283,7 +283,7 @@ fn test_check_merges_a_prefixed_file_by_the_schemas_namespace() { fn test_the_models_namespace_is_most_roots_one() { foreign := '' - mut o := open_sources([src('00.arxml', foreign), src('a.arxml', open_a), src('b.arxml', open_b)])! + mut o := open_sources([source_of('00.arxml', foreign), source_of('a.arxml', open_a), source_of('b.arxml', open_b)])! defer { o.free() } @@ -294,7 +294,7 @@ fn test_the_models_namespace_is_most_roots_one() { fn test_a_repetition_is_said_once() { pkg := 'PA' - mut o := open_sources([src('a.arxml', '${pkg}${pkg}')])! + mut o := open_sources([source_of('a.arxml', '${pkg}${pkg}')])! defer { o.free() } @@ -307,7 +307,7 @@ fn test_an_element_of_no_namespace_is_no_value_of_the_model() { text := 'P' + 'C/D/p' + '' - mut o := open_sources([src('a.arxml', text)])! + mut o := open_sources([source_of('a.arxml', text)])! defer { o.free() } @@ -340,7 +340,7 @@ fn lengths_of(n flatxml.MNode) []flatxml.MNode { fn test_files_giving_one_element_two_values_say_so() { // the one FRAME-LENGTH of a frame in each file is one element of the model: the first file's // is read, and that the second gives another is said - mut o := open_sources([src('a.arxml', frame_doc('8')), src('b.arxml', frame_doc('12'))])! + mut o := open_sources([source_of('a.arxml', frame_doc('8')), source_of('b.arxml', frame_doc('12'))])! defer { o.free() } @@ -349,7 +349,7 @@ fn test_files_giving_one_element_two_values_say_so() { assert d.len == 1 && d[0].path == '/P/F#FRAME-LENGTH' && d[0].at.len == 2, d.str() assert d[0].at[0].starts_with('a.arxml:') && d[0].at[1].starts_with('b.arxml:') // the same value in both, or the same element told apart by an attribute, is no finding - mut same := open_sources([src('a.arxml', frame_doc('8')), src('b.arxml', frame_doc('8'))])! + mut same := open_sources([source_of('a.arxml', frame_doc('8')), source_of('b.arxml', frame_doc('8'))])! defer { same.free() } @@ -358,7 +358,7 @@ fn test_files_giving_one_element_two_values_say_so() { desc := fn (l string, t string) string { return frame_doc('8').replace('', '${t}') } - mut langs := open_sources([src('a.arxml', desc('EN', 'hello')), src('b.arxml', desc('DE', 'hallo'))])! + mut langs := open_sources([source_of('a.arxml', desc('EN', 'hello')), source_of('b.arxml', desc('DE', 'hallo'))])! defer { langs.free() } @@ -367,7 +367,7 @@ fn test_files_giving_one_element_two_values_say_so() { label := fn (l string, t string) string { return frame_doc('8').replace('', '${t}') } - mut labels := open_sources([src('a.arxml', label('EN', 'hello')), src('b.arxml', label('DE', 'hallo'))])! + mut labels := open_sources([source_of('a.arxml', label('EN', 'hello')), source_of('b.arxml', label('DE', 'hallo'))])! defer { labels.free() } @@ -377,19 +377,19 @@ fn test_files_giving_one_element_two_values_say_so() { ref := fn (attrs string, path string) string { return frame_doc('8').replace('', '${path}') } - mut refs := open_sources([src('a.arxml', ref('DEST="I-PDU" BASE="b"', '/P/A')), - src('b.arxml', ref('BASE="b" DEST="I-PDU"', '/P/B'))])! + mut refs := open_sources([source_of('a.arxml', ref('DEST="I-PDU" BASE="b"', '/P/A')), + source_of('b.arxml', ref('BASE="b" DEST="I-PDU"', '/P/B'))])! defer { refs.free() } assert refs.findings.map(it.path) == ['/P/F#PDU-REF'] hinted := frame_doc('12').replace('', '').replace('', '') - mut hints := open_sources([src('a.arxml', frame_doc('8')), src('b.arxml', hinted)])! + mut hints := open_sources([source_of('a.arxml', frame_doc('8')), source_of('b.arxml', hinted)])! defer { hints.free() } assert hints.findings.map(it.path) == ['/P/F#FRAME-LENGTH'], hints.findings.str() - mut deep := open_sources([src('a.arxml', desc('EN', 'hello')), src('b.arxml', desc('EN', 'hello').replace('L="EN"', 'L="DE"'))])! + mut deep := open_sources([source_of('a.arxml', desc('EN', 'hello')), source_of('b.arxml', desc('EN', 'hello').replace('L="EN"', 'L="DE"'))])! defer { deep.free() } @@ -398,12 +398,12 @@ fn test_files_giving_one_element_two_values_say_so() { text_or := fn (body string) string { return frame_doc('8').replace('', '${body}') } - mut lit := open_sources([src('a.arxml', text_or('<L-2>hello')), src('b.arxml', text_or('hello'))])! + mut lit := open_sources([source_of('a.arxml', text_or('<L-2>hello')), source_of('b.arxml', text_or('hello'))])! defer { lit.free() } assert lit.findings.map(it.path) == ['/P/F#DESC'] - mut cdata := open_sources([src('a.arxml', text_or('a ')), src('b.arxml', text_or('a b'))])! + mut cdata := open_sources([source_of('a.arxml', text_or('a ')), source_of('b.arxml', text_or('a b'))])! defer { cdata.free() } @@ -413,12 +413,12 @@ fn test_files_giving_one_element_two_values_say_so() { return frame_doc('8').replace('', 'n' + '${first}${second}') } - mut order := open_sources([src('a.arxml', both('M1', 'M2')), src('b.arxml', both('M2', 'M1'))])! + mut order := open_sources([source_of('a.arxml', both('M1', 'M2')), source_of('b.arxml', both('M2', 'M1'))])! defer { order.free() } assert order.findings.len == 0, order.findings.str() - mut other := open_sources([src('a.arxml', both('M1', 'M2')), src('b.arxml', both('M1', 'M3'))])! + mut other := open_sources([source_of('a.arxml', both('M1', 'M2')), source_of('b.arxml', both('M1', 'M3'))])! defer { other.free() } @@ -428,14 +428,14 @@ fn test_files_giving_one_element_two_values_say_so() { return frame_doc('8').replace('', 'n' + '<${first}>m<${second}>m') } - mut wrapped := open_sources([src('a.arxml', lists('XS', 'YS')), src('b.arxml', lists('YS', 'XS'))])! + mut wrapped := open_sources([source_of('a.arxml', lists('XS', 'YS')), source_of('b.arxml', lists('YS', 'XS'))])! defer { wrapped.free() } assert wrapped.findings.len == 0, wrapped.findings.str() // nor is a name one file repeats: those are matched by place twice := frame_doc('8').replace('8', '89') - mut rep := open_sources([src('a.arxml', twice), src('b.arxml', frame_doc('12'))])! + mut rep := open_sources([source_of('a.arxml', twice), source_of('b.arxml', frame_doc('12'))])! defer { rep.free() } diff --git a/arxmodel/references.v b/arxmodel/references.v index ba7d51a..a96796c 100644 --- a/arxmodel/references.v +++ b/arxmodel/references.v @@ -250,9 +250,10 @@ pub fn index_paths(v &flatxml.Merged, mut ty Typing, typed bool, fold bool) &Pat return ix } -// short_name_of is a node's SHORT-NAME text: its single child of that name, or, where the rules -// keep every occurrence apart (the built-in identity rules), its first child of that name — as the -// merge names it, so with a local namespace a document binding it to `ar` is indexed alike. +// short_name_and_doc is a node's SHORT-NAME text and the document it is written in: its single +// child of that name, or, where the rules keep every occurrence apart (the built-in identity +// rules), its first child of that name — as the merge names it, so with a local namespace a +// document binding it to `ar` is indexed alike. fn short_name_and_doc(n flatxml.MNode, sn u32) (string, &flatxml.Doc) { c := n.child_id(sn, '') if c.ok() { @@ -268,19 +269,6 @@ fn short_name_and_doc(n flatxml.MNode, sn u32) (string, &flatxml.Doc) { return '', unsafe { &flatxml.Doc(nil) } } -fn short_name_of(n flatxml.MNode, sn u32) string { - c := n.child_id(sn, '') - if c.ok() { - return trimmed(c.text()) - } - for k in n.children() { - if k.tag() == sn { - return trimmed(k.text()) - } - } - return '' -} - // merged_path is a merged node's AUTOSAR path: its nearest referrable ancestor's (or its own) // path, then, after `#`, the elements below it down to the node, each with its key where the // merge gives it one (`NAME[key]`); `#` and the elements from the root where no ancestor is diff --git a/arxmodel/spec_test.v b/arxmodel/spec_test.v index f8e5e0b..5d69df7 100644 --- a/arxmodel/spec_test.v +++ b/arxmodel/spec_test.v @@ -196,13 +196,11 @@ fn test_an_attribute_ignored_by_one_spelling_is_left_out_of_every_hash() { d.resolve_namespaces() or { panic(err) } return d } - a := mk('') - b := mk('') + mut a := mk('') + mut b := mk('') mut set := flatxml.DocSet.new() - mut da := a - mut db := b - set.add(mut da) - set.add(mut db) + set.add(mut a) + set.add(mut b) m := &Model{ set: set } diff --git a/arxmodel/validate_test.v b/arxmodel/validate_test.v index 1b4de67..02c566b 100644 --- a/arxmodel/validate_test.v +++ b/arxmodel/validate_test.v @@ -1,6 +1,5 @@ module arxmodel -import flatxml.xsd import os fn vdata(p ...string) string { diff --git a/cmd/arxmodel/main.v b/cmd/arxmodel/main.v index b8e084e..ff2fb9a 100644 --- a/cmd/arxmodel/main.v +++ b/cmd/arxmodel/main.v @@ -908,18 +908,10 @@ fn read_for(o Opts, cmd string, what string) (string, arxmodel.Checked) { rest.paths = o.paths[1..] _, _, c, _ := merged(rest, Out{ err: true - }, read_options(o)) + }, read_options()) return o.paths[0], c } -fn all_skipped() arxmodel.CheckOptions { - return arxmodel.CheckOptions{ - skip_xml: true - skip_multiplicity: true - skip_references: true - } -} - // check_options are the options given to check and merge, as the merge's. fn check_options(o Opts) arxmodel.CheckOptions { return arxmodel.CheckOptions{ @@ -937,7 +929,7 @@ fn check_options(o Opts) arxmodel.CheckOptions { // read_options are the options of the commands that only read the merged model (get, list, // values): no layer checked. -fn read_options(o Opts) arxmodel.CheckOptions { +fn read_options() arxmodel.CheckOptions { return arxmodel.CheckOptions{ skip_xml: true skip_multiplicity: true diff --git a/cmd/arxmodel/serve.v b/cmd/arxmodel/serve.v index adc8c38..004f8b7 100644 --- a/cmd/arxmodel/serve.v +++ b/cmd/arxmodel/serve.v @@ -479,7 +479,7 @@ fn serve_worker(o Opts) { } m, _, c, _ := merged(o, Out{ err: true - }, read_options(o)) + }, read_options()) if m.failed.len > 0 { // no answer from a part of the files: the server says why, from this file os.write_file(errs, m.failed.map(it.msg).join('; ')) or {} diff --git a/flatxml/VENDORED b/flatxml/VENDORED index 19aa44f..f7327bd 100644 --- a/flatxml/VENDORED +++ b/flatxml/VENDORED @@ -1,3 +1,3 @@ -flatxml 83da97ee878cfbe77d0341cc274c57c736f05a52 +flatxml 5da7bdc134343ae52239cd1ef2e57231f4becaf0 source https://github.com/MartenH/flatxml The library folder at that commit, without its tests. Do not edit; re-vendor. diff --git a/flatxml/xsd/resolve.v b/flatxml/xsd/resolve.v index 6485d41..1383866 100644 --- a/flatxml/xsd/resolve.v +++ b/flatxml/xsd/resolve.v @@ -101,7 +101,7 @@ fn (mut r Reader) resolve() ! { for ct in 0 .. r.s.complex_types.len { mut from := map[u64]u64{} for g in r.ct_agroups[u32(ct)] or { []u32{} } { - // joined as union_of joins, recording the uses it keeps + // joined as a set (a group reached twice adds its attributes once), recording the uses kept for j, u in r.flatten(g)! { if !r.s.complex_types[ct].attrs.any(it.decl == u.decl) { r.s.complex_types[ct].attrs << u @@ -217,7 +217,8 @@ fn (mut r Reader) flatten(g u32) ![]AttrUse { mut attrs := r.agroups[g].attrs.clone() mut origins := []u64{len: attrs.len, init: u64(g) << 32 | u64(index)} for sub in r.agroups[g].refs { - // joined as union_of joins, each kept use with where it is written + // joined as a set (a group reached twice adds its attributes once), each kept use with + // where it is written for j, u in r.flatten(sub)! { if !attrs.any(it.decl == u.decl) { attrs << u @@ -232,18 +233,6 @@ fn (mut r Reader) flatten(g u32) ![]AttrUse { return attrs } -// union_of is a then the uses of b whose declaration a does not have: attribute groups combine -// as sets, so a group reached twice contributes its attributes once. -fn union_of(a []AttrUse, b []AttrUse) []AttrUse { - mut out := a.clone() - for u in b { - if !out.any(it.decl == u.decl) { - out << u - } - } - return out -} - // check_simple_cycles refuses a simple type that is its own base, directly or through others. fn (r &Reader) check_simple_cycles() ! { mut state := []u8{len: r.s.simple_types.len} // 0 unvisited, 1 on the current chain, 2 done diff --git a/scripts/gen_builtin.vsh b/scripts/gen_builtin.vsh index 291d8ea..bbbe279 100644 --- a/scripts/gen_builtin.vsh +++ b/scripts/gen_builtin.vsh @@ -1,14 +1,15 @@ #!/usr/bin/env -S v run -// gen_builtin.vsh writes arxmodel/builtin.v from the files the library carries built in: +// gen_builtin.vsh writes arxmodel/builtin.v from the files the library carries built in, and +// arxmodel/builtin_test.v, which pins each text to its file: // v run scripts/gen_builtin.vsh // Run it after changing one of them; builtin_test.v fails until you do. vendor_flatxml.sh runs it. import os const root = os.dir(os.dir(@FILE)) -// const name -> file, relative to the repository. ONE list: builtin.v carries it as -// `builtin_files`, which the test walks. +// const name -> file, relative to the repository. ONE list: builtin_test.v carries it as +// `builtin_files`, which the test walks; the library itself never reads it. const table = [ ['default_policy_text', 'arxmodel/policy.toml'], ['automat_policy_text', 'arxmodel/automat.policy.toml'], @@ -47,12 +48,28 @@ for t in table { out << '// ${t[1]}' out << 'const ${t[0]} = ${literal(text)}' } -out << '' -out << '// builtin_files is every built-in text by the file it was made from.' -out << 'const builtin_files = {' +os.write_file(os.join_path(root, 'arxmodel', 'builtin.v'), out.join('\n') + '\n')! + +mut test := []string{} +test << 'module arxmodel' +test << '' +test << 'import os' +test << '' +test << '// GENERATED by scripts/gen_builtin.vsh with builtin.v; do not edit.' +test << '' +test << '// builtin_files is every built-in text by the file it was made from.' +test << 'const builtin_files = {' for t in table { - out << "\t'${t[1]}': ${t[0]}" + test << "\t'${t[1]}': ${t[0]}" } -out << '}' -os.write_file(os.join_path(root, 'arxmodel', 'builtin.v'), out.join('\n') + '\n')! -println('wrote arxmodel/builtin.v') +test << '}' +test << '' +test << '// The generated texts ARE the files they were made from: change one and forget' +test << '// scripts/gen_builtin.vsh, and this fails rather than the library carrying the old text.' +test << 'fn test_the_builtin_texts_are_the_files() {' +test << '\tfor path, text in builtin_files {' +test << "\t\tassert text == os.read_file(os.join_path(@VMODROOT, path))!, '\${path} changed: v run scripts/gen_builtin.vsh'" +test << '\t}' +test << '}' +os.write_file(os.join_path(root, 'arxmodel', 'builtin_test.v'), test.join('\n') + '\n')! +println('wrote arxmodel/builtin.v and arxmodel/builtin_test.v') From 628cbb0a7330b6408909922cfed7f79093e4f185 Mon Sep 17 00:00:00 2001 From: Marten Hildell Date: Sun, 18 Oct 2026 17:09:41 +0200 Subject: [PATCH 2/2] flatxml at 2a2650f Co-Authored-By: Claude Opus 5.5 --- arxmodel/builtin.v | 2 +- flatxml/VENDORED | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/arxmodel/builtin.v b/arxmodel/builtin.v index f96c20e..84cc682 100644 --- a/arxmodel/builtin.v +++ b/arxmodel/builtin.v @@ -302,7 +302,7 @@ const identity_text = '# arxmodel\'s built-in identity rules: how the elements o '# order counts: a reorder is reported. The order of named elements does not count.\n' // flatxml/VENDORED -const flatxml_vendored_text = 'flatxml 5da7bdc134343ae52239cd1ef2e57231f4becaf0\n' + +const flatxml_vendored_text = 'flatxml 2a2650fcc0865f5dd60ec296a585ab0fcdf4d51a\n' + 'source https://github.com/MartenH/flatxml\n' + 'The library folder at that commit, without its tests. Do not edit; re-vendor.\n' diff --git a/flatxml/VENDORED b/flatxml/VENDORED index f7327bd..1373c53 100644 --- a/flatxml/VENDORED +++ b/flatxml/VENDORED @@ -1,3 +1,3 @@ -flatxml 5da7bdc134343ae52239cd1ef2e57231f4becaf0 +flatxml 2a2650fcc0865f5dd60ec296a585ab0fcdf4d51a source https://github.com/MartenH/flatxml The library folder at that commit, without its tests. Do not edit; re-vendor.