@@ -1193,18 +1193,6 @@ def test_ENV(self) -> None:
1193
1193
1194
1194
def test_ReservedVariables (self ) -> None :
1195
1195
"""Test warning generation when reserved variable names are set"""
1196
-
1197
- reserved_variables = [
1198
- 'CHANGED_SOURCES' ,
1199
- 'CHANGED_TARGETS' ,
1200
- 'SOURCE' ,
1201
- 'SOURCES' ,
1202
- 'TARGET' ,
1203
- 'TARGETS' ,
1204
- 'UNCHANGED_SOURCES' ,
1205
- 'UNCHANGED_TARGETS' ,
1206
- ]
1207
-
1208
1196
warning = SCons .Warnings .ReservedVariableWarning
1209
1197
SCons .Warnings .enableWarningClass (warning )
1210
1198
old = SCons .Warnings .warningAsException (1 )
@@ -1759,19 +1747,26 @@ def test_AppendENVPath(self) -> None:
1759
1747
ENV = {'PATH' : r'C:\dir\num\one;C:\dir\num\two' },
1760
1748
MYENV = {'MYPATH' : r'C:\mydir\num\one;C:\mydir\num\two' },
1761
1749
)
1750
+
1762
1751
# have to include the pathsep here so that the test will work on UNIX too.
1763
1752
env1 .AppendENVPath ('PATH' , r'C:\dir\num\two' , sep = ';' )
1764
1753
env1 .AppendENVPath ('PATH' , r'C:\dir\num\three' , sep = ';' )
1765
- env1 .AppendENVPath ('MYPATH' , r'C:\mydir\num\three' , 'MYENV' , sep = ';' )
1766
1754
assert (
1767
1755
env1 ['ENV' ]['PATH' ] == r'C:\dir\num\one;C:\dir\num\two;C:\dir\num\three'
1768
1756
), env1 ['ENV' ]['PATH' ]
1769
1757
1758
+ # add nonexisting - at end
1770
1759
env1 .AppendENVPath ('MYPATH' , r'C:\mydir\num\three' , 'MYENV' , sep = ';' )
1760
+ assert (
1761
+ env1 ['MYENV' ]['MYPATH' ] == r'C:\mydir\num\one;C:\mydir\num\two;C:\mydir\num\three'
1762
+ ), env1 ['MYENV' ]['MYPATH' ]
1763
+
1764
+ # add existing with delete_existing true - moves to the end
1771
1765
env1 .AppendENVPath (
1772
- 'MYPATH' , r'C:\mydir\num\one' , 'MYENV' , sep = ';' , delete_existing = 1
1766
+ 'MYPATH' , r'C:\mydir\num\one' , 'MYENV' , sep = ';' , delete_existing = True
1773
1767
)
1774
- # this should do nothing since delete_existing is 0
1768
+ # this should do nothing since delete_existing is false (the default)
1769
+ env1 .AppendENVPath ('MYPATH' , r'C:\mydir\num\three' , 'MYENV' , sep = ';' )
1775
1770
assert (
1776
1771
env1 ['MYENV' ]['MYPATH' ] == r'C:\mydir\num\two;C:\mydir\num\three;C:\mydir\num\one'
1777
1772
), env1 ['MYENV' ]['MYPATH' ]
@@ -1783,6 +1778,7 @@ def test_AppendENVPath(self) -> None:
1783
1778
env1 .AppendENVPath ('PATH' , env1 .fs .Dir ('sub2' ), sep = ';' )
1784
1779
assert env1 ['ENV' ]['PATH' ] == p + ';sub1;sub2' , env1 ['ENV' ]['PATH' ]
1785
1780
1781
+
1786
1782
def test_AppendUnique (self ) -> None :
1787
1783
"""Test appending to unique values to construction variables
1788
1784
@@ -1832,34 +1828,46 @@ def test_AppendUnique(self) -> None:
1832
1828
assert env ['CCC1' ] == 'c1' , env ['CCC1' ]
1833
1829
assert env ['CCC2' ] == ['c2' ], env ['CCC2' ]
1834
1830
assert env ['DDD1' ] == ['a' , 'b' , 'c' ], env ['DDD1' ]
1835
- assert env ['LL1' ] == [env .Literal ('a literal' ), env .Literal ('b literal' )], env ['LL1' ]
1836
- assert env ['LL2' ] == [env .Literal ('c literal' ), env .Literal ('b literal' ), env .Literal ('a literal' )], [str (x ) for x in env ['LL2' ]]
1831
+ assert env ['LL1' ] == [env .Literal ('a literal' ), \
1832
+ env .Literal ('b literal' )], env ['LL1' ]
1833
+ assert env ['LL2' ] == [
1834
+ env .Literal ('c literal' ),
1835
+ env .Literal ('b literal' ),
1836
+ env .Literal ('a literal' ),
1837
+ ], [str (x ) for x in env ['LL2' ]]
1838
+
1839
+ env .AppendUnique (DDD1 = 'b' , delete_existing = True )
1840
+ assert env ['DDD1' ] == ['a' , 'c' , 'b' ], env ['DDD1' ] # b moves to end
1837
1841
1838
- env .AppendUnique (DDD1 = 'b' , delete_existing = 1 )
1839
- assert env ['DDD1' ] == ['a' , 'c' , 'b' ], env ['DDD1' ] # b moves to end
1840
- env .AppendUnique (DDD1 = ['a' ,'b' ], delete_existing = 1 )
1841
- assert env ['DDD1' ] == ['c' , 'a' , 'b' ], env ['DDD1' ] # a & b move to end
1842
- env .AppendUnique (DDD1 = ['e' ,'f' , 'e' ], delete_existing = 1 )
1843
- assert env ['DDD1' ] == ['c' , 'a' , 'b' , 'f' , 'e' ], env ['DDD1' ] # add last
1842
+ env .AppendUnique (DDD1 = ['a' , 'b' ], delete_existing = True )
1843
+ assert env ['DDD1' ] == ['c' , 'a' , 'b' ], env ['DDD1' ] # a & b move to end
1844
+
1845
+ env .AppendUnique (DDD1 = ['e' , 'f' , 'e' ], delete_existing = True )
1846
+ assert env ['DDD1' ] == ['c' , 'a' , 'b' , 'f' , 'e' ], env ['DDD1' ] # add last
1847
+
1848
+ # issue regression: substrings should not be deleted
1849
+ env .AppendUnique (BBB4 = 'b4.newer' , delete_existing = True )
1850
+ assert env ['BBB4' ] == ['b4' , 'b4.new' , 'b4.newer' ], env ['BBB4' ]
1844
1851
1845
1852
env ['CLVar' ] = CLVar ([])
1846
- env .AppendUnique (CLVar = 'bar' )
1853
+ env .AppendUnique (CLVar = 'bar' )
1847
1854
result = env ['CLVar' ]
1848
1855
assert isinstance (result , CLVar ), repr (result )
1849
1856
assert result == ['bar' ], result
1850
1857
1851
1858
env ['CLVar' ] = CLVar (['abc' ])
1852
- env .AppendUnique (CLVar = 'bar' )
1859
+ env .AppendUnique (CLVar = 'bar' )
1853
1860
result = env ['CLVar' ]
1854
1861
assert isinstance (result , CLVar ), repr (result )
1855
1862
assert result == ['abc' , 'bar' ], result
1856
1863
1857
1864
env ['CLVar' ] = CLVar (['bar' ])
1858
- env .AppendUnique (CLVar = 'bar' )
1865
+ env .AppendUnique (CLVar = 'bar' )
1859
1866
result = env ['CLVar' ]
1860
1867
assert isinstance (result , CLVar ), repr (result )
1861
1868
assert result == ['bar' ], result
1862
1869
1870
+
1863
1871
def test_Clone (self ) -> None :
1864
1872
"""Test construction environment cloning.
1865
1873
@@ -2501,18 +2509,26 @@ def test_PrependENVPath(self) -> None:
2501
2509
ENV = {'PATH' : r'C:\dir\num\one;C:\dir\num\two' },
2502
2510
MYENV = {'MYPATH' : r'C:\mydir\num\one;C:\mydir\num\two' },
2503
2511
)
2512
+
2504
2513
# have to include the pathsep here so that the test will work on UNIX too.
2505
2514
env1 .PrependENVPath ('PATH' , r'C:\dir\num\two' , sep = ';' )
2506
2515
env1 .PrependENVPath ('PATH' , r'C:\dir\num\three' , sep = ';' )
2507
2516
assert (
2508
2517
env1 ['ENV' ]['PATH' ] == r'C:\dir\num\three;C:\dir\num\two;C:\dir\num\one'
2509
2518
), env1 ['ENV' ]['PATH' ]
2510
2519
2520
+
2521
+ # add nonexisting - at front
2511
2522
env1 .PrependENVPath ('MYPATH' , r'C:\mydir\num\three' , 'MYENV' , sep = ';' )
2523
+ assert (
2524
+ env1 ['MYENV' ]['MYPATH' ] == r'C:\mydir\num\three;C:\mydir\num\one;C:\mydir\num\two'
2525
+ ), env1 ['MYENV' ]['MYPATH' ]
2526
+
2527
+ # add existing - moves to the front
2512
2528
env1 .PrependENVPath ('MYPATH' , r'C:\mydir\num\one' , 'MYENV' , sep = ';' )
2513
- # this should do nothing since delete_existing is 0
2529
+ # this should do nothing since delete_existing is false
2514
2530
env1 .PrependENVPath (
2515
- 'MYPATH' , r'C:\mydir\num\three' , 'MYENV' , sep = ';' , delete_existing = 0
2531
+ 'MYPATH' , r'C:\mydir\num\three' , 'MYENV' , sep = ';' , delete_existing = False
2516
2532
)
2517
2533
assert (
2518
2534
env1 ['MYENV' ]['MYPATH' ] == r'C:\mydir\num\one;C:\mydir\num\three;C:\mydir\num\two'
@@ -2525,6 +2541,7 @@ def test_PrependENVPath(self) -> None:
2525
2541
env1 .PrependENVPath ('PATH' , env1 .fs .Dir ('sub2' ), sep = ';' )
2526
2542
assert env1 ['ENV' ]['PATH' ] == 'sub2;sub1;' + p , env1 ['ENV' ]['PATH' ]
2527
2543
2544
+
2528
2545
def test_PrependUnique (self ) -> None :
2529
2546
"""Test prepending unique values to construction variables
2530
2547
@@ -2570,32 +2587,36 @@ def test_PrependUnique(self) -> None:
2570
2587
assert env ['CCC2' ] == ['c2' ], env ['CCC2' ]
2571
2588
assert env ['DDD1' ] == ['a' , 'b' , 'c' ], env ['DDD1' ]
2572
2589
2573
- env .PrependUnique (DDD1 = 'b' , delete_existing = 1 )
2574
- assert env ['DDD1' ] == ['b' , 'a' , 'c' ], env ['DDD1' ] # b moves to front
2575
- env .PrependUnique (DDD1 = ['a' ,'c' ], delete_existing = 1 )
2576
- assert env ['DDD1' ] == ['a' , 'c' , 'b' ], env ['DDD1' ] # a & c move to front
2577
- env .PrependUnique (DDD1 = ['d' ,'e' ,'d' ], delete_existing = 1 )
2590
+ env .PrependUnique (DDD1 = 'b' , delete_existing = True )
2591
+ assert env ['DDD1' ] == ['b' , 'a' , 'c' ], env ['DDD1' ] # b moves to front
2592
+ env .PrependUnique (DDD1 = ['a' , 'c' ], delete_existing = True )
2593
+ assert env ['DDD1' ] == ['a' , 'c' , 'b' ], env ['DDD1' ] # a & c move to front
2594
+ env .PrependUnique (DDD1 = ['d' , 'e' , 'd' ], delete_existing = True )
2578
2595
assert env ['DDD1' ] == ['d' , 'e' , 'a' , 'c' , 'b' ], env ['DDD1' ]
2579
2596
2597
+ # issue regression: substrings should not be deleted
2598
+ env .PrependUnique (BBB4 = 'b4.newer' , delete_existing = True )
2599
+ assert env ['BBB4' ] == ['b4.newer' , 'b4.new' , 'b4' ], env ['BBB4' ]
2580
2600
2581
2601
env ['CLVar' ] = CLVar ([])
2582
- env .PrependUnique (CLVar = 'bar' )
2602
+ env .PrependUnique (CLVar = 'bar' )
2583
2603
result = env ['CLVar' ]
2584
2604
assert isinstance (result , CLVar ), repr (result )
2585
2605
assert result == ['bar' ], result
2586
2606
2587
2607
env ['CLVar' ] = CLVar (['abc' ])
2588
- env .PrependUnique (CLVar = 'bar' )
2608
+ env .PrependUnique (CLVar = 'bar' )
2589
2609
result = env ['CLVar' ]
2590
2610
assert isinstance (result , CLVar ), repr (result )
2591
2611
assert result == ['bar' , 'abc' ], result
2592
2612
2593
2613
env ['CLVar' ] = CLVar (['bar' ])
2594
- env .PrependUnique (CLVar = 'bar' )
2614
+ env .PrependUnique (CLVar = 'bar' )
2595
2615
result = env ['CLVar' ]
2596
2616
assert isinstance (result , CLVar ), repr (result )
2597
2617
assert result == ['bar' ], result
2598
2618
2619
+
2599
2620
def test_Replace (self ) -> None :
2600
2621
"""Test replacing construction variables in an Environment
2601
2622
0 commit comments