summaryrefslogtreecommitdiffstats
path: root/third_party/python/gyp/test/library/gyptest-shared.py
blob: a1d2985d919bf1b42cb21dea8865e81e98a70a28 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/usr/bin/env python

# Copyright (c) 2009 Google Inc. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

"""
Verifies simple build of a "Hello, world!" program with shared libraries,
including verifying that libraries are rebuilt correctly when functions
move between libraries.
"""

import TestGyp

test = TestGyp.TestGyp()

test.run_gyp('library.gyp',
             '-Dlibrary=shared_library',
             '-Dmoveable_function=lib1',
             chdir='src')

test.relocate('src', 'relocate/src')

test.build('library.gyp', test.ALL, chdir='relocate/src')

expect = """\
Hello from program.c
Hello from lib1.c
Hello from lib2.c
Hello from lib1_moveable.c
"""
test.run_built_executable('program', chdir='relocate/src', stdout=expect)


test.run_gyp('library.gyp',
             '-Dlibrary=shared_library',
             '-Dmoveable_function=lib2',
             chdir='relocate/src')

# Update program.c to force a rebuild.
test.sleep()
contents = test.read('relocate/src/program.c')
contents = contents.replace('Hello', 'Hello again')
test.write('relocate/src/program.c', contents)

test.build('library.gyp', test.ALL, chdir='relocate/src')

expect = """\
Hello again from program.c
Hello from lib1.c
Hello from lib2.c
Hello from lib2_moveable.c
"""
test.run_built_executable('program', chdir='relocate/src', stdout=expect)


test.run_gyp('library.gyp',
             '-Dlibrary=shared_library',
             '-Dmoveable_function=lib1',
             chdir='relocate/src')

# Update program.c to force a rebuild.
test.sleep()
contents = test.read('relocate/src/program.c')
contents = contents.replace('again', 'again again')
test.write('relocate/src/program.c', contents)

# TODO(sgk):  we have to force a rebuild of lib2 so that it weeds out
# the "moved" module.  This should be done in gyp by adding a dependency
# on the generated .vcproj file itself.
test.touch('relocate/src/lib2.c')

test.build('library.gyp', test.ALL, chdir='relocate/src')

expect = """\
Hello again again from program.c
Hello from lib1.c
Hello from lib2.c
Hello from lib1_moveable.c
"""
test.run_built_executable('program', chdir='relocate/src', stdout=expect)


test.pass_test()