Patchwork D10704: status: Add some more tests

login
register
mail settings
Submitter phabricator
Date May 11, 2021, 4:13 p.m.
Message ID <differential-rev-PHID-DREV-c6ahjp3cizqbqg3cr3zw-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/49023/
State Superseded
Headers show

Comments

phabricator - May 11, 2021, 4:13 p.m.
SimonSapin created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Trying to improve coverage for various non-ovbious scenarios

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D10704

AFFECTED FILES
  tests/test-status.t

CHANGE DETAILS




To: SimonSapin, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/tests/test-status.t b/tests/test-status.t
--- a/tests/test-status.t
+++ b/tests/test-status.t
@@ -762,3 +762,107 @@ 
   ? foo
 
 #endif
+
+
+Create a repo with files in each possible status
+
+  $ cd ..
+  $ hg init repo7
+  $ cd repo7
+  $ mkdir subdir
+  $ touch clean modified deleted removed
+  $ touch subdir/clean subdir/modified subdir/deleted subdir/removed
+  $ echo ignored > .hgignore
+  $ hg ci -Aqm '#0'
+  $ echo 1 > modified
+  $ echo 1 > subdir/modified
+  $ rm deleted
+  $ rm subdir/deleted
+  $ hg rm removed
+  $ hg rm subdir/removed
+  $ touch unknown ignored
+  $ touch subdir/unknown subdir/ignored
+
+Check the output
+
+  $ hg status
+  M modified
+  M subdir/modified
+  R removed
+  R subdir/removed
+  ! deleted
+  ! subdir/deleted
+  ? subdir/unknown
+  ? unknown
+
+  $ hg status -mard
+  M modified
+  M subdir/modified
+  R removed
+  R subdir/removed
+  ! deleted
+  ! subdir/deleted
+
+  $ hg status -A
+  M modified
+  M subdir/modified
+  R removed
+  R subdir/removed
+  ! deleted
+  ! subdir/deleted
+  ? subdir/unknown
+  ? unknown
+  I ignored
+  I subdir/ignored
+  C .hgignore
+  C clean
+  C subdir/clean
+
+Note: `hg status some-name` creates a patternmatcher which is not supported
+yet by the Rust implementation of status, but includematcher is supported.
+--include is used below for that reason
+
+Remove a directory that contains tracked files
+
+  $ rm -r subdir
+  $ hg status --include subdir
+  R subdir/removed
+  ! subdir/clean
+  ! subdir/deleted
+  ! subdir/modified
+
+… and replace it by a file
+
+  $ touch subdir
+  $ hg status --include subdir
+  R subdir/removed
+  ! subdir/clean
+  ! subdir/deleted
+  ! subdir/modified
+  ? subdir
+
+Replaced a deleted or removed file with a directory
+
+  $ mkdir deleted removed
+  $ touch deleted/1 removed/1
+  $ hg status --include deleted --include removed
+  R removed
+  ! deleted
+  ? deleted/1
+  ? removed/1
+  $ hg add removed/1
+  $ hg status --include deleted --include removed
+  A removed/1
+  R removed
+  ! deleted
+  ? deleted/1
+
+Deeply nested files in an ignored directory are still listed on request
+
+  $ echo ignored-dir >> .hgignore
+  $ mkdir ignored-dir
+  $ mkdir ignored-dir/subdir
+  $ touch ignored-dir/subdir/1
+  $ hg status --ignored
+  I ignored
+  I ignored-dir/subdir/1