def get_testname(filename):
    """
    Return a standardized test name given a filename corresponding to a golden
    JSON file, a coding tables file, a fidl file, or an order.txt file.
    >>> get_testname('foo/bar/testdata/mytest/order.txt')
    'mytest'
    >>> get_testname('foo/bar/goldens/mytest.test.json.golden')
    'mytest'
    >>> get_testname('foo/bar/goldens/mytest.test.tables.c.golden')
    'mytest'
    >>> get_testname('foo/bar/testdata/mytest.test.fidl')
    'mytest'
    """
    path = filename.split('/')
    dirname = 'goldens' if '/goldens/' in filename else 'testdata'
    dir_index = path.index(dirname)
    return path[dir_index + 1].split('.')[0]