def METHOD_NAME(test, targets, suites):
    global i
    env = ' '.join(('%s=%s' % (shlex.quote(k), shlex.quote(v))
                    for k, v in test['env'].items()))
    executable = test['cmd'][0]
    try:
        executable = os.path.relpath(executable)
    except:
        pass
    if test['workdir'] is not None:
        try:
            test['cmd'][0] = os.path.relpath(executable, test['workdir'])
        except:
            test['cmd'][0] = executable
    else:
        test['cmd'][0] = executable
    cmd = ' '.join((shlex.quote(x) for x in test['cmd']))
    driver = test['protocol'] if 'protocol' in test else 'exitcode'
    i += 1
    if test['workdir'] is not None:
        print('.test.dir.%d := %s' % (i, shlex.quote(test['workdir'])))
    if 'depends' in test:
        deps = (targets.get(x, []) for x in test['depends'])
        deps = itertools.chain.from_iterable(deps)
    else:
        deps = ['all']
    print('.test.name.%d := %s' % (i, test['name']))
    print('.test.driver.%d := %s' % (i, driver))
    print('.test.env.%d := $(.test.env) %s' % (i, env))
    print('.test.cmd.%d := %s' % (i, cmd))
    print('.test.deps.%d := %s' % (i, ' '.join(deps)))
    print('.PHONY: run-test-%d' % (i,))
    print('run-test-%d: $(.test.deps.%d)' % (i,i))
    print('\t@$(call .test.run,%d,$(.test.output-format))' % (i,))
    test_suites = test['suite'] or ['default']
    is_slow = any(s.endswith('-slow') for s in test_suites)
    for s in test_suites:
        # The suite name in the introspection info is "PROJECT:SUITE"
        s = s.split(':')[1]
        if s.endswith('-slow'):
            s = s[:-5]
        if is_slow:
            suites[s].slow_tests.append(i)
        else:
            suites[s].tests.append(i)
        suites[s].executables.add(executable)