##// END OF EJS Templates
bundle2: add a test for exceptions raised during the generation process...
Pierre-Yves David -
r23007:03f3af8f default
parent child Browse files
Show More
@@ -76,6 +76,7 b' Create an extension to test bundle2 API'
76 > ('', 'parts', False, 'include some arbitrary parts to the bundle'),
76 > ('', 'parts', False, 'include some arbitrary parts to the bundle'),
77 > ('', 'reply', False, 'produce a reply bundle'),
77 > ('', 'reply', False, 'produce a reply bundle'),
78 > ('', 'pushrace', False, 'includes a check:head part with unknown nodes'),
78 > ('', 'pushrace', False, 'includes a check:head part with unknown nodes'),
79 > ('', 'genraise', False, 'includes a part that raise an exception during generation'),
79 > ('r', 'rev', [], 'includes those changeset in the bundle'),],
80 > ('r', 'rev', [], 'includes those changeset in the bundle'),],
80 > '[OUTPUTFILE]')
81 > '[OUTPUTFILE]')
81 > def cmdbundle2(ui, repo, path=None, **opts):
82 > def cmdbundle2(ui, repo, path=None, **opts):
@@ -128,14 +129,22 b' Create an extension to test bundle2 API'
128 > bundler.newpart('test:SONG', [('randomparams', '')])
129 > bundler.newpart('test:SONG', [('randomparams', '')])
129 > if opts['parts']:
130 > if opts['parts']:
130 > bundler.newpart('test:ping')
131 > bundler.newpart('test:ping')
132 > if opts['genraise']:
133 > def genraise():
134 > yield 'first line\n'
135 > raise RuntimeError('Someone set up us the bomb!')
136 > bundler.newpart('b2x:output', data=genraise())
131 >
137 >
132 > if path is None:
138 > if path is None:
133 > file = sys.stdout
139 > file = sys.stdout
134 > else:
140 > else:
135 > file = open(path, 'wb')
141 > file = open(path, 'wb')
136 >
142 >
137 > for chunk in bundler.getchunks():
143 > try:
138 > file.write(chunk)
144 > for chunk in bundler.getchunks():
145 > file.write(chunk)
146 > except RuntimeError, exc:
147 > raise util.Abort(exc)
139 >
148 >
140 > @command('unbundle2', [], '')
149 > @command('unbundle2', [], '')
141 > def cmdunbundle2(ui, repo, replypath=None):
150 > def cmdunbundle2(ui, repo, replypath=None):
@@ -766,4 +775,28 b' with reply'
766 added 0 changesets with 0 changes to 3 files
775 added 0 changesets with 0 changes to 3 files
767 \x00\x00\x00\x00\x00\x00 (no-eol) (esc)
776 \x00\x00\x00\x00\x00\x00 (no-eol) (esc)
768
777
778 Check handling of exception during generation.
779 ----------------------------------------------
780 (is currently not right)
781
782 $ hg bundle2 --genraise > ../genfailed.hg2
783 abort: Someone set up us the bomb!
784 [255]
785
786 Should still be a valid bundle
787 (is currently not right)
788
789 $ cat ../genfailed.hg2
790 HG2X\x00\x00\x00\x11 (esc)
791 b2x:output\x00\x00\x00\x00\x00\x00 (no-eol) (esc)
792
793 And its handling on the other size raise a clean exception
794 (is currently not right)
795
796 $ cat ../genfailed.hg2 | hg unbundle2
797 0 unread bytes
798 abort: stream ended unexpectedly (got 0 bytes, expected 2)
799 [255]
800
801
769 $ cd ..
802 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now