From 2ea284bac1dce5ac659aaaa68f4c36f6278ed340 Mon Sep 17 00:00:00 2001 From: Jussi Pakkanen Date: Mon, 6 Nov 2023 18:30:00 +0200 Subject: Prohibit symlinks in test data dir because they get mangled by setup.py. --- run_format_tests.py | 8 +++++ run_project_tests.py | 21 ++++++++++++ .../foo/file1 | 1 + .../meson.build | 38 ++++++++++++++++++++++ .../test.json | 14 ++++++++ .../foo/file1 | 1 - .../foo/link1 | 1 - .../foo/link2.h | 1 - .../meson.build | 38 ---------------------- .../test.json | 14 -------- .../subprojects/no-warn/meson_options.txt | 2 +- 11 files changed, 83 insertions(+), 56 deletions(-) mode change 100644 => 100755 run_format_tests.py create mode 100644 test cases/common/268 install functions and follow symlinks/foo/file1 create mode 100644 test cases/common/268 install functions and follow symlinks/meson.build create mode 100644 test cases/common/268 install functions and follow symlinks/test.json delete mode 100644 test cases/common/268 install functions and follow_symlinks/foo/file1 delete mode 120000 test cases/common/268 install functions and follow_symlinks/foo/link1 delete mode 120000 test cases/common/268 install functions and follow_symlinks/foo/link2.h delete mode 100644 test cases/common/268 install functions and follow_symlinks/meson.build delete mode 100644 test cases/common/268 install functions and follow_symlinks/test.json mode change 120000 => 100644 test cases/warning/9 meson.options/subprojects/no-warn/meson_options.txt diff --git a/run_format_tests.py b/run_format_tests.py old mode 100644 new mode 100755 index 70fa1212e..ca3e715f2 --- a/run_format_tests.py +++ b/run_format_tests.py @@ -75,9 +75,17 @@ def check_format() -> None: continue check_file(root / file) +def check_symlinks(): + for f in Path('test cases').glob('**/*'): + if f.is_symlink(): + if 'boost symlinks' in str(f): + continue + raise SystemExit(f'Test data dir contains symlink: {f}.') + if __name__ == '__main__': script_dir = os.path.split(__file__)[0] if script_dir != '': os.chdir(script_dir) check_format() + check_symlinks() diff --git a/run_project_tests.py b/run_project_tests.py index 7ff164086..39bf1628f 100755 --- a/run_project_tests.py +++ b/run_project_tests.py @@ -1561,6 +1561,14 @@ def print_tool_versions() -> None: print('{0:<{2}}: {1}'.format(tool.tool, get_version(tool), max_width)) print() +tmpdir = list(Path('.').glob('**/*install functions and follow symlinks')) +print(tmpdir) +assert(len(tmpdir) == 1) +symlink_test_dir = tmpdir[0] +symlink_file1 = symlink_test_dir / 'foo/link1' +symlink_file2 = symlink_test_dir / 'foo/link2.h' +del tmpdir + def clear_transitive_files() -> None: a = Path('test cases/common') for d in a.glob('*subproject subdir/subprojects/subsubsub*'): @@ -1568,6 +1576,18 @@ def clear_transitive_files() -> None: mesonlib.windows_proof_rmtree(str(d)) else: mesonlib.windows_proof_rm(str(d)) + try: + symlink_file1.unlink() + except FileNotFoundError: + pass + try: + symlink_file2.unlink() + except FileNotFoundError: + pass + +def setup_symlinks() -> None: + symlink_file1.symlink_to('file1') + symlink_file2.symlink_to('file1') if __name__ == '__main__': if under_ci and not raw_ci_jobname: @@ -1611,6 +1631,7 @@ if __name__ == '__main__': options.extra_args += ['--native-file', options.native_file] clear_transitive_files() + setup_symlinks() print('Meson build system', meson_version, 'Project Tests') print('Using python', sys.version.split('\n')[0], f'({sys.executable!r})') diff --git a/test cases/common/268 install functions and follow symlinks/foo/file1 b/test cases/common/268 install functions and follow symlinks/foo/file1 new file mode 100644 index 000000000..9daeafb98 --- /dev/null +++ b/test cases/common/268 install functions and follow symlinks/foo/file1 @@ -0,0 +1 @@ +test diff --git a/test cases/common/268 install functions and follow symlinks/meson.build b/test cases/common/268 install functions and follow symlinks/meson.build new file mode 100644 index 000000000..327c02131 --- /dev/null +++ b/test cases/common/268 install functions and follow symlinks/meson.build @@ -0,0 +1,38 @@ +project('install_data following symlinks') + +install_data( + 'foo/link1', + install_dir: get_option('datadir') / 'followed', + follow_symlinks: true, +) + +install_headers( + 'foo/link2.h', + follow_symlinks: true, + subdir: 'followed' +) + +install_data( + 'foo/link1', + install_dir: get_option('datadir'), + follow_symlinks: false, +) + +install_headers( + 'foo/link2.h', + follow_symlinks: false, +) + +install_subdir( + 'foo', + install_dir: get_option('datadir') / 'subdir', + strip_directory: true, + follow_symlinks: false, +) + +install_subdir( + 'foo', + install_dir: get_option('datadir') / 'subdir_followed', + strip_directory: true, + follow_symlinks: true, +) diff --git a/test cases/common/268 install functions and follow symlinks/test.json b/test cases/common/268 install functions and follow symlinks/test.json new file mode 100644 index 000000000..6a395177d --- /dev/null +++ b/test cases/common/268 install functions and follow symlinks/test.json @@ -0,0 +1,14 @@ +{ + "installed": [ + {"type": "link", "file": "usr/share/link1"}, + {"type": "link", "file": "usr/include/link2.h"}, + {"type": "file", "file": "usr/share/followed/link1"}, + {"type": "file", "file": "usr/include/followed/link2.h"}, + {"type": "link", "file": "usr/share/subdir/link1"}, + {"type": "link", "file": "usr/share/subdir/link2.h"}, + {"type": "file", "file": "usr/share/subdir/file1"}, + {"type": "file", "file": "usr/share/subdir_followed/link1"}, + {"type": "file", "file": "usr/share/subdir_followed/link2.h"}, + {"type": "file", "file": "usr/share/subdir_followed/file1"} + ] +} diff --git a/test cases/common/268 install functions and follow_symlinks/foo/file1 b/test cases/common/268 install functions and follow_symlinks/foo/file1 deleted file mode 100644 index 9daeafb98..000000000 --- a/test cases/common/268 install functions and follow_symlinks/foo/file1 +++ /dev/null @@ -1 +0,0 @@ -test diff --git a/test cases/common/268 install functions and follow_symlinks/foo/link1 b/test cases/common/268 install functions and follow_symlinks/foo/link1 deleted file mode 120000 index 08219db9b..000000000 --- a/test cases/common/268 install functions and follow_symlinks/foo/link1 +++ /dev/null @@ -1 +0,0 @@ -file1 \ No newline at end of file diff --git a/test cases/common/268 install functions and follow_symlinks/foo/link2.h b/test cases/common/268 install functions and follow_symlinks/foo/link2.h deleted file mode 120000 index 08219db9b..000000000 --- a/test cases/common/268 install functions and follow_symlinks/foo/link2.h +++ /dev/null @@ -1 +0,0 @@ -file1 \ No newline at end of file diff --git a/test cases/common/268 install functions and follow_symlinks/meson.build b/test cases/common/268 install functions and follow_symlinks/meson.build deleted file mode 100644 index 327c02131..000000000 --- a/test cases/common/268 install functions and follow_symlinks/meson.build +++ /dev/null @@ -1,38 +0,0 @@ -project('install_data following symlinks') - -install_data( - 'foo/link1', - install_dir: get_option('datadir') / 'followed', - follow_symlinks: true, -) - -install_headers( - 'foo/link2.h', - follow_symlinks: true, - subdir: 'followed' -) - -install_data( - 'foo/link1', - install_dir: get_option('datadir'), - follow_symlinks: false, -) - -install_headers( - 'foo/link2.h', - follow_symlinks: false, -) - -install_subdir( - 'foo', - install_dir: get_option('datadir') / 'subdir', - strip_directory: true, - follow_symlinks: false, -) - -install_subdir( - 'foo', - install_dir: get_option('datadir') / 'subdir_followed', - strip_directory: true, - follow_symlinks: true, -) diff --git a/test cases/common/268 install functions and follow_symlinks/test.json b/test cases/common/268 install functions and follow_symlinks/test.json deleted file mode 100644 index 6a395177d..000000000 --- a/test cases/common/268 install functions and follow_symlinks/test.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "installed": [ - {"type": "link", "file": "usr/share/link1"}, - {"type": "link", "file": "usr/include/link2.h"}, - {"type": "file", "file": "usr/share/followed/link1"}, - {"type": "file", "file": "usr/include/followed/link2.h"}, - {"type": "link", "file": "usr/share/subdir/link1"}, - {"type": "link", "file": "usr/share/subdir/link2.h"}, - {"type": "file", "file": "usr/share/subdir/file1"}, - {"type": "file", "file": "usr/share/subdir_followed/link1"}, - {"type": "file", "file": "usr/share/subdir_followed/link2.h"}, - {"type": "file", "file": "usr/share/subdir_followed/file1"} - ] -} diff --git a/test cases/warning/9 meson.options/subprojects/no-warn/meson_options.txt b/test cases/warning/9 meson.options/subprojects/no-warn/meson_options.txt deleted file mode 120000 index 7b28df279..000000000 --- a/test cases/warning/9 meson.options/subprojects/no-warn/meson_options.txt +++ /dev/null @@ -1 +0,0 @@ -meson.options \ No newline at end of file diff --git a/test cases/warning/9 meson.options/subprojects/no-warn/meson_options.txt b/test cases/warning/9 meson.options/subprojects/no-warn/meson_options.txt new file mode 100644 index 000000000..b84ee83fc --- /dev/null +++ b/test cases/warning/9 meson.options/subprojects/no-warn/meson_options.txt @@ -0,0 +1 @@ +option('foo', type : 'string') -- cgit v1.2.3