OTOH, this test case is begging for list comprehension in some guise.  In a weird hybrid of python and .cf:
join(',', ["$(G.testdir)$(const.dirsep)path_split($(x))[0]" for x in @(names)])