From d63e32633d60c0dac388cde8de001cc2b8b1fd62 Mon Sep 17 00:00:00 2001 From: Thomas Nagy Date: Tue, 25 Sep 2018 18:05:10 +0200 Subject: [PATCH] Add tests for #2184 --- tests/install/wscript | 73 +++++++++++++++++++++++++++---------------- 1 file changed, 46 insertions(+), 27 deletions(-) diff --git a/tests/install/wscript b/tests/install/wscript index 718f796d..826d0ad4 100644 --- a/tests/install/wscript +++ b/tests/install/wscript @@ -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