13
13
import shutil
14
14
import tempfile
15
15
16
- import libcxx .test .format
17
16
import lit
17
+ import lit .formats
18
18
import lit .LitConfig
19
19
import lit .Test
20
20
import lit .TestRunner
@@ -99,7 +99,7 @@ def _executeWithFakeConfig(test, commands):
99
99
order = "smart" ,
100
100
params = {},
101
101
)
102
- return libcxx . test . format ._executeScriptInternal (test , litConfig , commands )
102
+ return lit . formats . standardlibrarytest ._executeScriptInternal (test , litConfig , commands )
103
103
104
104
105
105
def _makeConfigTest (config ):
@@ -121,12 +121,12 @@ def _makeConfigTest(config):
121
121
122
122
class TestWrapper (lit .Test .Test ):
123
123
def __enter__ (self ):
124
- testDir , _ = libcxx . test . format ._getTempPaths (self )
124
+ testDir , _ = lit . formats . standardlibrarytest ._getTempPaths (self )
125
125
os .makedirs (testDir )
126
126
return self
127
127
128
128
def __exit__ (self , * args ):
129
- testDir , _ = libcxx . test . format ._getTempPaths (self )
129
+ testDir , _ = lit . formats . standardlibrarytest ._getTempPaths (self )
130
130
shutil .rmtree (testDir )
131
131
os .remove (tmp .name )
132
132
@@ -348,18 +348,6 @@ def featureTestMacros(config, flags=""):
348
348
}
349
349
350
350
351
- def _getSubstitution (substitution , config ):
352
- for (orig , replacement ) in config .substitutions :
353
- if orig == substitution :
354
- return replacement
355
- raise ValueError ('Substitution {} is not in the config.' .format (substitution ))
356
-
357
- def _appendToSubstitution (substitutions , key , value ):
358
- return [(k , v + " " + value ) if k == key else (k , v ) for (k , v ) in substitutions ]
359
-
360
- def _prependToSubstitution (substitutions , key , value ):
361
- return [(k , value + " " + v ) if k == key else (k , v ) for (k , v ) in substitutions ]
362
-
363
351
def _ensureFlagIsSupported (config , flag ):
364
352
(exitCode , out , err ) = tryCompileFlag (config , flag )
365
353
assert (
@@ -442,7 +430,7 @@ def __init__(self, flag):
442
430
def applyTo (self , config ):
443
431
flag = self ._getFlag (config )
444
432
_ensureFlagIsSupported (config , flag )
445
- config .substitutions = _appendToSubstitution (
433
+ config .substitutions = lit . formats . standardlibrarytest . _appendToSubstitution (
446
434
config .substitutions , "%{flags}" , flag
447
435
)
448
436
@@ -464,7 +452,7 @@ def __init__(self, flag):
464
452
def applyTo (self , config ):
465
453
flag = self ._getFlag (config )
466
454
if hasCompileFlag (config , flag ):
467
- config .substitutions = _appendToSubstitution (
455
+ config .substitutions = lit . formats . standardlibrarytest . _appendToSubstitution (
468
456
config .substitutions , "%{flags}" , flag
469
457
)
470
458
@@ -486,7 +474,7 @@ def __init__(self, flag):
486
474
def applyTo (self , config ):
487
475
flag = self ._getFlag (config )
488
476
_ensureFlagIsSupported (config , flag )
489
- config .substitutions = _appendToSubstitution (
477
+ config .substitutions = lit . formats . standardlibrarytest . _appendToSubstitution (
490
478
config .substitutions , "%{compile_flags}" , flag
491
479
)
492
480
@@ -508,7 +496,7 @@ def __init__(self, flag):
508
496
def applyTo (self , config ):
509
497
flag = self ._getFlag (config )
510
498
_ensureFlagIsSupported (config , flag )
511
- config .substitutions = _appendToSubstitution (
499
+ config .substitutions = lit . formats . standardlibrarytest . _appendToSubstitution (
512
500
config .substitutions , "%{link_flags}" , flag
513
501
)
514
502
@@ -530,7 +518,7 @@ def __init__(self, flag):
530
518
def applyTo (self , config ):
531
519
flag = self ._getFlag (config )
532
520
_ensureFlagIsSupported (config , flag )
533
- config .substitutions = _prependToSubstitution (
521
+ config .substitutions = lit . formats . standardlibrarytest . _prependToSubstitution (
534
522
config .substitutions , "%{link_flags}" , flag
535
523
)
536
524
@@ -554,7 +542,7 @@ def applyTo(self, config):
554
542
flag = self ._getFlag (config )
555
543
# Use -Werror to make sure we see an error about the flag being unsupported.
556
544
if hasCompileFlag (config , "-Werror " + flag ):
557
- config .substitutions = _appendToSubstitution (
545
+ config .substitutions = lit . formats . standardlibrarytest . _appendToSubstitution (
558
546
config .substitutions , "%{compile_flags}" , flag
559
547
)
560
548
0 commit comments