summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMats Wichmann <mats@linux.com>2019-05-03 18:56:48 (GMT)
committerMats Wichmann <mats@linux.com>2019-05-03 18:56:48 (GMT)
commit2f097b05561d5db58edf079b11ce46b89544ce18 (patch)
tree5933256d88314369848ad2349badd45ff8c76c2d
parent624df56fb21efc3fa0e8851964dd11d942d55ee3 (diff)
downloadSCons-2f097b05561d5db58edf079b11ce46b89544ce18.zip
SCons-2f097b05561d5db58edf079b11ce46b89544ce18.tar.gz
SCons-2f097b05561d5db58edf079b11ce46b89544ce18.tar.bz2
Rework the failed-builds test
test/Parallel/failed-builds.py has been sporadically failing on the CI builds. Rework it a bit to see if it improves. Signed-off-by: Mats Wichmann <mats@linux.com>
-rw-r--r--test/Parallel/failed-build.py65
1 files changed, 34 insertions, 31 deletions
diff --git a/test/Parallel/failed-build.py b/test/Parallel/failed-build.py
index 12a8f04..6d8448b 100644
--- a/test/Parallel/failed-build.py
+++ b/test/Parallel/failed-build.py
@@ -60,48 +60,51 @@ test = TestSCons.TestSCons()
# could detect our successful exit first (typically if a high system
# load happens to delay the failure script) and start another job before
# it sees the failure from the first script.
+#
+# Both scripts are set to bail if they had to wait too long for what
+# they expected to see.
-test.write('myfail.py', r"""\
+test.write('myfail.py', """\
import os
import sys
import time
-for i in [1, 2, 3, 4, 5]:
- time.sleep(2)
- if os.path.exists('mycopy.started'):
- os.mkdir('myfail.exiting')
- sys.exit(1)
-sys.exit(99)
+WAIT = 10
+count = 0
+while not os.path.exists('mycopy.started') and count < WAIT:
+ time.sleep(1)
+ count += 1
+if count >= WAIT:
+ sys.exit(99)
+os.mkdir('myfail.exiting')
+sys.exit(1)
""")
-test.write('mycopy.py', r"""\
+test.write('mycopy.py', """\
import os
import sys
import time
-try:
- os.makedirs('mycopy.started', exist_ok=True)
-except TypeError: # Python 2 has no exist_ok
- try:
- os.mkdir('mycopy.started')
- except FileExistsError:
- pass
-
+os.mkdir('mycopy.started')
with open(sys.argv[1], 'wb') as ofp, open(sys.argv[2], 'rb') as ifp:
ofp.write(ifp.read())
-for i in [1, 2, 3, 4, 5]:
- time.sleep(2)
- if os.path.exists('myfail.exiting'):
- sys.exit(0)
-sys.exit(99)
+WAIT = 10
+count = 0
+while not os.path.exists('myfail.exiting') and count < WAIT:
+ time.sleep(1)
+ count += 1
+if count >= WAIT:
+ sys.exit(99)
+os.rmdir('mycopy.started')
+sys.exit(0)
""")
test.write('SConstruct', """
-MyCopy = Builder(action = [[r'%(python)s', 'mycopy.py', '$TARGET', '$SOURCE']])
-Fail = Builder(action = [[r'%(python)s', 'myfail.py', '$TARGETS', '$SOURCE']])
-env = Environment(BUILDERS = { 'MyCopy' : MyCopy, 'Fail' : Fail })
-env.Fail(target = 'f3', source = 'f3.in')
-env.MyCopy(target = 'f4', source = 'f4.in')
-env.MyCopy(target = 'f5', source = 'f5.in')
-env.MyCopy(target = 'f6', source = 'f6.in')
+MyCopy = Builder(action=[[r'%(python)s', 'mycopy.py', '$TARGET', '$SOURCE']])
+Fail = Builder(action=[[r'%(python)s', 'myfail.py', '$TARGETS', '$SOURCE']])
+env = Environment(BUILDERS={'MyCopy' : MyCopy, 'Fail' : Fail})
+env.Fail(target='f3', source='f3.in')
+env.MyCopy(target='f4', source='f4.in')
+env.MyCopy(target='f5', source='f5.in')
+env.MyCopy(target='f6', source='f6.in')
""" % locals())
test.write('f3.in', "f3.in\n")
@@ -109,9 +112,9 @@ test.write('f4.in', "f4.in\n")
test.write('f5.in', "f5.in\n")
test.write('f6.in', "f6.in\n")
-test.run(arguments = '-j 2 .',
- status = 2,
- stderr = "scons: *** [f3] Error 1\n")
+test.run(arguments='-j 2 .',
+ status=2,
+ stderr="scons: *** [f3] Error 1\n")
test.must_not_exist(test.workpath('f3'))
test.must_match(test.workpath('f4'), 'f4.in\n')