#
#  This is separated out because we need 2 separate Jamrules to
#  do the multi-root thing in which the bug presents itself.
#
#  Returns $(SUBDIR) on failure, and an empty list on success.
#
rule TestTokens
{
	local undef  = "undefined" ;
	local result ;

	if $(TEST-SET)
	{
	#Echo "Jam already knows about TEST - it's $(TEST)" ;
	#Echo "         and TEST-ROOT   is $(TEST-ROOT:J=/)" ;
	#Echo "         and TEST-UP     is $(TEST-UP:J=/)" ;
	#Echo "         and TEST-DOWN   is $(TEST-DOWN:J=/)" ;
	}

	if $(ROOT-SET)
	{
	#Echo "Jam already knows about ROOT - it's $(ROOT)" ;
	#Echo "         and ROOT-ROOT   is $(ROOT-ROOT:J=/)" ;
	#Echo "         and ROOT-UP     is $(ROOT-UP:J=/)" ;
	#Echo "         and ROOT-DOWN   is $(ROOT-DOWN:J=/)" ;
	}
	#Echo "         and SUBDIR_ROOT is $(SUBDIR_ROOT:J=/)" ;
	#Echo "         and SUBDIR_UP   is $(SUBDIR_UP:J=/)" ;
	#Echo "         and SUBDIR_DOWN is $(SUBDIR_DOWN:J=/)" ;


	# ensure the variables we're testing evaluate to _something_!
	SUBDIR          ?= $(undef) ;
	SUBDIR_TOKENS   ?= $(undef) ;

	EXPECTED_TOKENS  = $(<) ;
	EXPECTED_TOKENS ?= $(undef) ;

	if $(EXPECTED_TOKENS) = $(SUBDIR_TOKENS)
	{
	Echo "  ... $(SUBDIR) looks OK" ;
	}
	else
	{
	Echo "  Failed in $(SUBDIR)!" ;
	Echo "  expected subdir tokens: \"$(EXPECTED_TOKENS:J=,)\"" ;
	Echo "    actual subdir tokens: \"$(SUBDIR_TOKENS:J=,)\"" ;
	Echo "    SUBDIR_UP:  $(SUBDIR_UP)" ;
	result = $(SUBDIR) ;
	}

	return $(result) ;
}