mbox series

[0/3] bring some tests to newer style.

Message ID 20180921235833.99045-1-sbeller@google.com (mailing list archive)
Headers show
Series bring some tests to newer style. | expand

Message

Stefan Beller Sept. 21, 2018, 11:58 p.m. UTC
The old formatting style is a real hindrance of getting people up to speed
contributing as they use existing code as an example and follow that style.
So let's get rid of the old style and reformat it in our current style.

This was reported off list by Derrick and Jeff as both of them followed
outdated formatting style for their first patches only to have a long
discussion on the mailing list on style.

The tests changed are not modified in origin/master..origin/pu,
and they were changed using a hacky script:
--8<--
#!/usr/bin/python
import sys
def applyformat(fname):
	with open(fname, 'r') as f:
		lines = f.readlines()
		state = "lookingforstart"
		outlines = []
		for line in lines:
			if state == "lookingforstart":
				if line == "test_expect_success \\\n":
					print "AHA!"
					state = "firstlinefound"
				else:
					outlines += [line]
			elif state == "firstlinefound":
				l = line.strip()
				must_strip = False
				if l.endswith("\\"):
					l = l[:-1]
					must_strip=True
				if l.endswith("'"):
					l = l[:-1].strip()
				if l.startswith("'"):
					line = "test_expect_success " + l + " '\n"
					outlines += [line]
					state = "re-indent-until-done"
				else:
					print "what?"
					exit(1)
			elif state == "re-indent-until-done":
				l = line.strip()
				if must_strip:
					if l.startswith("'"):
						l = l[1:]
						must_strip = False
					else:
						print "what 1?"
						exit(1)
				if l.endswith("'"):
					l = l[:-1]
					state = "lookingforstart"

				if len(l):
					line = "	" + l + "\n"
					outlines += [line]
				elif state == "lookingforstart":
					# skip an empty line before test is done
					pass
				else:
					outlines += ["\n"]

				if state == "lookingforstart":
					outlines += ["'\n"]
			else:
				print "what?"
				exit(1)
	with open(fname, 'w') as f:
		f.write(''.join(outlines))

for n in sys.argv[1:]:
	print n
	applyformat(n)
--8<--

Thanks,
Stefan

Stefan Beller (3):
  t7001: reformat to newer style
  t7004: reformat style
  t0030: reformat style

 t/t0030-stripspace.sh | 525 ++++++++++++++++++++----------------------
 t/t7001-mv.sh         | 268 ++++++++++-----------
 t/t7004-tag.sh        | 149 +++++-------
 3 files changed, 444 insertions(+), 498 deletions(-)