2
0
mirror of https://gitlab.com/ita1024/waf.git synced 2024-11-25 11:19:52 +01:00

Find the order that follows the alphabet

This commit is contained in:
Thomas Nagy 2017-01-05 03:44:36 +01:00
parent e5cafe6c7a
commit fa145ed653
No known key found for this signature in database
GPG Key ID: 49B4C67C05277AAA
2 changed files with 70 additions and 4 deletions

66
tests/post/wscript Normal file
View File

@ -0,0 +1,66 @@
#! /usr/bin/env python
# encoding: utf-8
# Thomas Nagy, 2017 (ita)
top = '.'
out = 'build'
import inspect
from waflib import Utils, Logs, TaskGen
@TaskGen.taskgen_method
def log(self):
fname = inspect.stack()[1][3]
try:
self.called.append(fname)
except AttributeError:
self.called = [fname]
@TaskGen.taskgen_method
def check(self):
self.post()
result = ''.join(self.called)
if result == self.expected:
color = 'GREEN'
else:
color = 'RED'
result = 'got %r but expected %r' % (result, self.expected)
self.bld.failure = 1
Logs.pprint(color, result)
@TaskGen.feature('test1')
@TaskGen.after('d')
def a(self):
self.log()
@TaskGen.feature('test1')
@TaskGen.after('c')
def b(self):
self.log()
@TaskGen.feature('test1')
def c(self):
self.log()
@TaskGen.feature('test1')
def d(self):
self.log()
@TaskGen.feature('test1')
@TaskGen.after('f')
def e(self):
self.log()
@TaskGen.feature('test1')
def f(self):
self.log()
def configure(conf):
pass
def build(bld):
bld.failure = 0
def stop_status(bld):
if bld.failure:
bld.fatal('One or several test failed, check the outputs above')
bld.add_post_fun(stop_status)
bld(features='test1', expected='cbdafe').check()

View File

@ -190,7 +190,7 @@ class task_gen(object):
else:
tmp.append(a)
tmp.sort()
tmp.sort(reverse=True)
# topological sort
out = []
@ -210,13 +210,13 @@ class task_gen(object):
break
else:
tmp.append(x)
tmp.sort(reverse=True)
if prec:
buf = ['Cycle detected in the method execution:']
for k, v in prec.items():
buf.append('- %s after %s' % (k, [x for x in v if x in prec]))
raise Errors.WafError('\n'.join(buf))
out.reverse()
self.meths = out
# then we run the methods in order
@ -430,7 +430,7 @@ def before_method(*k):
def deco(func):
setattr(task_gen, func.__name__, func)
for fun_name in k:
task_gen.prec[fun_name].add(func.__name__)
task_gen.prec[func.__name__].add(fun_name)
return func
return deco
before = before_method
@ -457,7 +457,7 @@ def after_method(*k):
def deco(func):
setattr(task_gen, func.__name__, func)
for fun_name in k:
task_gen.prec[func.__name__].add(fun_name)
task_gen.prec[fun_name].add(func.__name__)
return func
return deco
after = after_method