Add tests for #2184

This commit is contained in:
Thomas Nagy 2018-09-25 18:05:10 +02:00
parent 72ba2cff1e
commit d63e32633d
No known key found for this signature in database
GPG Key ID: 49B4C67C05277AAA
1 changed files with 46 additions and 27 deletions

View File

@ -4,7 +4,10 @@
#
import os
from waflib import TaskGen, Build, Utils
from waflib import Build, Options, TaskGen, Utils
def build(bld):
bld.fatal("Not implemented! Run 'waf configure'")
@TaskGen.feature('ruler')
@TaskGen.before('process_rule')
@ -21,13 +24,14 @@ def test(self):
def configure(conf):
tmpdir = conf.bldnode.make_node('tmpdir')
tmpdir.delete(evict=False)
tmpdir_top = conf.bldnode.make_node('tmpdir')
tmpdir_top.delete(evict=False)
tmpdir = tmpdir_top.make_node('foo')
def build(bld):
bld.is_install = env.INSTALL
bld.path.make_node('tmpfile').write('test')
bld.env.PREFIX = tmpdir.abspath()
bld.install_as('${PREFIX}/bin/foo', 'tmpfile', chmod=Utils.O755)
bld.symlink_as('${PREFIX}/bin/bar', '../tmpfile')
tsk = bld.install_files('${PREFIX}/bin', 'tmpfile', chmod=Utils.O755, name='cheese')
@ -43,30 +47,45 @@ def configure(conf):
bld(features='subst', source='tmpfile', target='blah/blah/rel3', is_copy=True)
bld.install_files('${PREFIX}', 'blah/blah/rel3', relative_base=bld.path.search_node('blah').get_bld(), relative_trick=True)
bld(features='subst', source='tmpfile', target='blah/blah/rel4', is_copy=True)
bld.install_files('lib', 'blah/blah/rel4')
def check(env):
tmpdir_top.delete(evict=False)
env.INSTALL = Build.INSTALL
conf.run_build(build_fun=build, msg='building', okmsg='ok', errmsg='eh', env=env)
assert tmpdir.exists()
assert tmpdir.make_node('bin/foo').exists()
assert tmpdir.make_node('bin/tmpfile').exists()
assert tmpdir.make_node('bin/foo').read() == tmpdir.make_node('bin/tmpfile').read()
assert os.path.lexists(tmpdir.make_node('bin/bar').abspath())
assert os.readlink(tmpdir.make_node('bin/bar').abspath()) == '../tmpfile'
assert tmpdir.make_node('rel1').exists()
assert tmpdir.make_node('blah/blah/rel2').exists()
assert tmpdir.make_node('blah/rel3').exists()
assert tmpdir.make_node('lib/rel4').exists()
env.INSTALL = Build.UNINSTALL
conf.run_build(build_fun=build, msg='building', okmsg='ok', errmsg='eh', env=env)
assert not tmpdir.exists()
assert not tmpdir.make_node('bin/foo').exists()
assert not tmpdir.make_node('bin/tmpfile').exists()
assert not os.path.lexists(tmpdir.make_node('bin/bar').abspath())
assert not tmpdir.exists()
assert not tmpdir.make_node('rel1').exists()
assert not tmpdir.make_node('blah/blah/rel2').exists()
assert not tmpdir.make_node('blah/rel3').exists()
env = conf.env.derive()
env.INSTALL = Build.INSTALL
conf.run_build(build_fun=build, msg='building', okmsg='ok', errmsg='eh', env=env)
assert tmpdir.exists()
assert tmpdir.make_node('bin/foo').exists()
assert tmpdir.make_node('bin/tmpfile').exists()
assert tmpdir.make_node('bin/foo').read() == tmpdir.make_node('bin/tmpfile').read()
assert os.path.lexists(tmpdir.make_node('bin/bar').abspath())
assert os.readlink(tmpdir.make_node('bin/bar').abspath()) == '../tmpfile'
assert tmpdir.make_node('rel1').exists()
assert tmpdir.make_node('blah/blah/rel2').exists()
assert tmpdir.make_node('blah/rel3').exists()
env.PREFIX = tmpdir.abspath()
Options.options.destdir = None
check(env)
env.INSTALL = Build.UNINSTALL
conf.run_build(build_fun=build, msg='building', okmsg='ok', errmsg='eh', env=env)
assert not tmpdir.exists()
assert not tmpdir.make_node('bin/foo').exists()
assert not tmpdir.make_node('bin/tmpfile').exists()
assert not os.path.lexists(tmpdir.make_node('bin/bar').abspath())
assert not tmpdir.exists()
assert not tmpdir.make_node('rel1').exists()
assert not tmpdir.make_node('blah/blah/rel2').exists()
assert not tmpdir.make_node('blah/rel3').exists()
env = conf.env.derive()
env.PREFIX = '/foo'
Options.options.destdir = tmpdir_top.abspath()
check(env)
def build(bld):
pass