def create_test_workspace(sdk, output, workspace_info):
    # Remove any existing output.
    shutil.rmtree(output, True)

    # Copy the base tests.
    copy_tree(os.path.join(SCRIPT_DIR, 'tests', 'common'), output)
    if workspace_info.with_cc:
        copy_tree(os.path.join(SCRIPT_DIR, 'tests', 'cc'), output)
    if workspace_info.with_dart:
        copy_tree(os.path.join(SCRIPT_DIR, 'tests', 'dart'), output)

    # WORKSPACE file.
    workspace = model.TestWorkspace(os.path.relpath(sdk, output),
                                    workspace_info.with_cc,
                                    workspace_info.with_dart)
    write_file(os.path.join(output, 'WORKSPACE'), 'workspace', workspace)

    # .bazelrc file.
    crosstool = model.Crosstool(workspace_info.target_arches)
    write_file(os.path.join(output, '.bazelrc'), 'bazelrc', crosstool)

    # run.py file
    write_file(os.path.join(output, 'run.py'),
               'run_py',
               crosstool,
               is_executable=True)

    if workspace_info.with_cc:
        # Generate tests to verify that headers compile fine.
        for target, files in workspace_info.headers.iteritems():
            if not files:
                continue
            dir = os.path.join(output, 'headers', target[2:])
            write_file(make_dir(os.path.join(dir, 'BUILD')), 'headers_build', {
                'dep': target,
                'headers': files,
            })
            write_file(make_dir(os.path.join(dir, 'headers.cc')), 'headers',
                       {'headers': files})

    # Tests that generated FIDL bindings are usable.
    for library in workspace_info.fidl_libraries:
        dir = os.path.join(output, 'fidl', library)
        write_file(make_dir(os.path.join(dir, 'BUILD')), 'fidl_build', {
            'library': library,
        })
        write_file(make_dir(os.path.join(dir, 'header_test.cc')),
                   'fidl_headers', {
                       'header': library.replace('_', '/') + '/cpp/fidl.h',
                   })

    return True
def create_test_workspace(sdk, output, workspace_info):
    # Remove any existing output.
    shutil.rmtree(output, True)

    # Copy the base tests.
    copy_tree(os.path.join(SCRIPT_DIR, 'tests', 'common'), output)
    if workspace_info.with_cc:
        copy_tree(os.path.join(SCRIPT_DIR, 'tests', 'cc'), output)
    if workspace_info.with_dart:
        copy_tree(os.path.join(SCRIPT_DIR, 'tests', 'dart'), output)

    # WORKSPACE file.
    workspace = model.TestWorkspace(os.path.relpath(sdk, output),
                                    workspace_info.with_cc,
                                    workspace_info.with_dart)
    write_file(os.path.join(output, 'WORKSPACE'), 'workspace', workspace)

    # .bazelrc file.
    crosstool = model.Crosstool(workspace_info.target_arches)
    write_file(os.path.join(output, '.bazelrc'), 'bazelrc', crosstool)

    # run.py file
    write_file(os.path.join(output, 'run.py'),
               'run_py',
               crosstool,
               is_executable=True)

    if workspace_info.with_cc:
        # Generate test to verify that headers compile fine.
        headers = workspace_info.headers
        header_base = os.path.join(output, 'headers')
        write_file(make_dir(os.path.join(
            header_base, 'BUILD')), 'headers_build', {
                'deps': list(filter(lambda k: headers[k], headers.keys())),
            })
        write_file(make_dir(os.path.join(header_base, 'headers.cc')),
                   'headers', {
                       'headers': headers,
                   })

    return True