-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
325dd87
commit 7c7878c
Showing
4 changed files
with
75 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import os | ||
import time | ||
from uranium.rules import rule, WasChanged | ||
|
||
|
||
def test_unchanged(tmpdir, build): | ||
|
||
g = [] | ||
|
||
tmpdir.join("foo.txt").write("foo") | ||
|
||
@build.task | ||
@rule(WasChanged("./foo.txt")) | ||
def main(build): | ||
g.append("ran") | ||
|
||
build.run_task("main") | ||
assert "ran" in g | ||
build.run_task("main") | ||
assert len(g) == 1 | ||
|
||
|
||
def test_changed(tmpdir, build): | ||
|
||
g = [] | ||
|
||
f_path = os.path.join(tmpdir.strpath, "foo.txt") | ||
|
||
with open(f_path, "w+") as fh: | ||
fh.write("foo") | ||
|
||
@build.task | ||
@rule(WasChanged("./foo.txt")) | ||
def main(build): | ||
g.append("ran") | ||
|
||
build.run_task("main") | ||
assert "ran" in g | ||
# for some reason we need a sleep | ||
# here. I think it's not considering | ||
# milliseconds. | ||
time.sleep(1) | ||
os.utime(f_path) | ||
build.run_task("main") | ||
assert len(g) == 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from abc import ABCMeta, abstractmethod | ||
|
||
|
||
class RuleBase(object): | ||
""" | ||
an example of a rule. | ||
* func gets set during the initialization process. | ||
""" | ||
func = None | ||
|
||
__metaclass__ = ABCMeta | ||
|
||
@abstractmethod | ||
def before(self, build): | ||
pass | ||
|
||
@abstractmethod | ||
def after(self, build): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters