Mercurial > hg
comparison tests/run-tests.py @ 46668:fb2368598281
tests: Add `--rhg` and `--with-rhg=<path>` options for `run-tests.py`
They are mostly equivalent to the corresponding `chg` options.
For now, many tests are still failing in this configuration.
It is *not* run on CI.
Differential Revision: https://phab.mercurial-scm.org/D10095
author | Simon Sapin <simon.sapin@octobus.net> |
---|---|
date | Tue, 02 Mar 2021 21:31:12 +0100 |
parents | 7bb31c367847 |
children | a6553ba1c598 |
comparison
equal
deleted
inserted
replaced
46667:93e9f448273c | 46668:fb2368598281 |
---|---|
538 hgconf.add_argument( | 538 hgconf.add_argument( |
539 "--chg-debug", | 539 "--chg-debug", |
540 action="store_true", | 540 action="store_true", |
541 help="show chg debug logs", | 541 help="show chg debug logs", |
542 ) | 542 ) |
543 hgconf.add_argument( | |
544 "--rhg", | |
545 action="store_true", | |
546 help="install and use rhg Rust implementation in place of hg", | |
547 ) | |
543 hgconf.add_argument("--compiler", help="compiler to build with") | 548 hgconf.add_argument("--compiler", help="compiler to build with") |
544 hgconf.add_argument( | 549 hgconf.add_argument( |
545 '--extra-config-opt', | 550 '--extra-config-opt', |
546 action="append", | 551 action="append", |
547 default=[], | 552 default=[], |
550 hgconf.add_argument( | 555 hgconf.add_argument( |
551 "-l", | 556 "-l", |
552 "--local", | 557 "--local", |
553 action="store_true", | 558 action="store_true", |
554 help="shortcut for --with-hg=<testdir>/../hg, " | 559 help="shortcut for --with-hg=<testdir>/../hg, " |
560 "--with-rhg=<testdir>/../rust/target/release/rhg if --rhg is set, " | |
555 "and --with-chg=<testdir>/../contrib/chg/chg if --chg is set", | 561 "and --with-chg=<testdir>/../contrib/chg/chg if --chg is set", |
556 ) | 562 ) |
557 hgconf.add_argument( | 563 hgconf.add_argument( |
558 "--ipv6", | 564 "--ipv6", |
559 action="store_true", | 565 action="store_true", |
576 ) | 582 ) |
577 hgconf.add_argument( | 583 hgconf.add_argument( |
578 "--with-chg", | 584 "--with-chg", |
579 metavar="CHG", | 585 metavar="CHG", |
580 help="use specified chg wrapper in place of hg", | 586 help="use specified chg wrapper in place of hg", |
587 ) | |
588 hgconf.add_argument( | |
589 "--with-rhg", | |
590 metavar="RHG", | |
591 help="use specified rhg Rust implementation in place of hg", | |
581 ) | 592 ) |
582 hgconf.add_argument( | 593 hgconf.add_argument( |
583 "--with-hg", | 594 "--with-hg", |
584 metavar="HG", | 595 metavar="HG", |
585 help="test using specified hg script rather than a " | 596 help="test using specified hg script rather than a " |
665 | 676 |
666 if options.rust and options.no_rust: | 677 if options.rust and options.no_rust: |
667 parser.error('--rust cannot be used with --no-rust') | 678 parser.error('--rust cannot be used with --no-rust') |
668 | 679 |
669 if options.local: | 680 if options.local: |
670 if options.with_hg or options.with_chg: | 681 if options.with_hg or options.with_rhg or options.with_chg: |
671 parser.error('--local cannot be used with --with-hg or --with-chg') | 682 parser.error( |
683 '--local cannot be used with --with-hg or --with-rhg or --with-chg' | |
684 ) | |
672 testdir = os.path.dirname(_sys2bytes(canonpath(sys.argv[0]))) | 685 testdir = os.path.dirname(_sys2bytes(canonpath(sys.argv[0]))) |
673 reporootdir = os.path.dirname(testdir) | 686 reporootdir = os.path.dirname(testdir) |
674 pathandattrs = [(b'hg', 'with_hg')] | 687 pathandattrs = [(b'hg', 'with_hg')] |
675 if options.chg: | 688 if options.chg: |
676 pathandattrs.append((b'contrib/chg/chg', 'with_chg')) | 689 pathandattrs.append((b'contrib/chg/chg', 'with_chg')) |
690 if options.rhg: | |
691 pathandattrs.append((b'rust/target/release/rhg', 'with_rhg')) | |
677 for relpath, attr in pathandattrs: | 692 for relpath, attr in pathandattrs: |
678 binpath = os.path.join(reporootdir, relpath) | 693 binpath = os.path.join(reporootdir, relpath) |
679 if os.name != 'nt' and not os.access(binpath, os.X_OK): | 694 if os.name != 'nt' and not os.access(binpath, os.X_OK): |
680 parser.error( | 695 parser.error( |
681 '--local specified, but %r not found or ' | 696 '--local specified, but %r not found or ' |
694 sys.stderr.write('warning: --with-hg should specify an hg script\n') | 709 sys.stderr.write('warning: --with-hg should specify an hg script\n') |
695 sys.stderr.flush() | 710 sys.stderr.flush() |
696 | 711 |
697 if (options.chg or options.with_chg) and os.name == 'nt': | 712 if (options.chg or options.with_chg) and os.name == 'nt': |
698 parser.error('chg does not work on %s' % os.name) | 713 parser.error('chg does not work on %s' % os.name) |
714 if (options.rhg or options.with_rhg) and os.name == 'nt': | |
715 parser.error('rhg does not work on %s' % os.name) | |
699 if options.with_chg: | 716 if options.with_chg: |
700 options.chg = False # no installation to temporary location | 717 options.chg = False # no installation to temporary location |
701 options.with_chg = canonpath(_sys2bytes(options.with_chg)) | 718 options.with_chg = canonpath(_sys2bytes(options.with_chg)) |
702 if not ( | 719 if not ( |
703 os.path.isfile(options.with_chg) | 720 os.path.isfile(options.with_chg) |
704 and os.access(options.with_chg, os.X_OK) | 721 and os.access(options.with_chg, os.X_OK) |
705 ): | 722 ): |
706 parser.error('--with-chg must specify a chg executable') | 723 parser.error('--with-chg must specify a chg executable') |
724 if options.with_rhg: | |
725 options.rhg = False # no installation to temporary location | |
726 options.with_rhg = canonpath(_sys2bytes(options.with_rhg)) | |
727 if not ( | |
728 os.path.isfile(options.with_rhg) | |
729 and os.access(options.with_rhg, os.X_OK) | |
730 ): | |
731 parser.error('--with-rhg must specify a rhg executable') | |
707 if options.chg and options.with_hg: | 732 if options.chg and options.with_hg: |
708 # chg shares installation location with hg | 733 # chg shares installation location with hg |
709 parser.error( | 734 parser.error( |
710 '--chg does not work when --with-hg is specified ' | 735 '--chg does not work when --with-hg is specified ' |
711 '(use --with-chg instead)' | 736 '(use --with-chg instead)' |
712 ) | 737 ) |
738 if options.rhg and options.with_hg: | |
739 # rhg shares installation location with hg | |
740 parser.error( | |
741 '--rhg does not work when --with-hg is specified ' | |
742 '(use --with-rhg instead)' | |
743 ) | |
744 if options.rhg and options.chg: | |
745 parser.error('--rhg and --chg do not work together') | |
713 | 746 |
714 if options.color == 'always' and not pygmentspresent: | 747 if options.color == 'always' and not pygmentspresent: |
715 sys.stderr.write( | 748 sys.stderr.write( |
716 'warning: --color=always ignored because ' | 749 'warning: --color=always ignored because ' |
717 'pygments is not installed\n' | 750 'pygments is not installed\n' |
932 shell=None, | 965 shell=None, |
933 hgcommand=None, | 966 hgcommand=None, |
934 slowtimeout=None, | 967 slowtimeout=None, |
935 usechg=False, | 968 usechg=False, |
936 chgdebug=False, | 969 chgdebug=False, |
970 rhg_fallback_exe=None, | |
937 useipv6=False, | 971 useipv6=False, |
938 ): | 972 ): |
939 """Create a test from parameters. | 973 """Create a test from parameters. |
940 | 974 |
941 path is the full path to the file defining the test. | 975 path is the full path to the file defining the test. |
989 self._extraconfigopts = extraconfigopts or [] | 1023 self._extraconfigopts = extraconfigopts or [] |
990 self._shell = _sys2bytes(shell) | 1024 self._shell = _sys2bytes(shell) |
991 self._hgcommand = hgcommand or b'hg' | 1025 self._hgcommand = hgcommand or b'hg' |
992 self._usechg = usechg | 1026 self._usechg = usechg |
993 self._chgdebug = chgdebug | 1027 self._chgdebug = chgdebug |
1028 self._rhg_fallback_exe = rhg_fallback_exe | |
994 self._useipv6 = useipv6 | 1029 self._useipv6 = useipv6 |
995 | 1030 |
996 self._aborted = False | 1031 self._aborted = False |
997 self._daemonpids = [] | 1032 self._daemonpids = [] |
998 self._finished = None | 1033 self._finished = None |
1470 ) | 1505 ) |
1471 hgrc.write(b'[web]\n') | 1506 hgrc.write(b'[web]\n') |
1472 hgrc.write(b'address = localhost\n') | 1507 hgrc.write(b'address = localhost\n') |
1473 hgrc.write(b'ipv6 = %r\n' % self._useipv6) | 1508 hgrc.write(b'ipv6 = %r\n' % self._useipv6) |
1474 hgrc.write(b'server-header = testing stub value\n') | 1509 hgrc.write(b'server-header = testing stub value\n') |
1510 | |
1511 if self._rhg_fallback_exe: | |
1512 hgrc.write(b'[rhg]\n') | |
1513 hgrc.write( | |
1514 b'fallback-executable = %s\n' % self._rhg_fallback_exe | |
1515 ) | |
1475 | 1516 |
1476 for opt in self._extraconfigopts: | 1517 for opt in self._extraconfigopts: |
1477 section, key = _sys2bytes(opt).split(b'.', 1) | 1518 section, key = _sys2bytes(opt).split(b'.', 1) |
1478 assert b'=' in key, ( | 1519 assert b'=' in key, ( |
1479 'extra config opt %s must ' 'have an = for assignment' % opt | 1520 'extra config opt %s must ' 'have an = for assignment' % opt |
2956 self._tmpbindir = None | 2997 self._tmpbindir = None |
2957 self._pythondir = None | 2998 self._pythondir = None |
2958 self._coveragefile = None | 2999 self._coveragefile = None |
2959 self._createdfiles = [] | 3000 self._createdfiles = [] |
2960 self._hgcommand = None | 3001 self._hgcommand = None |
3002 self._rhg_fallback_exe = None | |
2961 self._hgpath = None | 3003 self._hgpath = None |
2962 self._portoffset = 0 | 3004 self._portoffset = 0 |
2963 self._ports = {} | 3005 self._ports = {} |
2964 | 3006 |
2965 def run(self, args, parser=None): | 3007 def run(self, args, parser=None): |
3096 self._hgcommand = b'chg' | 3138 self._hgcommand = b'chg' |
3097 elif self.options.with_chg: | 3139 elif self.options.with_chg: |
3098 chgbindir = os.path.dirname(os.path.realpath(self.options.with_chg)) | 3140 chgbindir = os.path.dirname(os.path.realpath(self.options.with_chg)) |
3099 self._hgcommand = os.path.basename(self.options.with_chg) | 3141 self._hgcommand = os.path.basename(self.options.with_chg) |
3100 | 3142 |
3143 # set fallback executable path, then replace "hg" command by "rhg" | |
3144 rhgbindir = self._bindir | |
3145 if self.options.rhg or self.options.with_rhg: | |
3146 self._rhg_fallback_exe = os.path.join(self._bindir, self._hgcommand) | |
3147 if self.options.rhg: | |
3148 self._hgcommand = b'rhg' | |
3149 elif self.options.with_rhg: | |
3150 rhgbindir = os.path.dirname(os.path.realpath(self.options.with_rhg)) | |
3151 self._hgcommand = os.path.basename(self.options.with_rhg) | |
3152 | |
3101 osenvironb[b"BINDIR"] = self._bindir | 3153 osenvironb[b"BINDIR"] = self._bindir |
3102 osenvironb[b"PYTHON"] = PYTHON | 3154 osenvironb[b"PYTHON"] = PYTHON |
3103 | 3155 |
3104 fileb = _sys2bytes(__file__) | 3156 fileb = _sys2bytes(__file__) |
3105 runtestdir = os.path.abspath(os.path.dirname(fileb)) | 3157 runtestdir = os.path.abspath(os.path.dirname(fileb)) |
3114 realfile = os.path.realpath(fileb) | 3166 realfile = os.path.realpath(fileb) |
3115 realdir = os.path.abspath(os.path.dirname(realfile)) | 3167 realdir = os.path.abspath(os.path.dirname(realfile)) |
3116 path.insert(2, realdir) | 3168 path.insert(2, realdir) |
3117 if chgbindir != self._bindir: | 3169 if chgbindir != self._bindir: |
3118 path.insert(1, chgbindir) | 3170 path.insert(1, chgbindir) |
3171 if rhgbindir != self._bindir: | |
3172 path.insert(1, rhgbindir) | |
3119 if self._testdir != runtestdir: | 3173 if self._testdir != runtestdir: |
3120 path = [self._testdir] + path | 3174 path = [self._testdir] + path |
3121 if self._tmpbindir != self._bindir: | 3175 if self._tmpbindir != self._bindir: |
3122 path = [self._tmpbindir] + path | 3176 path = [self._tmpbindir] + path |
3123 osenvironb[b"PATH"] = sepb.join(path) | 3177 osenvironb[b"PATH"] = sepb.join(path) |
3421 extraconfigopts=self.options.extra_config_opt, | 3475 extraconfigopts=self.options.extra_config_opt, |
3422 shell=self.options.shell, | 3476 shell=self.options.shell, |
3423 hgcommand=self._hgcommand, | 3477 hgcommand=self._hgcommand, |
3424 usechg=bool(self.options.with_chg or self.options.chg), | 3478 usechg=bool(self.options.with_chg or self.options.chg), |
3425 chgdebug=self.options.chg_debug, | 3479 chgdebug=self.options.chg_debug, |
3480 rhg_fallback_exe=self._rhg_fallback_exe, | |
3426 useipv6=useipv6, | 3481 useipv6=useipv6, |
3427 **kwds | 3482 **kwds |
3428 ) | 3483 ) |
3429 t.should_reload = True | 3484 t.should_reload = True |
3430 return t | 3485 return t |