From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- .../test/win/win-tool/copies_readonly_files.gyp | 29 ++++++++++++ .../gyptest-win-tool-handles-readonly-files.py | 55 ++++++++++++++++++++++ 2 files changed, 84 insertions(+) create mode 100644 third_party/python/gyp/test/win/win-tool/copies_readonly_files.gyp create mode 100644 third_party/python/gyp/test/win/win-tool/gyptest-win-tool-handles-readonly-files.py (limited to 'third_party/python/gyp/test/win/win-tool') diff --git a/third_party/python/gyp/test/win/win-tool/copies_readonly_files.gyp b/third_party/python/gyp/test/win/win-tool/copies_readonly_files.gyp new file mode 100644 index 0000000000..3cd7e69f1a --- /dev/null +++ b/third_party/python/gyp/test/win/win-tool/copies_readonly_files.gyp @@ -0,0 +1,29 @@ +{ + 'targets': [ + { + 'target_name': 'foo', + 'type': 'none', + 'copies': [ + { + 'destination': '<(PRODUCT_DIR)/dest', + 'files': [ + 'read-only-file', + ], + }, + ], + }, # target: foo + + { + 'target_name': 'bar', + 'type': 'none', + 'copies': [ + { + 'destination': '<(PRODUCT_DIR)/dest', + 'files': [ + 'subdir/', + ], + }, + ], + }, # target: bar + ], +} diff --git a/third_party/python/gyp/test/win/win-tool/gyptest-win-tool-handles-readonly-files.py b/third_party/python/gyp/test/win/win-tool/gyptest-win-tool-handles-readonly-files.py new file mode 100644 index 0000000000..951b952775 --- /dev/null +++ b/third_party/python/gyp/test/win/win-tool/gyptest-win-tool-handles-readonly-files.py @@ -0,0 +1,55 @@ +#!/usr/bin/env python + +# Copyright (c) 2014 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. + +""" +Make sure overwriting read-only files works as expected (via win-tool). +""" + +import TestGyp + +import filecmp +import os +import stat +import sys + +if sys.platform == 'win32': + test = TestGyp.TestGyp(formats=['ninja']) + + # First, create the source files. + os.makedirs('subdir') + read_only_files = ['read-only-file', 'subdir/A', 'subdir/B', 'subdir/C'] + for f in read_only_files: + test.write(f, 'source_contents') + test.chmod(f, stat.S_IREAD) + if os.access(f, os.W_OK): + test.fail_test() + + # Second, create the read-only destination files. Note that we are creating + # them where the ninja and win-tool will try to copy them to, in order to test + # that copies overwrite the files. + os.makedirs(test.built_file_path('dest/subdir')) + for f in read_only_files: + f = os.path.join('dest', f) + test.write(test.built_file_path(f), 'SHOULD BE OVERWRITTEN') + test.chmod(test.built_file_path(f), stat.S_IREAD) + # Ensure not writable. + if os.access(test.built_file_path(f), os.W_OK): + test.fail_test() + + test.run_gyp('copies_readonly_files.gyp') + test.build('copies_readonly_files.gyp') + + # Check the destination files were overwritten by ninja. + for f in read_only_files: + f = os.path.join('dest', f) + test.must_contain(test.built_file_path(f), 'source_contents') + + # This will fail if the files are not the same mode or contents. + for f in read_only_files: + if not filecmp.cmp(f, test.built_file_path(os.path.join('dest', f))): + test.fail_test() + + test.pass_test() -- cgit v1.2.3