Skip to content

Commit

Permalink
Remove hacky setup for CustomTargetIndex tests in fs.relative_to()
Browse files Browse the repository at this point in the history
  • Loading branch information
tristan957 authored and xclaesse committed Aug 17, 2023
1 parent 543e9ca commit 7a2b673
Showing 1 changed file with 5 additions and 21 deletions.
26 changes: 5 additions & 21 deletions test cases/common/220 fs module/subdir/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,19 @@ assert(fs.is_samepath(subdirfiles[0], 'subdirfile.txt'), 'is_samepath not detect

# More relative_to to test subdir/builddir components

python3 = find_program('python3')
build_to_src = fs.relative_to(meson.current_source_dir(), meson.current_build_dir())
src_to_build = fs.relative_to(meson.current_build_dir(), meson.current_source_dir())

btgt = executable('btgt', 'btgt.c')
ctgt = custom_target(
'copied-files',
command: [
python3,
'-c',
'import shutil; shutil.copyfile("@INPUT0@", "@OUTPUT0@"); shutil.copyfile("@INPUT1@", "@OUTPUT1@")'
],
input: [
'subdirfile.txt',
'meson.build',
],
output: [
'subdirfile.txt',
'meson.build',
],
)
ctgt = fs.copyfile('subdirfile.txt')

if build_machine.system() == 'windows'
# Test that CustomTarget works
assert(fs.relative_to('subdirfile.txt', ctgt) == '..\\@0@\\subdirfile.txt'.format(build_to_src))
assert(fs.relative_to(ctgt, 'subdirfile.txt') == '..\\@0@\\subdirfile.txt'.format(src_to_build))
# Test that CustomTargetIndex works
assert(fs.relative_to('meson.build', ctgt[1]) == '..\\@0@\\meson.build'.format(build_to_src))
assert(fs.relative_to(ctgt[1], 'meson.build') == '..\\@0@\\meson.build'.format(src_to_build))
assert(fs.relative_to('subdirfile.txt', ctgt[0]) == '..\\@0@\\subdirfile.txt'.format(build_to_src))
assert(fs.relative_to(ctgt[0], 'subdirfile.txt') == '..\\@0@\\subdirfile.txt'.format(src_to_build))
# Test that BuildTarget works
assert(fs.relative_to('subdirfile.txt', btgt) == '..\\@0@\\subdirfile.txt'.format(build_to_src))
assert(fs.relative_to(btgt, 'subdirfile.txt') == '..\\@0@\\btgt.exe'.format(src_to_build))
Expand All @@ -44,8 +28,8 @@ else
assert(fs.relative_to('subdirfile.txt', ctgt) == '../@0@/subdirfile.txt'.format(build_to_src))
assert(fs.relative_to(ctgt, 'subdirfile.txt') == '../@0@/subdirfile.txt'.format(src_to_build))
# Test that CustomTargetIndex works
assert(fs.relative_to('meson.build', ctgt[1]) == '../@0@/meson.build'.format(build_to_src))
assert(fs.relative_to(ctgt[1], 'meson.build') == '../@0@/meson.build'.format(src_to_build))
assert(fs.relative_to('subdirfile.txt', ctgt[0]) == '../@0@/subdirfile.txt'.format(build_to_src))
assert(fs.relative_to(ctgt[0], 'subdirfile.txt') == '../@0@/subdirfile.txt'.format(src_to_build))
# Test that BuildTarget works
assert(fs.relative_to('subdirfile.txt', btgt) == '../@0@/subdirfile.txt'.format(build_to_src))
if host_machine.system() == 'windows'
Expand Down

0 comments on commit 7a2b673

Please sign in to comment.