OLD | NEW |
---|---|
(Empty) | |
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 """ | |
8 Verifies build of a static_library with the standalone_static_library flag set. | |
9 """ | |
10 | |
11 import os | |
12 import subprocess | |
13 import sys | |
14 import TestGyp | |
15 | |
16 test = TestGyp.TestGyp() | |
17 | |
18 # Verify that types other than static_library cause a failure. | |
19 test.run_gyp('invalid.gyp', status=1, stderr=None) | |
20 target_str = 'invalid.gyp:bad#target' | |
21 if test.format == 'scons': | |
22 target_str = os.path.join(os.path.realpath(os.curdir), target_str) | |
23 err = ['gyp: Target %s has type executable but standalone_static_library flag ' | |
24 'is only valid for static_library type.' % target_str] | |
25 test.must_contain_all_lines(test.stderr(), err) | |
26 | |
27 # Build a valid standalone_static_library. | |
28 test.run_gyp('mylib.gyp') | |
29 test.build('mylib.gyp', target='prog') | |
30 | |
31 # Verify that the static library is copied to the correct location. | |
32 if test.format in ('make', 'msvs', 'ninja'): | |
Nico
2012/10/04 02:18:58
Why is this necessary? scons? I know that xcode al
borenet
2012/10/04 16:07:47
Yep. I changed the condition; skipping the test s
| |
33 # For make/msvs/ninja, we expect the library to be copied to $PRODUCT_DIR. | |
34 standalone_static_library_dir = test.EXECUTABLE | |
35 else: | |
36 # Otherwise, we expect the library to be copied to the shared lib dir. | |
37 standalone_static_library_dir = test.SHARED_LIB | |
38 path_to_lib = os.path.split( | |
39 test.built_file_path('mylib', type=standalone_static_library_dir))[0] | |
40 lib_name = test.built_file_basename('mylib', type=test.STATIC_LIB) | |
41 path = os.path.join(path_to_lib, lib_name) | |
42 test.must_exist(path) | |
43 | |
44 # Verify that the program runs properly. | |
45 expect = 'hello from mylib.c\n' | |
46 test.run_built_executable('prog', stdout=expect) | |
47 | |
48 # Verify that libmylib.a contains symbols. "ar -x" fails on a 'thin' archive. | |
49 if test.format in ('make', 'ninja') and sys.platform.startswith('linux'): | |
50 retcode = subprocess.call(['ar', '-x', path]) | |
51 assert retcode == 0 | |
52 | |
53 test.pass_test() | |
OLD | NEW |