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"""
8Make sure paths are normalized with VS macros properly expanded on Windows.
9"""
10
11import TestGyp
12
13import sys
14
15if sys.platform == 'win32':
16  test = TestGyp.TestGyp(formats=['ninja'])
17
18  test.run_gyp('normalize-paths.gyp')
19
20  # We can't use existence tests because any case will pass, so we check the
21  # contents of ninja files directly since that's what we're most concerned
22  # with anyway.
23  subninja = open(test.built_file_path('obj/some_target.ninja')).read()
24  if '$!product_dir' in subninja:
25    test.fail_test()
26  if 'out\\Default' in subninja:
27    test.fail_test()
28
29  second = open(test.built_file_path('obj/second.ninja')).read()
30  if ('..\\..\\things\\AnotherName.exe' in second or
31      'AnotherName.exe' not in second):
32    test.fail_test()
33
34  copytarget = open(test.built_file_path('obj/copy_target.ninja')).read()
35  if '$(VSInstallDir)' in copytarget:
36    test.fail_test()
37
38  action = open(test.built_file_path('obj/action.ninja')).read()
39  if '..\\..\\out\\Default' in action:
40    test.fail_test()
41  if '..\\..\\SomethingElse' in action or 'SomethingElse' not in action:
42    test.fail_test()
43  if '..\\..\\SomeOtherInput' in action or 'SomeOtherInput' not in action:
44    test.fail_test()
45
46  test.pass_test()
47