Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(531)

Side by Side Diff: test/symlinks/gyptest-symlinks.py

Issue 1365163002: Make the ninja generator handle symlinked paths correctly. (Closed) Base URL: https://chromium.googlesource.com/external/gyp@master
Patch Set: Revert CPPFLAGS_host, they will be moved to a separate CL. Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « pylib/gyp/generator/ninja.py ('k') | test/symlinks/hello.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/env python
2
3 # Copyright (c) 2015 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 Test that RelativePath(s, d) doesn't return a path starting with '..' when
9 s is textually below d, but is also a symlink to a file that is not below d.
10
11 Returning .. in this case would break the Ninja generator in such a case,
12 because it computes output directories by concatenating paths, and concat'ing
13 a path starting with .. can unexpectedly erase other parts of the path. It's
14 difficult to test this directly since the test harness assumes toplevel_dir is
15 the root of the repository, but this test should at least verify that the
16 required behavior doesn't change.
17 """
18
19 import TestGyp
20 import os
21 import sys
22 import tempfile
23
24 if sys.platform != 'win32':
25 test = TestGyp.TestGyp()
26
27 sys.path.insert(0, os.path.join(test._cwd, 'pylib'))
28 import gyp.common
scottmg 2015/09/24 22:12:16 oh, what's this for?
lindleyf 2015/09/24 22:15:50 Good catch, I think that's left over from a previo
29
30 # Copy hello.gyp and hello.c to temporary named files, which will then be
31 # symlinked back and processed. Note that we don't ask gyp to touch the
32 # original files at all; they are only there as source material for the copy.
33 # That's why hello.gyp references symlink_hello.c instead of hello.c.
34 with tempfile.NamedTemporaryFile() as gyp_file:
35 with tempfile.NamedTemporaryFile() as c_file:
36 with open('hello.gyp') as orig_gyp_file:
37 gyp_file.write(orig_gyp_file.read())
38 gyp_file.flush()
39 with open('hello.c') as orig_c_file:
40 c_file.write(orig_c_file.read())
41 c_file.flush()
42 # We need to flush the files because we want to read them before closing
43 # them, since when they are closed they will be deleted.
44
45 # Don't proceed with the test on a system that doesn't let you read from
46 # a still-open temporary file.
47 if os.path.getsize(gyp_file.name) == 0:
48 raise OSError("Copy to temporary file didn't work.")
49
50 symlink_gyp = test.built_file_path('symlink_hello.gyp')
51 symlink_c = test.built_file_path('symlink_hello.c')
52 outdir = os.path.dirname(symlink_gyp)
53
54 # Make sure the outdir exists.
55 try:
56 os.makedirs(outdir)
57 except OSError:
58 if not os.path.isdir(outdir):
59 raise
60 os.symlink(gyp_file.name, symlink_gyp)
61 os.symlink(c_file.name, symlink_c)
62
63 # Run gyp on the symlinked files.
64 test.run_gyp(symlink_gyp, chdir=outdir)
65 test.build(symlink_gyp, chdir=outdir)
66 test.run_built_executable('symlink_hello', stdout="Hello, world!\n",
67 chdir=outdir)
68
69 test.pass_test()
70
OLDNEW
« no previous file with comments | « pylib/gyp/generator/ninja.py ('k') | test/symlinks/hello.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698