a0a3411bca2fdd6d704ce2be7c9c8fca7682913a
braney
  Sat Sep 19 18:19:36 2026 -0700
bedItemRgbTester: pin the order of the itemRgb and color tests

bedItemRgb() decides whether a BED track draws its items in the colors its file
carries or in the one color its stanza names.  The rule has four steps, and the
order of the first three is the whole of #36212: an explicit "itemRgb off"
wins, then an explicit "itemRgb on" wins, and only then does the presence of a
"color" setting turn item colors off by default.  88d620e6c82 folded those
tests together, so a stanza saying both "itemRgb on" and "color" -- which means
items from the file and labels from color -- lost its item colors.

The pairs are what matter here.  Every single-setting case passed while the bug
was live, so a test that exercised one setting at a time would have proved
nothing.  A child that says "itemRgb on" under a parent that says "color" is
the same case reached through trackDbSettingClosestToHome.

Two runs, with and without hg.conf's alwaysItemRgb, since the last step of the
rule reads it and a mirror that turns it off must still honour a stanza that
asks for item colors explicitly.

The test lives in hg/lib/tests because hg/cgilib has no tests directory; its
link line adds jkhgapcgi.a.

Watched to fail and then pass: with the color test moved back in front of the
itemRgb test, three lines flip, and they are the three that pair the two
settings.  Recorded as sandbox-ab in utils/testRegistry.

refs #36212, refs #38391

diff --git src/hg/lib/tests/expected/bedItemRgbTest src/hg/lib/tests/expected/bedItemRgbTest
new file mode 100644
index 00000000000..67efe919dfb
--- /dev/null
+++ src/hg/lib/tests/expected/bedItemRgbTest
@@ -0,0 +1,38 @@
+======== hg.conf alwaysItemRgb=(not set, defaults on)
+one setting
+  (nothing)                                            item colors
+  itemRgb on                                           item colors
+  itemRgb off                                          one color
+  color 255,0,0                                        one color
+
+both settings
+  itemRgb on  + color 255,0,0                          item colors
+  itemRgb off + color 255,0,0                          one color
+  color 255,0,0 + itemRgb on  (other order)            item colors
+
+from a parent
+  child of a stanza with color                         one color
+  child says itemRgb on, parent says color             item colors
+
+no track
+  NULL                                                 item colors
+
+======== hg.conf alwaysItemRgb=off
+one setting
+  (nothing)                                            one color
+  itemRgb on                                           item colors
+  itemRgb off                                          one color
+  color 255,0,0                                        one color
+
+both settings
+  itemRgb on  + color 255,0,0                          item colors
+  itemRgb off + color 255,0,0                          one color
+  color 255,0,0 + itemRgb on  (other order)            item colors
+
+from a parent
+  child of a stanza with color                         one color
+  child says itemRgb on, parent says color             item colors
+
+no track
+  NULL                                                 item colors
+