sapling/tests/test-dirstate-completion-t.py
Jun Wu 5e5465c313 testutil/dott: match shell's behavior on quote handling
Summary:
This diff makes the code closer to shell behavior.

For example, globs are disabled for both single and double quotes:

  ~ % echo /bin/bash*
  /bin/bash /bin/bashbug
  ~ % echo "/bin/bash*"
  /bin/bash*
  ~ % echo '/bin/bash*'
  /bin/bash*

Environment variables are not expanded for single qutoes:

  ~ % echo $PWD
  /home/quark
  ~ % echo "$PWD"
  /home/quark
  ~ % echo '$PWD'
  $PWD

Tests using single quoted environment varialbes are updated to use double
quotes, mostly by using this vim command:

  %s/\(sh % ".*\)'\([^'$]*\$[^']*\)'/\1\\"\2\\"

The translation script was updated to prefer double quotes to preserve
environment variable expansion behavior.

Reviewed By: xavierd

Differential Revision: D17675351

fbshipit-source-id: d5c8d5f23ea8e29fe093c4e6ae89ddacda97141e
2019-09-30 16:53:25 -07:00

69 lines
1.7 KiB
Python

# Copyright (c) Facebook, Inc. and its affiliates.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.
from __future__ import absolute_import
from testutil.dott import feature, sh, testtmp # noqa: F401
for testcase in ["v0", "v1", "v2"]:
sh % "cd $TESTTMP"
if feature.check(["v0"]):
sh % "setconfig 'format.dirstate=0'"
if feature.check(["v1"]):
sh % "setconfig 'format.dirstate=1'"
if feature.check(["v2"]):
sh % "setconfig 'format.dirstate=2'"
sh % "newrepo"
sh % "echo file1" > "file1"
sh % "echo file2" > "file2"
sh % "mkdir -p dira dirb"
sh % "echo file3" > "dira/file3"
sh % "echo file4" > "dirb/file4"
sh % "echo file5" > "dirb/file5"
sh % "hg ci -q -Am base"
# Test debugpathcomplete with just normal files
sh % "hg debugpathcomplete f" == r"""
file1
file2"""
sh % "hg debugpathcomplete -f d" == r"""
dira/file3
dirb/file4
dirb/file5"""
# Test debugpathcomplete with removed files
sh % "hg rm dirb/file5"
sh % "hg debugpathcomplete -r d" == "dirb"
sh % "hg debugpathcomplete -fr d" == "dirb/file5"
sh % "hg rm dirb/file4"
sh % "hg debugpathcomplete -n d" == "dira"
# Test debugpathcomplete with merges
sh % "cd .."
sh % "newrepo"
sh % "drawdag" << r"""
D # A/filenormal = 1
/ \ # B/filep1 = 1
B C # B/filemerged = 1
\ / # C/filep2 = 1
A # C/filemerged = 2
# D/filemerged = 12
"""
sh % "hg up -q $D"
sh % "hg debugpathcomplete f" == r"""
filemerged
filenormal
filep1
filep2"""