I tried to import an old quilt series that was over a svn repository into the
new git based one as a stgit patch stack, and encountered a bug in:
"stg import -s".
I had created some of the patches with "-p 0" argument to quilt to ease other
maintainers patch integration workflow. Those zero-strip-level patches were not
importing properly into stgit:
Traceback (most recent call last):
File "stgit/stgit/main.py", line 185, in _main
ret = command.func(parser, options, args)
File "stgit/stgit/commands/imprt.py", line 347, in func
__import_series(filename, options)
File "stgit/stgit/commands/imprt.py", line 249, in __import_series
__import_file(patchfile, options, patch)
File "stgit/stgit/commands/imprt.py", line 201, in __import_file
(f, pname) = __get_handle_and_name(filename)
File "stgit/stgit/commands/imprt.py", line 194, in __get_handle_and_name
return (open(filename), filename)
IOError: [Errno 2] No such file or directory:
'stgit/t/trash/t4200-import-s.sh/patches/patch-p0.diff -p0'
stg import: [Errno 2] No such file or directory:
'stgit/t/trash/t4200-import-s.sh/patches/patch-p0.diff
-p0'
This patch adds testing for quilt series import. Some of the tests are for
patches with various strip levels, some of them valid some invalid, or even
unexpected. It also add testing for various whitespace before comments, which
is working, but currently not tested.
Signed-off-by: Vincent Legoll <[email protected]>
---
t/t4200-import-s.sh | 251 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 251 insertions(+)
create mode 100755 t/t4200-import-s.sh
diff --git a/t/t4200-import-s.sh b/t/t4200-import-s.sh
new file mode 100755
index 0000000..1077523
--- /dev/null
+++ b/t/t4200-import-s.sh
@@ -0,0 +1,251 @@
+#!/bin/sh
+
+# Copyright (c) 2015 Vincent Legoll
+
+test_description='Test the import -s command'
+
+. ./test-lib.sh
+
+prepare_test_env () {
+
+ # Initialize git tree
+ mkdir s
+ echo 0 > t
+ echo 0 > s/u
+ git add t s/u
+ git commit -a -m initial
+
+ # Initialize patch stacking tool
+ stg init
+}
+
+cleanup_test () {
+ stg delete ..
+ rm -r patches .pc
+}
+
+before_test () {
+ # Initialize patch stacking tool
+ quilt init
+}
+
+after_test () {
+ # Revert to master status : undedit files
+ quilt pop -a
+}
+
+check_test () {
+ # Test importing quilt series
+ stg import -s patches/series
+}
+
+test_import_quilt_series_empty () {
+ # Test empty patch
+ quilt new empty.diff
+ quilt refresh
+}
+
+test_import_quilt_series_comment_whitespace () {
+ quilt new patch_before_comment.diff
+ quilt add t
+ echo 1 > t
+ quilt refresh
+
+ # Test comment indentation
+ echo "# Test comment at beginning-of-line" >> patches/series
+ echo " # Test <SPACE> character before comment" >> patches/series
+ echo " # Test <TAB> character before comment" >> patches/series
+
+ quilt new patch_after_comments.diff
+ quilt add t
+ echo 2 > t
+ quilt refresh
+}
+
+test_import_quilt_series_toplevel () {
+ # Top-level edits
+
+ quilt new patch.diff
+ quilt add t
+ echo 1 > t
+ quilt refresh
+
+ quilt new -p 0 patch-p0.diff
+ quilt add t
+ echo 2 > t
+ quilt refresh
+
+ quilt new -p 1 patch-p1.diff
+ quilt add t
+ echo 3 > t
+ quilt refresh
+
+ quilt new -p ab patch-pab.diff
+ quilt add t
+ echo 4 > t
+ quilt refresh
+}
+
+test_import_quilt_series_subdir () {
+ # Subdirectory edits
+
+ quilt new patch-s.diff
+ quilt add s/u
+ echo 1 > s/u
+ quilt refresh
+
+ quilt new -p 0 patch-p0-s.diff
+ quilt add s/u
+ echo 2 > s/u
+ quilt refresh
+
+ quilt new -p 1 patch-p1-s.diff
+ quilt add s/u
+ echo 3 > s/u
+ quilt refresh
+
+ quilt new -p ab patch-pab-s.diff
+ quilt add s/u
+ echo 4 > s/u
+ quilt refresh
+}
+
+test_import_quilt_series_should_fail_p_something_ok () {
+ quilt new -p $1 patch-p$1.diff
+ quilt add t
+ echo 4 > t
+ quilt refresh
+
+ quilt new -p $1 patch-p$1-s.diff
+ quilt add s/u
+ echo 4 > s/u
+ quilt refresh
+}
+
+test_import_quilt_series_should_fail_p_something_unexpected () {
+ quilt new patch-p$1.diff
+ quilt add t
+ echo 4 > t
+ quilt refresh
+
+ quilt new patch-p$1-s.diff
+ quilt add s/u
+ echo 4 > s/u
+ quilt refresh
+}
+
+test_expect_success \
+ 'Test quilt presence' \
+ 'quilt --version'
+
+prepare_test_env
+
+test_expect_success \
+ 'Import a quilt series with an empty patch' \
+ 'before_test &&
+ test_import_quilt_series_empty &&
+ after_test &&
+ check_test &&
+ cleanup_test
+ '
+
+test_expect_success \
+ 'Import a quilt series with indented comments' \
+ 'before_test &&
+ test_import_quilt_series_comment_whitespace &&
+ after_test &&
+ check_test &&
+ cleanup_test
+ '
+
+test_expect_success \
+ 'Import a quilt series with patches for toplevel files' \
+ 'before_test &&
+ test_import_quilt_series_toplevel &&
+ after_test &&
+ check_test &&
+ cleanup_test
+ '
+
+test_expect_success \
+ 'Import a quilt series with patches for subdirectories files' \
+ 'before_test &&
+ test_import_quilt_series_subdir &&
+ after_test &&
+ check_test &&
+ cleanup_test
+ '
+
+test_expect_code \
+ 2 \
+ 'Import a quilt series with unexpected "-p" in series' \
+ 'before_test &&
+ test_import_quilt_series_should_fail_p_something_unexpected '' &&
+ after_test &&
+ sed -e "s/^\(.*\)$/\1 -p/g" patches/series > series_messed &&
+ mv series_messed patches/series &&
+ check_test &&
+ cleanup_test
+ '
+
+test_expect_code \
+ 2 \
+ 'Import a quilt series with unexpected "-p1" in series' \
+ 'before_test &&
+ test_import_quilt_series_should_fail_p_something_ok 1 &&
+ after_test &&
+ sed -e "s/^\(.*\)$/\1 -p1/g" patches/series > series_messed &&
+ mv series_messed patches/series &&
+ check_test &&
+ cleanup_test
+ '
+
+test_expect_code \
+ 2 \
+ 'Import a quilt series with unexpected "-pab" in series' \
+ 'before_test &&
+ test_import_quilt_series_should_fail_p_something_ok ab &&
+ after_test &&
+ sed -e "s/^\(.*\)$/\1 -pab/g" patches/series > series_messed &&
+ mv series_messed patches/series &&
+ check_test &&
+ cleanup_test
+ '
+
+test_expect_code \
+ 2 \
+ 'Import a quilt series with unexpected "-p000" in series' \
+ 'before_test &&
+ test_import_quilt_series_should_fail_p_something_unexpected 000 &&
+ after_test &&
+ sed -e "s/^\(.*\)$/\1 -p000/g" patches/series > series_messed &&
+ mv series_messed patches/series &&
+ check_test &&
+ cleanup_test
+ '
+
+test_expect_code \
+ 2 \
+ 'Import a quilt series with unexpected "-p42" in series' \
+ 'before_test &&
+ test_import_quilt_series_should_fail_p_something_unexpected 42 &&
+ after_test &&
+ sed -e "s/^\(.*\)$/\1 -p42/g" patches/series > series_messed &&
+ mv series_messed patches/series &&
+ check_test &&
+ cleanup_test
+ '
+
+test_expect_code \
+ 2 \
+ 'Import a quilt series with unexpected "-pYo" in series' \
+ 'before_test &&
+ test_import_quilt_series_should_fail_p_something_unexpected Yo &&
+ after_test &&
+ sed -e "s/^\(.*\)$/\1 -pYo/g" patches/series > series_messed &&
+ mv series_messed patches/series &&
+ check_test &&
+ cleanup_test
+ '
+
+test_done
--
2.1.4
_______________________________________________
stgit-users mailing list
[email protected]
https://mail.gna.org/listinfo/stgit-users