mirror of https://gitlab.com/ita1024/waf.git
More tests
This commit is contained in:
parent
12cbb42cd7
commit
a8ef298191
|
@ -2,17 +2,15 @@
|
|||
# encoding: utf-8
|
||||
# Thomas Nagy, 2016
|
||||
#
|
||||
# DESTDIR=/tmp/somedir waf install
|
||||
|
||||
def configure(conf):
|
||||
pass
|
||||
|
||||
import os
|
||||
from waflib import TaskGen, Build, Utils
|
||||
|
||||
@TaskGen.feature('ruler')
|
||||
@TaskGen.before('process_rule')
|
||||
def test(self):
|
||||
if not self.bld.is_install:
|
||||
while self.meths: # cancel everything
|
||||
if not self.bld.is_install or self.bld.is_install == Build.UNINSTALL:
|
||||
while self.meths: # do not generate tasks: the target file may not be there
|
||||
self.meths.pop()
|
||||
return
|
||||
|
||||
|
@ -21,10 +19,34 @@ def test(self):
|
|||
assert tg.install_task.outputs
|
||||
self.source = tg.install_task.outputs
|
||||
|
||||
def build(bld):
|
||||
bld.install_as('${PREFIX}/bin/foo', 'wscript', chmod=Utils.O755)
|
||||
bld.symlink_as('${PREFIX}/bin/bar', 'foo')
|
||||
tsk = bld.install_files('${PREFIX}/bin', 'wscript', chmod=Utils.O755, name='cheese')
|
||||
bld(rule='ls -l ${SRC}', always=True, bring_in='cheese', features='ruler')
|
||||
def configure(conf):
|
||||
|
||||
tmpdir = conf.bldnode.make_node('tmpdir')
|
||||
|
||||
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')
|
||||
bld(rule='ls -l ${SRC}', always=True, bring_in='cheese', features='ruler')
|
||||
|
||||
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').abspath()
|
||||
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'
|
||||
|
||||
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()
|
||||
|
||||
|
|
Loading…
Reference in New Issue