git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Add more tests for git-clean
  2007-11-04 19:02 [RFC] Second attempt at making git-clean a builtin Shawn Bohrer
@ 2007-11-04 19:02 ` Shawn Bohrer
  2007-11-04 23:35   ` Junio C Hamano
  0 siblings, 1 reply; 6+ messages in thread
From: Shawn Bohrer @ 2007-11-04 19:02 UTC (permalink / raw)
  To: git; +Cc: gitster, Shawn Bohrer

Signed-off-by: Shawn Bohrer <shawn.bohrer@gmail.com>
---
 t/t7300-clean.sh |  109 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 109 insertions(+), 0 deletions(-)

diff --git a/t/t7300-clean.sh b/t/t7300-clean.sh
index 8697213..d74c11c 100755
--- a/t/t7300-clean.sh
+++ b/t/t7300-clean.sh
@@ -39,6 +39,97 @@ test_expect_success 'git-clean' '
 
 '
 
+test_expect_success 'git-clean src/' '
+
+	mkdir -p build docs &&
+	touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
+	git-clean src/ &&
+	test -f Makefile &&
+	test -f README &&
+	test -f src/part1.c &&
+	test -f src/part2.c &&
+	test -f a.out &&
+	test ! -f src/part3.c &&
+	test -f docs/manual.txt &&
+	test -f obj.o &&
+	test -f build/lib.so
+
+'
+
+test_expect_success 'git-clean src/ src/' '
+
+	mkdir -p build docs &&
+	touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
+	git-clean src/ src/ &&
+	test -f Makefile &&
+	test -f README &&
+	test -f src/part1.c &&
+	test -f src/part2.c &&
+	test -f a.out &&
+	test ! -f src/part3.c &&
+	test -f docs/manual.txt &&
+	test -f obj.o &&
+	test -f build/lib.so
+
+'
+
+test_expect_success 'git-clean with prefix' '
+
+	mkdir -p build docs &&
+	touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
+	cd src/ &&
+	git-clean &&
+	cd - &&
+	test -f Makefile &&
+	test -f README &&
+	test -f src/part1.c &&
+	test -f src/part2.c &&
+	test -f a.out &&
+	test ! -f src/part3.c &&
+	test -f docs/manual.txt &&
+	test -f obj.o &&
+	test -f build/lib.so
+
+'
+test_expect_success 'git-clean -d with prefix and path' '
+
+	mkdir -p build docs src/feature &&
+	touch a.out src/part3.c src/feature/file.c docs/manual.txt obj.o build/lib.so &&
+	cd src/ &&
+	git-clean -d feature/ &&
+	cd - &&
+	test -f Makefile &&
+	test -f README &&
+	test -f src/part1.c &&
+	test -f src/part2.c &&
+	test -f a.out &&
+	test -f src/part3.c &&
+	test ! -f src/feature/file.c &&
+	test -f docs/manual.txt &&
+	test -f obj.o &&
+	test -f build/lib.so
+
+'
+
+test_expect_success 'git-clean symbolic link' '
+
+	mkdir -p build docs &&
+	touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
+	ln -s docs/manual.txt src/part4.c
+	git-clean &&
+	test -f Makefile &&
+	test -f README &&
+	test -f src/part1.c &&
+	test -f src/part2.c &&
+	test ! -f a.out &&
+	test ! -f src/part3.c &&
+	test ! -f src/part4.c &&
+	test -f docs/manual.txt &&
+	test -f obj.o &&
+	test -f build/lib.so
+
+'
+
 test_expect_success 'git-clean -n' '
 
 	mkdir -p build docs &&
@@ -73,6 +164,24 @@ test_expect_success 'git-clean -d' '
 
 '
 
+test_expect_success 'git-clean -d src/ examples/' '
+
+	mkdir -p build docs examples &&
+	touch a.out src/part3.c docs/manual.txt obj.o build/lib.so examples/1.c &&
+	git-clean -d src/ examples/ &&
+	test -f Makefile &&
+	test -f README &&
+	test -f src/part1.c &&
+	test -f src/part2.c &&
+	test -f a.out &&
+	test ! -f src/part3.c &&
+	test ! -f examples/1.c &&
+	test -f docs/manual.txt &&
+	test -f obj.o &&
+	test -f build/lib.so
+
+'
+
 test_expect_success 'git-clean -x' '
 
 	mkdir -p build docs &&
-- 
1.5.3.GIT

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] Add more tests for git-clean
  2007-11-04 19:02 ` [PATCH] Add more tests for git-clean Shawn Bohrer
@ 2007-11-04 23:35   ` Junio C Hamano
  2007-11-04 23:46     ` Pierre Habouzit
  2007-11-04 23:49     ` Johannes Schindelin
  0 siblings, 2 replies; 6+ messages in thread
From: Junio C Hamano @ 2007-11-04 23:35 UTC (permalink / raw)
  To: Shawn Bohrer; +Cc: git, gitster

Shawn Bohrer <shawn.bohrer@gmail.com> writes:

> +test_expect_success 'git-clean with prefix' '
> +
> +	mkdir -p build docs &&
> +	touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
> +	cd src/ &&
> +	git-clean &&
> +	cd - &&

This is wrong for two reasons.

 - Is "cd -" portable?

 - What happens when git-clean fails?  This test fails, and then
   it goes on to the next test without cd'ing back.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Add more tests for git-clean
  2007-11-04 23:35   ` Junio C Hamano
@ 2007-11-04 23:46     ` Pierre Habouzit
  2007-11-05  0:17       ` Junio C Hamano
  2007-11-04 23:49     ` Johannes Schindelin
  1 sibling, 1 reply; 6+ messages in thread
From: Pierre Habouzit @ 2007-11-04 23:46 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Shawn Bohrer, git

[-- Attachment #1: Type: text/plain, Size: 864 bytes --]

On Sun, Nov 04, 2007 at 11:35:42PM +0000, Junio C Hamano wrote:
> Shawn Bohrer <shawn.bohrer@gmail.com> writes:
> 
> > +test_expect_success 'git-clean with prefix' '
> > +
> > +	mkdir -p build docs &&
> > +	touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
> > +	cd src/ &&
> > +	git-clean &&
> > +	cd - &&
> 
> This is wrong for two reasons.
> 
>  - Is "cd -" portable?

  this is POSIX:

8910 − When a hyphen is used as the operand, this shall be equivalent to the command:
8911   cd "$OLDPWD" && pwd
8912   which changes to the previous working directory and then writes its name.

  Meaning that cd $OLDPWD should work, and won't print $OLDPWD.

-- 
·O·  Pierre Habouzit
··O                                                madcoder@debian.org
OOO                                                http://www.madism.org

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Add more tests for git-clean
  2007-11-04 23:35   ` Junio C Hamano
  2007-11-04 23:46     ` Pierre Habouzit
@ 2007-11-04 23:49     ` Johannes Schindelin
  1 sibling, 0 replies; 6+ messages in thread
From: Johannes Schindelin @ 2007-11-04 23:49 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Shawn Bohrer, git

Hi,

On Sun, 4 Nov 2007, Junio C Hamano wrote:

> Shawn Bohrer <shawn.bohrer@gmail.com> writes:
> 
> > +test_expect_success 'git-clean with prefix' '
> > +
> > +	mkdir -p build docs &&
> > +	touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
> > +	cd src/ &&
> > +	git-clean &&
> > +	cd - &&
> 
> This is wrong for two reasons.
> 
>  - Is "cd -" portable?
> 
>  - What happens when git-clean fails?  This test fails, and then
>    it goes on to the next test without cd'ing back.

So it should be

	(cd src/ && git clean) &&

right?  (Note that I also removed the dash, since it will be a builtin 
after the next commit.)

Ciao,
Dscho

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Add more tests for git-clean
  2007-11-04 23:46     ` Pierre Habouzit
@ 2007-11-05  0:17       ` Junio C Hamano
  0 siblings, 0 replies; 6+ messages in thread
From: Junio C Hamano @ 2007-11-05  0:17 UTC (permalink / raw)
  To: Pierre Habouzit; +Cc: Shawn Bohrer, git

Pierre Habouzit <madcoder@debian.org> writes:

> On Sun, Nov 04, 2007 at 11:35:42PM +0000, Junio C Hamano wrote:
>> Shawn Bohrer <shawn.bohrer@gmail.com> writes:
>> 
>> > +test_expect_success 'git-clean with prefix' '
>> > +
>> > +	mkdir -p build docs &&
>> > +	touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
>> > +	cd src/ &&
>> > +	git-clean &&
>> > +	cd - &&
>> 
>> This is wrong for two reasons.
>> 
>>  - Is "cd -" portable?
>
>   this is POSIX:

That actually doesn't matter.  What the real world shells do
matters more.

In addition, "cd -" is a nice shorthand for interactive use but
it is a bad discipline to use it in a script anyway.

	...
	( cd src && git-clean ) &&
	...

would be the best way to write this.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] Add more tests for git-clean
@ 2007-11-05  4:28 Shawn Bohrer
  0 siblings, 0 replies; 6+ messages in thread
From: Shawn Bohrer @ 2007-11-05  4:28 UTC (permalink / raw)
  To: gitster; +Cc: madcoder, git, Shawn Bohrer

Signed-off-by: Shawn Bohrer <shawn.bohrer@gmail.com>
---
 t/t7300-clean.sh |  105 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 105 insertions(+), 0 deletions(-)

On Sun, Nov 04, 2007 at 04:17:47PM -0800, Junio C Hamano wrote:
>       ...
>       ( cd src && git-clean ) &&
>       ...
>
> would be the best way to write this.

Agreed here is an updated patch that does this.

diff --git a/t/t7300-clean.sh b/t/t7300-clean.sh
index 8697213..25d3102 100755
--- a/t/t7300-clean.sh
+++ b/t/t7300-clean.sh
@@ -39,6 +39,93 @@ test_expect_success 'git-clean' '
 
 '
 
+test_expect_success 'git-clean src/' '
+
+	mkdir -p build docs &&
+	touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
+	git-clean src/ &&
+	test -f Makefile &&
+	test -f README &&
+	test -f src/part1.c &&
+	test -f src/part2.c &&
+	test -f a.out &&
+	test ! -f src/part3.c &&
+	test -f docs/manual.txt &&
+	test -f obj.o &&
+	test -f build/lib.so
+
+'
+
+test_expect_success 'git-clean src/ src/' '
+
+	mkdir -p build docs &&
+	touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
+	git-clean src/ src/ &&
+	test -f Makefile &&
+	test -f README &&
+	test -f src/part1.c &&
+	test -f src/part2.c &&
+	test -f a.out &&
+	test ! -f src/part3.c &&
+	test -f docs/manual.txt &&
+	test -f obj.o &&
+	test -f build/lib.so
+
+'
+
+test_expect_success 'git-clean with prefix' '
+
+	mkdir -p build docs &&
+	touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
+	(cd src/ && git-clean) &&
+	test -f Makefile &&
+	test -f README &&
+	test -f src/part1.c &&
+	test -f src/part2.c &&
+	test -f a.out &&
+	test ! -f src/part3.c &&
+	test -f docs/manual.txt &&
+	test -f obj.o &&
+	test -f build/lib.so
+
+'
+test_expect_success 'git-clean -d with prefix and path' '
+
+	mkdir -p build docs src/feature &&
+	touch a.out src/part3.c src/feature/file.c docs/manual.txt obj.o build/lib.so &&
+	(cd src/ && git-clean -d feature/) &&
+	test -f Makefile &&
+	test -f README &&
+	test -f src/part1.c &&
+	test -f src/part2.c &&
+	test -f a.out &&
+	test -f src/part3.c &&
+	test ! -f src/feature/file.c &&
+	test -f docs/manual.txt &&
+	test -f obj.o &&
+	test -f build/lib.so
+
+'
+
+test_expect_success 'git-clean symbolic link' '
+
+	mkdir -p build docs &&
+	touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
+	ln -s docs/manual.txt src/part4.c
+	git-clean &&
+	test -f Makefile &&
+	test -f README &&
+	test -f src/part1.c &&
+	test -f src/part2.c &&
+	test ! -f a.out &&
+	test ! -f src/part3.c &&
+	test ! -f src/part4.c &&
+	test -f docs/manual.txt &&
+	test -f obj.o &&
+	test -f build/lib.so
+
+'
+
 test_expect_success 'git-clean -n' '
 
 	mkdir -p build docs &&
@@ -73,6 +160,24 @@ test_expect_success 'git-clean -d' '
 
 '
 
+test_expect_success 'git-clean -d src/ examples/' '
+
+	mkdir -p build docs examples &&
+	touch a.out src/part3.c docs/manual.txt obj.o build/lib.so examples/1.c &&
+	git-clean -d src/ examples/ &&
+	test -f Makefile &&
+	test -f README &&
+	test -f src/part1.c &&
+	test -f src/part2.c &&
+	test -f a.out &&
+	test ! -f src/part3.c &&
+	test ! -f examples/1.c &&
+	test -f docs/manual.txt &&
+	test -f obj.o &&
+	test -f build/lib.so
+
+'
+
 test_expect_success 'git-clean -x' '
 
 	mkdir -p build docs &&
-- 
1.5.3.GIT

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2007-11-05  4:28 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-11-05  4:28 [PATCH] Add more tests for git-clean Shawn Bohrer
  -- strict thread matches above, loose matches on Subject: below --
2007-11-04 19:02 [RFC] Second attempt at making git-clean a builtin Shawn Bohrer
2007-11-04 19:02 ` [PATCH] Add more tests for git-clean Shawn Bohrer
2007-11-04 23:35   ` Junio C Hamano
2007-11-04 23:46     ` Pierre Habouzit
2007-11-05  0:17       ` Junio C Hamano
2007-11-04 23:49     ` Johannes Schindelin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).