summaryrefslogtreecommitdiff
path: root/src/engine/SCons/BuilderTests.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/engine/SCons/BuilderTests.py')
-rw-r--r--src/engine/SCons/BuilderTests.py46
1 files changed, 24 insertions, 22 deletions
diff --git a/src/engine/SCons/BuilderTests.py b/src/engine/SCons/BuilderTests.py
index edc4ca8..dd9a917 100644
--- a/src/engine/SCons/BuilderTests.py
+++ b/src/engine/SCons/BuilderTests.py
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2001 - 2017 The SCons Foundation
+# Copyright (c) 2001 - 2019 The SCons Foundation
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
@@ -22,7 +22,7 @@
#
from __future__ import print_function
-__revision__ = "src/engine/SCons/BuilderTests.py rel_3.0.0:4395:8972f6a2f699 2017/09/18 12:59:24 bdbaddog"
+__revision__ = "src/engine/SCons/BuilderTests.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.compat
@@ -409,10 +409,6 @@ class BuilderTestCase(unittest.TestCase):
builder = SCons.Builder.Builder(generator=generator)
assert builder.action.generator == generator
- def test_get_name(self):
- """Test the get_name() method
- """
-
def test_cmp(self):
"""Test simple comparisons of Builder objects
"""
@@ -552,7 +548,7 @@ class BuilderTestCase(unittest.TestCase):
def test_src_suffix(self):
"""Test Builder creation with a specified source file suffix
-
+
Make sure that the '.' separator is appended to the
beginning if it isn't already present.
"""
@@ -680,10 +676,12 @@ class BuilderTestCase(unittest.TestCase):
def test_single_source(self):
"""Test Builder with single_source flag set"""
def func(target, source, env):
- open(str(target[0]), "w")
+ """create the file"""
+ with open(str(target[0]), "w"):
+ pass
if (len(source) == 1 and len(target) == 1):
env['CNT'][0] = env['CNT'][0] + 1
-
+
env = Environment()
infiles = []
outfiles = []
@@ -730,16 +728,18 @@ class BuilderTestCase(unittest.TestCase):
pass
else:
assert 0
-
-
+
+
def test_lists(self):
"""Testing handling lists of targets and source"""
def function2(target, source, env, tlist = [outfile, outfile2], **kw):
for t in target:
- open(str(t), 'w').write("function2\n")
+ with open(str(t), 'w') as f:
+ f.write("function2\n")
for t in tlist:
if not t in list(map(str, target)):
- open(t, 'w').write("function2\n")
+ with open(t, 'w') as f:
+ f.write("function2\n")
return 1
env = Environment()
@@ -765,10 +765,12 @@ class BuilderTestCase(unittest.TestCase):
def function3(target, source, env, tlist = [sub1_out, sub2_out]):
for t in target:
- open(str(t), 'w').write("function3\n")
+ with open(str(t), 'w') as f:
+ f.write("function3\n")
for t in tlist:
if not t in list(map(str, target)):
- open(t, 'w').write("function3\n")
+ with open(t, 'w') as f:
+ f.write("function3\n")
return 1
builder = SCons.Builder.Builder(action = function3)
@@ -875,7 +877,7 @@ class BuilderTestCase(unittest.TestCase):
def func(self):
pass
-
+
scanner = SCons.Scanner.Base(func, name='fooscan')
b1 = SCons.Builder.Builder(action='bld', target_scanner=scanner)
@@ -884,8 +886,8 @@ class BuilderTestCase(unittest.TestCase):
assert b1 == b2
assert b1 != b3
-
- def test_src_scanner(slf):
+
+ def test_src_scanner(self):
"""Testing ability to set a source file scanner through a builder."""
class TestScanner(object):
def key(self, env):
@@ -1239,7 +1241,7 @@ class BuilderTestCase(unittest.TestCase):
for t in target:
t.builder = nb
return [nn], source
-
+
builder=SCons.Builder.Builder(action='foo',
emitter=emit,
target_factory=MyNode,
@@ -1315,7 +1317,7 @@ class BuilderTestCase(unittest.TestCase):
builder2 = SCons.Builder.Builder(action='foo',
emitter='$EMITTERLIST',
node_factory=MyNode)
-
+
env = Environment(EMITTERLIST = [emit2a, emit2b])
tgts = builder2(env, target='target-2', source='aaa.2')
@@ -1413,7 +1415,7 @@ class BuilderTestCase(unittest.TestCase):
b6 = SCons.Builder.Builder(action='foo')
assert isinstance(b4, SCons.Builder.CompositeBuilder)
assert isinstance(b4.action, SCons.Action.CommandGeneratorAction)
-
+
env = Environment(BUILDERS={'bldr1': b1,
'bldr2': b2,
'bldr3': b3,
@@ -1475,7 +1477,7 @@ class CompositeBuilderTestCase(unittest.TestCase):
tgt = builder(env, source=[])
assert tgt == [], tgt
-
+
assert isinstance(builder, SCons.Builder.CompositeBuilder)
assert isinstance(builder.action, SCons.Action.CommandGeneratorAction)