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/makefile src/hg/lib/tests/makefile
index 4e9057e935e..526d235e3c0 100644
--- src/hg/lib/tests/makefile
+++ src/hg/lib/tests/makefile
@@ -12,31 +12,31 @@
 	${BIN_DIR}/pslReaderTester \
 	${BIN_DIR}/quickLiftTester \
 	${BIN_DIR}/sessionDataTester \
 	${BIN_DIR}/trashDirTester \
 #	${BIN_DIR}/annoGratorTester \
 	${BIN_DIR}/binTest \
 	${BIN_DIR}/customTrackTester \
 	${BIN_DIR}/hgvsTester \
 	${BIN_DIR}/sqlCheck 
 
 ${BIN_DIR}/%: %.c ${MYLIBS}
 	@${MKDIR} ${BIN_DIR}
 	${CC} ${CC_PROG_OPTS} -o $@ $*.c ${MYLIBS} $L
 
 #test: binTest spDbTest hdbTest genePredTest pslReaderTest annoGratorTest customTrackTest hgvsTest
-test: binTest quickLiftTest sessionDataTest trashDirTest mallocTopPadTest spDbTest hdbTest genePredTest pslReaderTest customTrackTest hgvsTest
+test: binTest quickLiftTest sessionDataTest trashDirTest mallocTopPadTest bedItemRgbTest spDbTest hdbTest genePredTest pslReaderTest customTrackTest hgvsTest
 	rm -r output
 	echo tested all
 
 mkdirs:
 	@${MKDIR} output ${BIN_DIR}
 
 loaders:
 	ln -sf ${CGI_BIN}/loader .
 
 spDbTest: ${BIN_DIR}/spDbTest mkdirs
 	${BIN_DIR}/spDbTest sp121210 Q9FFH7 > output/spDbTest
 	${BIN_DIR}/spDbTest sp121210 P29312 >> output/spDbTest
 	diff expected/spDbTest output/spDbTest
 
 hdbTest: ${BIN_DIR}/hdbTest mkdirs
@@ -94,21 +94,34 @@
 	HGDB_CONF=output/sd/rel.conf ${BIN_DIR}/trashDirTester \
 	    "the symlink, relative" `pwd`/output/sd/link `pwd`/output/sd/real \
 	    >> output/trashDirTest
 	diff expected/trashDirTest output/trashDirTest
 
 # Twice: once with the setting and once without, because the answer is the DIFFERENCE between
 # them.  A single run could pass on a library whose own default happened to be large.
 mallocTopPadTest: ${BIN_DIR}/mallocTopPadTester mkdirs
 	echo "include ${HOME}/.hg.conf" > output/topPadOff.conf
 	echo "include ${HOME}/.hg.conf" > output/topPadOn.conf
 	echo "mallocTopPad=33554432" >> output/topPadOn.conf
 	HGDB_CONF=output/topPadOff.conf ${BIN_DIR}/mallocTopPadTester > output/mallocTopPadTest
 	HGDB_CONF=output/topPadOn.conf ${BIN_DIR}/mallocTopPadTester >> output/mallocTopPadTest
 	diff expected/mallocTopPadTest output/mallocTopPadTest
 
+# bedItemRgb lives in hg/cgilib, which has no tests directory, so this one test links
+# jkhgapcgi.a on top of the libraries the rest of this directory uses.  Two runs, because the
+# last step of the rule reads hg.conf's alwaysItemRgb and a mirror may turn it off.
+bedItemRgbTest: mkdirs
+	${CC} ${CC_PROG_OPTS} -o ${BIN_DIR}/bedItemRgbTester bedItemRgbTester.c \
+	    ${MYLIBDIR}/jkhgapcgi.a ${MYLIBS} $L
+	echo "include ${HOME}/.hg.conf" > output/rgbOn.conf
+	echo "include ${HOME}/.hg.conf" > output/rgbOff.conf
+	echo "alwaysItemRgb=off" >> output/rgbOff.conf
+	HGDB_CONF=output/rgbOn.conf ${BIN_DIR}/bedItemRgbTester > output/bedItemRgbTest
+	HGDB_CONF=output/rgbOff.conf ${BIN_DIR}/bedItemRgbTester >> output/bedItemRgbTest
+	diff expected/bedItemRgbTest output/bedItemRgbTest
+
 sqlCheck: ${BIN_DIR}/sqlCheck mkdirs
 	${MAKE} -f sqlCheck.mk test BIN_DIR=${BIN_DIR} OUT_DIR=output
 
 
 clean:
 	rm -rf *.o bin output *.tmp loader udcCache