comparison tests/run-tests.py @ 44489:9183b7dcfa8d

run-tests: add option for running with and without Rust extensions This provide a simple and clear way to run the test with or without rust.
author Raphaël Gomès <rgomes@octobus.net>
date Fri, 06 Mar 2020 11:16:15 +0100
parents 0d9ad84a28d9
children b2e41723f886
comparison
equal deleted inserted replaced
44488:0d9ad84a28d9 44489:9183b7dcfa8d
51 import distutils.version as version 51 import distutils.version as version
52 import errno 52 import errno
53 import json 53 import json
54 import multiprocessing 54 import multiprocessing
55 import os 55 import os
56 import platform
56 import random 57 import random
57 import re 58 import re
58 import shutil 59 import shutil
59 import signal 60 import signal
60 import socket 61 import socket
553 "--pure", 554 "--pure",
554 action="store_true", 555 action="store_true",
555 help="use pure Python code instead of C extensions", 556 help="use pure Python code instead of C extensions",
556 ) 557 )
557 hgconf.add_argument( 558 hgconf.add_argument(
559 "--rust",
560 action="store_true",
561 help="use Rust code alongside C extensions",
562 )
563 hgconf.add_argument(
564 "--no-rust",
565 action="store_true",
566 help="do not use Rust code even if compiled",
567 )
568 hgconf.add_argument(
558 "--with-chg", 569 "--with-chg",
559 metavar="CHG", 570 metavar="CHG",
560 help="use specified chg wrapper in place of hg", 571 help="use specified chg wrapper in place of hg",
561 ) 572 )
562 hgconf.add_argument( 573 hgconf.add_argument(
634 options = parser.parse_args(args) 645 options = parser.parse_args(args)
635 646
636 # jython is always pure 647 # jython is always pure
637 if 'java' in sys.platform or '__pypy__' in sys.modules: 648 if 'java' in sys.platform or '__pypy__' in sys.modules:
638 options.pure = True 649 options.pure = True
650
651 if platform.python_implementation() != 'CPython' and options.rust:
652 parser.error('Rust extensions are only available with CPython')
653
654 if options.pure and options.rust:
655 parser.error('--rust cannot be used with --pure')
656
657 if options.rust and options.no_rust:
658 parser.error('--rust cannot be used with --no-rust')
639 659
640 if options.local: 660 if options.local:
641 if options.with_hg or options.with_chg: 661 if options.with_hg or options.with_chg:
642 parser.error('--local cannot be used with --with-hg or --with-chg') 662 parser.error('--local cannot be used with --with-hg or --with-chg')
643 testdir = os.path.dirname(_sys2bytes(canonpath(sys.argv[0]))) 663 testdir = os.path.dirname(_sys2bytes(canonpath(sys.argv[0])))
3091 osenvironb[IMPL_PATH] = sepb.join(pypath) 3111 osenvironb[IMPL_PATH] = sepb.join(pypath)
3092 3112
3093 if self.options.pure: 3113 if self.options.pure:
3094 os.environ["HGTEST_RUN_TESTS_PURE"] = "--pure" 3114 os.environ["HGTEST_RUN_TESTS_PURE"] = "--pure"
3095 os.environ["HGMODULEPOLICY"] = "py" 3115 os.environ["HGMODULEPOLICY"] = "py"
3116 if self.options.rust:
3117 os.environ["HGMODULEPOLICY"] = "rust+c"
3118 if self.options.no_rust:
3119 current_policy = os.environ.get("HGMODULEPOLICY", "")
3120 if current_policy.startswith("rust+"):
3121 os.environ["HGMODULEPOLICY"] = current_policy[len("rust+") :]
3122 os.environ.pop("HGWITHRUSTEXT", None)
3096 3123
3097 if self.options.allow_slow_tests: 3124 if self.options.allow_slow_tests:
3098 os.environ["HGTEST_SLOW"] = "slow" 3125 os.environ["HGTEST_SLOW"] = "slow"
3099 elif 'HGTEST_SLOW' in os.environ: 3126 elif 'HGTEST_SLOW' in os.environ:
3100 del os.environ['HGTEST_SLOW'] 3127 del os.environ['HGTEST_SLOW']
3424 if self.options.compiler: 3451 if self.options.compiler:
3425 compiler = '--compiler ' + self.options.compiler 3452 compiler = '--compiler ' + self.options.compiler
3426 setup_opts = b"" 3453 setup_opts = b""
3427 if self.options.pure: 3454 if self.options.pure:
3428 setup_opts = b"--pure" 3455 setup_opts = b"--pure"
3456 elif self.options.rust:
3457 setup_opts = b"--rust"
3458 elif self.options.no_rust:
3459 setup_opts = b"--no-rust"
3429 3460
3430 # Run installer in hg root 3461 # Run installer in hg root
3431 script = os.path.realpath(sys.argv[0]) 3462 script = os.path.realpath(sys.argv[0])
3432 exe = sysexecutable 3463 exe = sysexecutable
3433 if PYTHON3: 3464 if PYTHON3: