Skip to content

Commit d88176e

Browse files
paolopasgrafikrobot
authored andcommitted
Rework delay logic in various tests to be consistent.
fixes #582
1 parent cf28fda commit d88176e

5 files changed

Lines changed: 83 additions & 155 deletions

test/core_option_l.py

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,43 +2,29 @@
22

33
# Copyright 2007 Rene Rivera.
44
# Copyright 2011 Steven Watanabe
5+
# Copyright 2026 Paolo Pastori
56
# Distributed under the Boost Software License, Version 1.0.
67
# (See accompanying file LICENSE.txt or copy at
78
# https://www.bfgroup.xyz/b2/LICENSE.txt)
89

910
import BoostBuild
11+
import sys
1012

11-
t = BoostBuild.Tester(pass_toolset=0)
13+
sleep_s = 1.5
1214

13-
t.write("sleep.bat", """\
14-
::@timeout /T %1 /NOBREAK >nul
15-
@ping 127.0.0.1 -n 2 -w 1000 >nul
16-
@ping 127.0.0.1 -n %1 -w 1000 >nul
17-
@exit /B 0
18-
""")
15+
t = BoostBuild.Tester(pass_toolset=False)
1916

2017
t.write("file.jam", """\
21-
if $(NT)
22-
{
23-
SLEEP = @call sleep.bat ;
24-
}
25-
else
26-
{
27-
SLEEP = sleep ;
28-
}
29-
30-
actions .a. {
31-
echo 001
32-
$(SLEEP) 4
33-
echo 002
34-
}
18+
actions .a. {{
19+
"{}" -c "import time; time.sleep({})"
20+
}}
3521
3622
.a. sleeper ;
3723
3824
DEPENDS all : sleeper ;
39-
""")
25+
""".format(sys.executable, sleep_s))
4026

41-
t.run_build_system(["-ffile.jam", "-d1", "-l2"], status=1)
42-
t.expect_output_lines("2 second time limit exceeded")
27+
t.run_build_system(["-ffile.jam", "-l1"], status=1)
28+
t.expect_output_lines("1 second time limit exceeded")
4329

4430
t.cleanup()

test/core_parallel_actions.py

Lines changed: 24 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -2,64 +2,49 @@
22

33
# Copyright 2006 Rene Rivera.
44
# Copyright 2011 Steven Watanabe
5+
# Copyright 2026 Paolo Pastori
56
# Distributed under the Boost Software License, Version 1.0.
67
# (See accompanying file LICENSE.txt or https://www.bfgroup.xyz/b2/LICENSE.txt)
78

89
import BoostBuild
10+
import sys
911

10-
t = BoostBuild.Tester(["-d1"], pass_toolset=0)
11-
12-
t.write("sleep.bat", """\
13-
::@timeout /T %1 /NOBREAK >nul
14-
@ping 127.0.0.1 -n 2 -w 1000 >nul
15-
@ping 127.0.0.1 -n %1 -w 1000 >nul
16-
@exit /B 0
17-
""")
12+
t = BoostBuild.Tester(["-d1"], pass_toolset=False)
1813

1914
t.write("file.jam", """\
20-
if $(NT)
21-
{
22-
actions sleeper
23-
{
24-
call sleep.bat $(<:B)
25-
}
26-
}
27-
else
28-
{
29-
actions sleeper
30-
{
31-
sleep $(<:B)
32-
}
33-
}
15+
actions sleeper
16+
{{
17+
"{}" -c "import time; time.sleep($(<:B))"
18+
}}
3419
3520
rule sleeper
36-
{
21+
{{
3722
DEPENDS $(<) : $(>) ;
38-
}
23+
}}
3924
4025
NOTFILE front ;
41-
sleeper 1.a : front ;
42-
sleeper 2.a : front ;
43-
sleeper 3.a : front ;
26+
sleeper 0.2.a : front ;
27+
sleeper 0.3.a : front ;
28+
sleeper 0.4.a : front ;
4429
NOTFILE choke ;
45-
DEPENDS choke : 1.a 2.a 3.a ;
46-
sleeper 1.b : choke ;
47-
sleeper 2.b : choke ;
48-
sleeper 3.b : choke ;
49-
DEPENDS bottom : 1.b 2.b 3.b ;
30+
DEPENDS choke : 0.2.a 0.3.a 0.4.a ;
31+
sleeper 0.2.b : choke ;
32+
sleeper 0.3.b : choke ;
33+
sleeper 0.4.b : choke ;
34+
DEPENDS bottom : 0.2.b 0.3.b 0.4.b ;
5035
DEPENDS all : bottom ;
51-
""")
36+
""".format(sys.executable))
5237

5338
t.run_build_system(["-ffile.jam", "-j3"])
5439
t.expect_output_lines("""\
5540
...found 10 targets...
5641
...updating 6 targets...
57-
sleeper [123].a
58-
sleeper [123].a
59-
sleeper [123].a
60-
sleeper [123].b
61-
sleeper [123].b
62-
sleeper [123].b
42+
sleeper 0.[234].a
43+
sleeper 0.[2-4].a
44+
sleeper 0.[234].a
45+
sleeper 0.[2-4].b
46+
sleeper 0.[234].b
47+
sleeper 0.[2-4].b
6348
6449
...updated 6 targets...
6550
""")

test/core_parallel_multifile_actions_1.py

Lines changed: 16 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
# Copyright 2007 Rene Rivera.
44
# Copyright 2011 Steven Watanabe
5+
# Copyright 2026 Paolo Pastori
56
# Distributed under the Boost Software License, Version 1.0.
67
# (See accompanying file LICENSE.txt or https://www.bfgroup.xyz/b2/LICENSE.txt)
78

@@ -16,51 +17,39 @@
1617
# depending on target A to be built prematurely.
1718

1819
import BoostBuild
20+
import sys
1921

20-
t = BoostBuild.Tester(["-d1"], pass_toolset=0)
22+
sleep1_s = 1.0
23+
sleep2_s = 0.1
2124

22-
t.write("sleep.bat", """\
23-
::@timeout /T %1 /NOBREAK >nul
24-
@ping 127.0.0.1 -n 2 -w 1000 >nul
25-
@ping 127.0.0.1 -n %1 -w 1000 >nul
26-
@exit /B 0
27-
""")
25+
t = BoostBuild.Tester(["-d1"], pass_toolset=False)
2826

2927
t.write("file.jam", """\
30-
if $(NT)
31-
{
32-
SLEEP = @call sleep.bat ;
33-
}
34-
else
35-
{
36-
SLEEP = sleep ;
37-
}
38-
3928
actions .gen.
40-
{
29+
{{
4130
echo 001
42-
$(SLEEP) 4
31+
"{0}" -c "import time; time.sleep({1})"
4332
echo 002
44-
}
45-
rule .use.1 { DEPENDS $(<) : $(>) ; }
33+
}}
34+
rule .use.1 {{ DEPENDS $(<) : $(>) ; }}
4635
actions .use.1
47-
{
36+
{{
4837
echo 003
49-
}
38+
}}
5039
51-
rule .use.2 { DEPENDS $(<) : $(>) ; }
40+
rule .use.2 {{ DEPENDS $(<) : $(>) ; }}
5241
actions .use.2
53-
{
54-
$(SLEEP) 1
42+
{{
43+
"{0}" -c "import time; time.sleep({2})"
5544
echo 004
56-
}
45+
}}
5746
5847
.gen. g1.generated g2.generated ;
5948
.use.1 u1.user : g1.generated ;
6049
.use.2 u2.user : g2.generated ;
6150
6251
DEPENDS all : u1.user u2.user ;
63-
""")
52+
""".format(sys.executable, sleep1_s, sleep2_s))
6453

6554
t.run_build_system(["-ffile.jam", "-j2"], stdout="""\
6655
...found 5 targets...

test/core_parallel_multifile_actions_2.py

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
# Copyright 2008 Jurko Gospodnetic, Vladimir Prus
44
# Copyright 2011 Steven Watanabe
5+
# Copyright 2026 Paolo Pastori
56
# Distributed under the Boost Software License, Version 1.0.
67
# (See accompanying file LICENSE.txt or https://www.bfgroup.xyz/b2/LICENSE.txt)
78

@@ -19,44 +20,31 @@
1920
# prematurely.
2021

2122
import BoostBuild
23+
import sys
2224

23-
t = BoostBuild.Tester(pass_toolset=0)
25+
sleep_s = 0.2
2426

25-
t.write("sleep.bat", """\
26-
::@timeout /T %1 /NOBREAK >nul
27-
@ping 127.0.0.1 -n 2 -w 1000 >nul
28-
@ping 127.0.0.1 -n %1 -w 1000 >nul
29-
@exit /B 0
30-
""")
27+
t = BoostBuild.Tester(pass_toolset=False)
3128

3229
t.write("file.jam", """\
33-
if $(NT)
34-
{
35-
SLEEP = @call sleep.bat ;
36-
}
37-
else
38-
{
39-
SLEEP = sleep ;
40-
}
41-
4230
actions link
43-
{
44-
$(SLEEP) 1
31+
{{
32+
"{}" -c "import time; time.sleep({})"
4533
echo 001 - linked
46-
}
34+
}}
4735
4836
link dll lib ;
4937
5038
actions install
51-
{
39+
{{
5240
echo 002 - installed
53-
}
41+
}}
5442
5543
install installed_dll : dll ;
5644
DEPENDS installed_dll : dll ;
5745
5846
DEPENDS all : lib installed_dll ;
59-
""")
47+
""".format(sys.executable, sleep_s))
6048

6149
t.run_build_system(["-ffile.jam", "-j2"], stdout="""\
6250
...found 4 targets...

0 commit comments

Comments
 (0)