1#!/usr/bin/env python
2
3# Copyright (c) 2012 Google Inc. All rights reserved.
4# Use of this source code is governed by a BSD-style license that can be
5# found in the LICENSE file.
6
7"""
8Verifies that bundles that have no 'sources' (pure resource containers) work.
9"""
10
11import TestGyp
12
13import sys
14
15if sys.platform == 'darwin':
16  test = TestGyp.TestGyp(formats=['ninja', 'make', 'xcode'])
17
18  test.run_gyp('test.gyp', chdir='sourceless-module')
19
20  # Just needs to build without errors.
21  test.build('test.gyp', 'empty_bundle', chdir='sourceless-module')
22  test.built_file_must_not_exist(
23      'empty_bundle.bundle', chdir='sourceless-module')
24
25  # Needs to build, and contain a resource.
26  test.build('test.gyp', 'resource_bundle', chdir='sourceless-module')
27
28  test.built_file_must_exist(
29      'resource_bundle.bundle/Contents/Resources/foo.manifest',
30      chdir='sourceless-module')
31  test.built_file_must_not_exist(
32      'resource_bundle.bundle/Contents/MacOS/resource_bundle',
33      chdir='sourceless-module')
34
35  # Build an app containing an actionless bundle.
36  test.build(
37      'test.gyp',
38      'bundle_dependent_on_resource_bundle_no_actions',
39      chdir='sourceless-module')
40
41  test.built_file_must_exist(
42      'bundle_dependent_on_resource_bundle_no_actions.app/Contents/Resources/'
43          'mac_resource_bundle_no_actions.bundle/Contents/Resources/empty.txt',
44      chdir='sourceless-module')
45
46  # Needs to build and cause the bundle to be built.
47  test.build(
48      'test.gyp', 'dependent_on_resource_bundle', chdir='sourceless-module')
49
50  test.built_file_must_exist(
51      'resource_bundle.bundle/Contents/Resources/foo.manifest',
52      chdir='sourceless-module')
53  test.built_file_must_not_exist(
54      'resource_bundle.bundle/Contents/MacOS/resource_bundle',
55      chdir='sourceless-module')
56
57  # TODO(thakis): shared_libraries that have no sources but depend on static
58  # libraries currently only work with the ninja generator.  This is used by
59  # chrome/mac's components build.
60  if test.format == 'ninja':
61    # Check that an executable depending on a resource framework links fine too.
62    test.build(
63       'test.gyp', 'dependent_on_resource_framework', chdir='sourceless-module')
64
65    test.built_file_must_exist(
66        'resource_framework.framework/Resources/foo.manifest',
67        chdir='sourceless-module')
68    test.built_file_must_exist(
69        'resource_framework.framework/resource_framework',
70        chdir='sourceless-module')
71
72  test.pass_test()
73