diff options
Diffstat (limited to 'third_party/python/gyp/test/same-source-file-name')
15 files changed, 321 insertions, 0 deletions
diff --git a/third_party/python/gyp/test/same-source-file-name/gyptest-all.py b/third_party/python/gyp/test/same-source-file-name/gyptest-all.py new file mode 100755 index 0000000000..4c215027c2 --- /dev/null +++ b/third_party/python/gyp/test/same-source-file-name/gyptest-all.py @@ -0,0 +1,34 @@ +#!/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. + +""" +Build a .gyp with two targets that share a common .c source file. +""" + +import TestGyp + +test = TestGyp.TestGyp() + +test.run_gyp('all.gyp', chdir='src') + +test.relocate('src', 'relocate/src') + +test.build('all.gyp', test.ALL, chdir='relocate/src') + +expect1 = """\ +Hello from prog1.c +Hello prog1 from func.c +""" + +expect2 = """\ +Hello from prog2.c +Hello prog2 from func.c +""" + +test.run_built_executable('prog1', chdir='relocate/src', stdout=expect1) +test.run_built_executable('prog2', chdir='relocate/src', stdout=expect2) + +test.pass_test() diff --git a/third_party/python/gyp/test/same-source-file-name/gyptest-default.py b/third_party/python/gyp/test/same-source-file-name/gyptest-default.py new file mode 100755 index 0000000000..98757c2697 --- /dev/null +++ b/third_party/python/gyp/test/same-source-file-name/gyptest-default.py @@ -0,0 +1,34 @@ +#!/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. + +""" +Build a .gyp with two targets that share a common .c source file. +""" + +import TestGyp + +test = TestGyp.TestGyp() + +test.run_gyp('all.gyp', chdir='src') + +test.relocate('src', 'relocate/src') + +test.build('all.gyp', chdir='relocate/src') + +expect1 = """\ +Hello from prog1.c +Hello prog1 from func.c +""" + +expect2 = """\ +Hello from prog2.c +Hello prog2 from func.c +""" + +test.run_built_executable('prog1', chdir='relocate/src', stdout=expect1) +test.run_built_executable('prog2', chdir='relocate/src', stdout=expect2) + +test.pass_test() diff --git a/third_party/python/gyp/test/same-source-file-name/gyptest-pass-executable.py b/third_party/python/gyp/test/same-source-file-name/gyptest-pass-executable.py new file mode 100755 index 0000000000..1a3dcda23d --- /dev/null +++ b/third_party/python/gyp/test/same-source-file-name/gyptest-pass-executable.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python + +# Copyright (c) 2012 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. + +""" +Checks that gyp does not fail on executable targets which have several files +with the same basename. +""" + +import TestGyp + +# While MSVS supports building executables that contain several files with the +# same name, the msvs gyp generator does not. +test = TestGyp.TestGyp(formats=['!msvs']) + +test.run_gyp('double-executable.gyp', chdir='src') + +test.relocate('src', 'relocate/src') + +test.build('double-executable.gyp', test.ALL, chdir='relocate/src') + +expect = """\ +Hello from prog3.c +Hello prog3 from func.c +Hello prog3 from subdir1/func.c +Hello prog3 from subdir2/func.c +""" + +test.run_built_executable('prog3', chdir='relocate/src', stdout=expect) + +test.pass_test() diff --git a/third_party/python/gyp/test/same-source-file-name/gyptest-pass-shared.py b/third_party/python/gyp/test/same-source-file-name/gyptest-pass-shared.py new file mode 100755 index 0000000000..a498f1a846 --- /dev/null +++ b/third_party/python/gyp/test/same-source-file-name/gyptest-pass-shared.py @@ -0,0 +1,18 @@ +#!/usr/bin/env python + +# Copyright (c) 2012 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. + +""" +Checks that gyp does not fail on shared_library targets which have several files +with the same basename. +""" + +import TestGyp + +test = TestGyp.TestGyp() + +test.run_gyp('double-shared.gyp', chdir='src') + +test.pass_test() diff --git a/third_party/python/gyp/test/same-source-file-name/gyptest-static.py b/third_party/python/gyp/test/same-source-file-name/gyptest-static.py new file mode 100755 index 0000000000..7fa2772040 --- /dev/null +++ b/third_party/python/gyp/test/same-source-file-name/gyptest-static.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python + +# Copyright (c) 2012 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. + +""" +Checks that gyp fails on static_library targets which have several files with +the same basename. +""" + +import os +import sys + +import TestGyp + +test = TestGyp.TestGyp() + +# Fails by default for the compatibility with legacy generators such as +# VCProj generator for Visual C++ 2008 and Makefile generator on Mac. +# TODO: Update expected behavior when these legacy generators are deprecated. +test.run_gyp('double-static.gyp', chdir='src', status=1, stderr=None) + +if ((test.format == 'make' and sys.platform == 'darwin') or + (test.format == 'msvs' and + int(os.environ.get('GYP_MSVS_VERSION', 2010)) < 2010)): + test.run_gyp('double-static.gyp', '--no-duplicate-basename-check', + chdir='src', status=1, stderr=None) +else: + test.run_gyp('double-static.gyp', '--no-duplicate-basename-check', + chdir='src') + test.build('double-static.gyp', test.ALL, chdir='src') + +test.pass_test() diff --git a/third_party/python/gyp/test/same-source-file-name/src/all.gyp b/third_party/python/gyp/test/same-source-file-name/src/all.gyp new file mode 100644 index 0000000000..4fe052c668 --- /dev/null +++ b/third_party/python/gyp/test/same-source-file-name/src/all.gyp @@ -0,0 +1,30 @@ +# 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. + +{ + 'targets': [ + { + 'target_name': 'prog1', + 'type': 'executable', + 'defines': [ + 'PROG="prog1"', + ], + 'sources': [ + 'prog1.c', + 'func.c', + ], + }, + { + 'target_name': 'prog2', + 'type': 'executable', + 'defines': [ + 'PROG="prog2"', + ], + 'sources': [ + 'prog2.c', + 'func.c', + ], + }, + ], +} diff --git a/third_party/python/gyp/test/same-source-file-name/src/double-executable.gyp b/third_party/python/gyp/test/same-source-file-name/src/double-executable.gyp new file mode 100644 index 0000000000..477bd87e0d --- /dev/null +++ b/third_party/python/gyp/test/same-source-file-name/src/double-executable.gyp @@ -0,0 +1,21 @@ +# Copyright (c) 2012 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. + +{ + 'targets': [ + { + 'target_name': 'prog3', + 'type': 'executable', + 'sources': [ + 'prog3.c', + 'func.c', + 'subdir1/func.c', + 'subdir2/func.c', + ], + 'defines': [ + 'PROG="prog3"', + ], + }, + ], +} diff --git a/third_party/python/gyp/test/same-source-file-name/src/double-shared.gyp b/third_party/python/gyp/test/same-source-file-name/src/double-shared.gyp new file mode 100644 index 0000000000..438b50f3f1 --- /dev/null +++ b/third_party/python/gyp/test/same-source-file-name/src/double-shared.gyp @@ -0,0 +1,27 @@ +# Copyright (c) 2012 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. + +{ + 'targets': [ + { + 'target_name': 'lib', + 'product_name': 'test_shared_lib', + 'type': 'shared_library', + 'sources': [ + 'prog2.c', + 'func.c', + 'subdir1/func.c', + 'subdir2/func.c', + ], + 'defines': [ + 'PROG="prog2"', + ], + 'conditions': [ + ['OS=="linux"', { + 'cflags': ['-fPIC'], + }], + ], + }, + ], +} diff --git a/third_party/python/gyp/test/same-source-file-name/src/double-static.gyp b/third_party/python/gyp/test/same-source-file-name/src/double-static.gyp new file mode 100644 index 0000000000..e49c0e1251 --- /dev/null +++ b/third_party/python/gyp/test/same-source-file-name/src/double-static.gyp @@ -0,0 +1,22 @@ +# Copyright (c) 2012 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. + +{ + 'targets': [ + { + 'target_name': 'lib', + 'product_name': 'test_static_lib', + 'type': 'static_library', + 'sources': [ + 'prog1.c', + 'func.c', + 'subdir1/func.c', + 'subdir2/func.c', + ], + 'defines': [ + 'PROG="prog1"', + ], + }, + ], +} diff --git a/third_party/python/gyp/test/same-source-file-name/src/func.c b/third_party/python/gyp/test/same-source-file-name/src/func.c new file mode 100644 index 0000000000..e069c692a6 --- /dev/null +++ b/third_party/python/gyp/test/same-source-file-name/src/func.c @@ -0,0 +1,6 @@ +#include <stdio.h> + +void func(void) +{ + printf("Hello %s from func.c\n", PROG); +} diff --git a/third_party/python/gyp/test/same-source-file-name/src/prog1.c b/third_party/python/gyp/test/same-source-file-name/src/prog1.c new file mode 100644 index 0000000000..604e2b9c98 --- /dev/null +++ b/third_party/python/gyp/test/same-source-file-name/src/prog1.c @@ -0,0 +1,16 @@ +#include <stdio.h> + +extern void func(void); + +int main(void) +{ + printf("Hello from prog1.c\n"); + func(); + /* + * Uncomment to test same-named files in different directories, + * which Visual Studio doesn't support. + subdir1_func(); + subdir2_func(); + */ + return 0; +} diff --git a/third_party/python/gyp/test/same-source-file-name/src/prog2.c b/third_party/python/gyp/test/same-source-file-name/src/prog2.c new file mode 100644 index 0000000000..466ee35003 --- /dev/null +++ b/third_party/python/gyp/test/same-source-file-name/src/prog2.c @@ -0,0 +1,16 @@ +#include <stdio.h> + +extern void func(void); + +int main(void) +{ + printf("Hello from prog2.c\n"); + func(); + /* + * Uncomment to test same-named files in different directories, + * which Visual Studio doesn't support. + subdir1_func(); + subdir2_func(); + */ + return 0; +} diff --git a/third_party/python/gyp/test/same-source-file-name/src/prog3.c b/third_party/python/gyp/test/same-source-file-name/src/prog3.c new file mode 100644 index 0000000000..34d495ce08 --- /dev/null +++ b/third_party/python/gyp/test/same-source-file-name/src/prog3.c @@ -0,0 +1,18 @@ +// Copyright (c) 2012 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. + +#include <stdio.h> + +extern void func(void); +extern void subdir1_func(void); +extern void subdir2_func(void); + +int main(void) +{ + printf("Hello from prog3.c\n"); + func(); + subdir1_func(); + subdir2_func(); + return 0; +} diff --git a/third_party/python/gyp/test/same-source-file-name/src/subdir1/func.c b/third_party/python/gyp/test/same-source-file-name/src/subdir1/func.c new file mode 100644 index 0000000000..b73450d105 --- /dev/null +++ b/third_party/python/gyp/test/same-source-file-name/src/subdir1/func.c @@ -0,0 +1,6 @@ +#include <stdio.h> + +void subdir1_func(void) +{ + printf("Hello %s from subdir1/func.c\n", PROG); +} diff --git a/third_party/python/gyp/test/same-source-file-name/src/subdir2/func.c b/third_party/python/gyp/test/same-source-file-name/src/subdir2/func.c new file mode 100644 index 0000000000..0248b5720e --- /dev/null +++ b/third_party/python/gyp/test/same-source-file-name/src/subdir2/func.c @@ -0,0 +1,6 @@ +#include <stdio.h> + +void subdir2_func(void) +{ + printf("Hello %s from subdir2/func.c\n", PROG); +} |