def fake_waf_context(tmpdir):

    if tmpdir:
        base_path = str(tmpdir.realpath())
    else:
        base_path = None

    fake_context = unit_test.FakeContext(base_path)

    fake_context.all_envs = {
        'platform_1_debug': {
            'INCLUDES_USELIB1': ['foo'],
            'LIBPATH_USELIB2': ['foo'],
            'LIB_USELIB3': ['foo'],
            'STLIBPATH_USELIB4': ['foo'],
            'STLIB_USELIB5': ['foo'],
            'DEFINES_USELIB6': ['foo'],
            'DEFINES_USELIB7': [],
            'COPY_EXTRA_USELIB8': ['foo'],
            'PDB_USELIB9': ['foo'],
            'SHAREDLIBPATH_USELIB10': ['foo'],
            'SHAREDLIB_USELIB11': []
        }
    }

    def _mock_get_configuration_names():
        return ['debug']

    fake_context.get_all_configuration_names = _mock_get_configuration_names

    yield fake_context
示例#2
0
def fake_waf_context(tmpdir):

    if tmpdir:
        base_path = str(tmpdir.realpath())
    else:
        base_path = None

    yield unit_test.FakeContext(base_path)
示例#3
0
def fake_ctx(tmpdir):
    fake_context = unit_test.FakeContext(str(tmpdir.realpath()), False)
    tmpdir.ensure('dev/layout', dir=True)
    fake_context.layout_node = fake_context.srcnode.make_node('layout')
    tmpdir.ensure('dev/shaders', dir=True)
    # Dir has been created, set cache_isdir to avoid calling mkdir on this node, the mkdir code
    # doesn't seem to like the structure of this fake context.
    fake_context.layout_node.cache_isdir = True
    fake_context.shaders_node = fake_context.srcnode.make_node('shaders')
    tmpdir.ensure('dev/assets_cache', dir=True)
    fake_context.assets_cache = fake_context.srcnode.make_node('assets_cache')
    tmpdir.ensure('dev/engine', dir=True)
    fake_context.engine_node = fake_context.srcnode.make_node('engine')
    return fake_context
def test_get_engine_node_internal(tmpdir, engine_json, expected_error):

    if engine_json:
        engine_json_content = json.dumps(engine_json,
                                         sort_keys=True,
                                         separators=(',', ': '),
                                         indent=4)
        tmpdir.ensure('dev', dir=True)
        tmpdir.join('dev/engine.json').write(engine_json_content)

    try:
        fake_context = unit_test.FakeContext(str(tmpdir.realpath()), False)
        fake_context.path = fake_context.srcnode
        lumberyard.get_engine_node(fake_context)
    except expected_error:
        pass
def test_get_engine_node_external(tmpdir, external_engine_json,
                                  ext_engine_subpath, expected_error):

    tmp_working_path = str(tmpdir.realpath())
    c = os.path.join(tmp_working_path, os.path.normpath(ext_engine_subpath))
    b = os.path.normpath(c)
    tmp_working_engine_path = os.path.realpath(b)

    if ext_engine_subpath.startswith('..'):
        json_external_engine_path = ext_engine_subpath
    else:
        json_external_engine_path = tmp_working_engine_path

    engine_json = {
        'ExternalEnginePath': json_external_engine_path,
        'FileVersion': 1,
        'LumberyardVersion': '0.0.0.0',
        'LumberyardCopyrightYear': 2019
    }

    rel_path = os.path.relpath(tmp_working_engine_path, tmp_working_path)
    tmpdir.ensure(rel_path, dir=True)

    engine_json_content = json.dumps(engine_json,
                                     sort_keys=True,
                                     separators=(',', ': '),
                                     indent=4)
    tmpdir.ensure('dev', dir=True)
    tmpdir.join('dev/engine.json').write(engine_json_content)

    if external_engine_json:
        external_engine_json_content = json.dumps(external_engine_json,
                                                  sort_keys=True,
                                                  separators=(',', ': '),
                                                  indent=4)
        if rel_path.startswith('..'):
            rel_path = rel_path[3:]

        tmpdir.ensure(rel_path, dir=True)
        tmpdir.join('{}/engine.json'.format(rel_path)).write(
            external_engine_json_content)
    try:
        fake_context = unit_test.FakeContext(tmp_working_path, False)
        fake_context.path = fake_context.srcnode
        lumberyard.get_engine_node(fake_context)
    except expected_error:
        pass
示例#6
0
def test_NodeGetBld_pathequals_success(tmpdir, mock_ctx_for_util):

    # LY-98845
    # To simulate conditions for LY-98845, we need a different context that represents the same path, and replace it's bldnode
    # with the parameterize mocked one to replicate the id's being different
    mock_ctx_2 = unit_test.FakeContext(str(tmpdir.realpath()),
                                       generate_engine_json=False)
    check_node = mock_ctx_for_util.srcnode.make_node('Test/A/B')
    check_node.ctx = mock_ctx_2

    bld_node = check_node.get_bld()

    bld_node_abs = os.path.normpath(bld_node.abspath())

    expected_bld_node_abs = os.path.normpath(
        os.path.join(mock_ctx_for_util.bintemp_node.abspath(), 'Test', 'A',
                     'B'))

    assert bld_node_abs == expected_bld_node_abs
示例#7
0
def test_context(tmpdir):
    fake_context = unit_test.FakeContext(str(tmpdir.realpath()), False)
    return fake_context
示例#8
0
def mock_ctx_for_util(tmpdir):
    ctx = unit_test.FakeContext(str(tmpdir.realpath()),
                                generate_engine_json=False)
    return ctx