Submitter | timeless@mozdev.org |
---|---|
Date | Jan. 12, 2016, 6:38 p.m. |
Message ID | <a4f6489df893272a532f.1452623885@waste.org> |
Download | mbox | patch |
Permalink | /patch/12698/ |
State | Changes Requested |
Delegated to: | Pierre-Yves David |
Headers | show |
Comments
On Tue, 12 Jan 2016 12:38:05 -0600, timeless wrote: > # HG changeset patch > # User timeless <timeless@mozdev.org> > # Date 1452619172 0 > # Tue Jan 12 17:19:32 2016 +0000 > # Node ID a4f6489df893272a532f9d9cf88b12fd0619efc6 > # Parent 13f44adf400886e8d65fcb2bcf5dc5763b250214 > run-tests: handle output that starts with "$ " > > This is necessary because some help content happens to start with that pattern, > and it is legitimate, so, we add an escape sequence for "$ " as "\$ ". > > If you need to use this escape sequence in a dynamic (echo > test-test.t << EOF) > test, remember that you have to escape your backslash because the first one > will be parsed by the shell, and thus will not be in your file. > > For normal users, a single backslash is enough, and running your test with -i > will generate the proper escaping. > > diff --git a/tests/run-tests.py b/tests/run-tests.py > --- a/tests/run-tests.py > +++ b/tests/run-tests.py > @@ -1045,6 +1045,9 @@ > elif l.startswith(b' > '): # continuations > after.setdefault(prepos, []).append(l) > script.append(l[4:]) > + elif l.startswith(b' \\$'): # results > + # Queue up a list of expected results. > + expected.setdefault(pos, []).append(l[2:]) > elif l.startswith(b' '): # results > # Queue up a list of expected results. > expected.setdefault(pos, []).append(l[2:]) This seems fine, but " > ", " >>> ", etc. would have the same issue in theory. So I came up with an idea, " (literal)" suffix. Haven't tried. $ ls (literal) foo.c $ hg status (literal) foo.c
As long as the .err generator automatically produces it, I'm fine with it. Actually I'd love for there to be a mode for a command where it outputs at the beginning whether the output will include file paths, that'd enable us to recognize that /'s in output should be expected to change direction and thus the err generator should produce (glob) or whatever we're using to handle backslash/slash differences. On Jan 15, 2016 9:59 AM, "Yuya Nishihara" <yuya@tcha.org> wrote: > On Tue, 12 Jan 2016 12:38:05 -0600, timeless wrote: > > # HG changeset patch > > # User timeless <timeless@mozdev.org> > > # Date 1452619172 0 > > # Tue Jan 12 17:19:32 2016 +0000 > > # Node ID a4f6489df893272a532f9d9cf88b12fd0619efc6 > > # Parent 13f44adf400886e8d65fcb2bcf5dc5763b250214 > > run-tests: handle output that starts with "$ " > > > > This is necessary because some help content happens to start with that > pattern, > > and it is legitimate, so, we add an escape sequence for "$ " as "\$ ". > > > > If you need to use this escape sequence in a dynamic (echo > test-test.t > << EOF) > > test, remember that you have to escape your backslash because the first > one > > will be parsed by the shell, and thus will not be in your file. > > > > For normal users, a single backslash is enough, and running your test > with -i > > will generate the proper escaping. > > > > diff --git a/tests/run-tests.py b/tests/run-tests.py > > --- a/tests/run-tests.py > > +++ b/tests/run-tests.py > > @@ -1045,6 +1045,9 @@ > > elif l.startswith(b' > '): # continuations > > after.setdefault(prepos, []).append(l) > > script.append(l[4:]) > > + elif l.startswith(b' \\$'): # results > > + # Queue up a list of expected results. > > + expected.setdefault(pos, []).append(l[2:]) > > elif l.startswith(b' '): # results > > # Queue up a list of expected results. > > expected.setdefault(pos, []).append(l[2:]) > > This seems fine, but " > ", " >>> ", etc. would have the same issue in > theory. So I came up with an idea, " (literal)" suffix. Haven't tried. > > $ ls (literal) > foo.c > $ hg status (literal) > foo.c > _______________________________________________ > Mercurial-devel mailing list > Mercurial-devel@selenic.com > https://selenic.com/mailman/listinfo/mercurial-devel >
On 01/15/2016 06:47 AM, Yuya Nishihara wrote: > On Tue, 12 Jan 2016 12:38:05 -0600, timeless wrote: >> # HG changeset patch >> # User timeless <timeless@mozdev.org> >> # Date 1452619172 0 >> # Tue Jan 12 17:19:32 2016 +0000 >> # Node ID a4f6489df893272a532f9d9cf88b12fd0619efc6 >> # Parent 13f44adf400886e8d65fcb2bcf5dc5763b250214 >> run-tests: handle output that starts with "$ " >> >> This is necessary because some help content happens to start with that pattern, >> and it is legitimate, so, we add an escape sequence for "$ " as "\$ ". >> >> If you need to use this escape sequence in a dynamic (echo > test-test.t << EOF) >> test, remember that you have to escape your backslash because the first one >> will be parsed by the shell, and thus will not be in your file. >> >> For normal users, a single backslash is enough, and running your test with -i >> will generate the proper escaping. >> >> diff --git a/tests/run-tests.py b/tests/run-tests.py >> --- a/tests/run-tests.py >> +++ b/tests/run-tests.py >> @@ -1045,6 +1045,9 @@ >> elif l.startswith(b' > '): # continuations >> after.setdefault(prepos, []).append(l) >> script.append(l[4:]) >> + elif l.startswith(b' \\$'): # results >> + # Queue up a list of expected results. >> + expected.setdefault(pos, []).append(l[2:]) >> elif l.startswith(b' '): # results >> # Queue up a list of expected results. >> expected.setdefault(pos, []).append(l[2:]) > > This seems fine, but " > ", " >>> ", etc. would have the same issue in > theory. So I came up with an idea, " (literal)" suffix. Haven't tried. > > $ ls (literal) > foo.c > $ hg status (literal) > foo.c Just to clarify, you mean a "(literal)" flag at the end of any line as we do for (glob) and (re) to mark it as an output line. The idea seems good to me. I'm not entirely convinced by the name (but fine with it). Cheers,
On Sun, 17 Jan 2016 10:48:26 -0800, Pierre-Yves David wrote: > On 01/15/2016 06:47 AM, Yuya Nishihara wrote: > > On Tue, 12 Jan 2016 12:38:05 -0600, timeless wrote: > >> # HG changeset patch > >> # User timeless <timeless@mozdev.org> > >> # Date 1452619172 0 > >> # Tue Jan 12 17:19:32 2016 +0000 > >> # Node ID a4f6489df893272a532f9d9cf88b12fd0619efc6 > >> # Parent 13f44adf400886e8d65fcb2bcf5dc5763b250214 > >> run-tests: handle output that starts with "$ " > >> > >> This is necessary because some help content happens to start with that pattern, > >> and it is legitimate, so, we add an escape sequence for "$ " as "\$ ". > >> > >> If you need to use this escape sequence in a dynamic (echo > test-test.t << EOF) > >> test, remember that you have to escape your backslash because the first one > >> will be parsed by the shell, and thus will not be in your file. > >> > >> For normal users, a single backslash is enough, and running your test with -i > >> will generate the proper escaping. > >> > >> diff --git a/tests/run-tests.py b/tests/run-tests.py > >> --- a/tests/run-tests.py > >> +++ b/tests/run-tests.py > >> @@ -1045,6 +1045,9 @@ > >> elif l.startswith(b' > '): # continuations > >> after.setdefault(prepos, []).append(l) > >> script.append(l[4:]) > >> + elif l.startswith(b' \\$'): # results > >> + # Queue up a list of expected results. > >> + expected.setdefault(pos, []).append(l[2:]) > >> elif l.startswith(b' '): # results > >> # Queue up a list of expected results. > >> expected.setdefault(pos, []).append(l[2:]) > > > > This seems fine, but " > ", " >>> ", etc. would have the same issue in > > theory. So I came up with an idea, " (literal)" suffix. Haven't tried. > > > > $ ls (literal) > > foo.c > > $ hg status (literal) > > foo.c > > Just to clarify, you mean a "(literal)" flag at the end of any line as > we do for (glob) and (re) to mark it as an output line. Yes. > The idea seems good to me. I'm not entirely convinced by the name (but > fine with it). I don't like "literal", too.
Patch
diff --git a/tests/run-tests.py b/tests/run-tests.py --- a/tests/run-tests.py +++ b/tests/run-tests.py @@ -1045,6 +1045,9 @@ elif l.startswith(b' > '): # continuations after.setdefault(prepos, []).append(l) script.append(l[4:]) + elif l.startswith(b' \\$'): # results + # Queue up a list of expected results. + expected.setdefault(pos, []).append(l[2:]) elif l.startswith(b' '): # results # Queue up a list of expected results. expected.setdefault(pos, []).append(l[2:]) @@ -1077,6 +1080,11 @@ lout, lcmd = l.split(salt, 1) while lout: + # We generally expect lines that start with "$ " + # To be commands, but they can also be the result of + # output, when that happens, we escape them with a \. + if lout.startswith('$ '): + lout = '\\' + lout if not lout.endswith(b'\n'): lout += b' (no-eol)\n' diff --git a/tests/test-help.t b/tests/test-help.t --- a/tests/test-help.t +++ b/tests/test-help.t @@ -2260,24 +2260,24 @@ <ul> <li> New (unknown) files are added automatically by "hg add": <pre> - \$ ls (re) + \$ ls foo.c - \$ hg status (re) + \$ hg status ? foo.c - \$ hg add (re) + \$ hg add adding foo.c - \$ hg status (re) + \$ hg status A foo.c </pre> <li> Specific files to be added can be specified: <pre> - \$ ls (re) + \$ ls bar.c foo.c - \$ hg status (re) + \$ hg status ? bar.c ? foo.c - \$ hg add bar.c (re) - \$ hg status (re) + \$ hg add bar.c + \$ hg status A bar.c ? foo.c </pre> diff --git a/tests/test-run-tests.t b/tests/test-run-tests.t --- a/tests/test-run-tests.t +++ b/tests/test-run-tests.t @@ -620,6 +620,16 @@ $ rm -f test-glob-backslash.t +dollar at beginning of line needs to be escaped + + $ cat > test-dollar-escape.t << EOF + > $ echo $ echo this + > \\$ echo this + > EOF + $ rt test-dollar-escape.t + . + # Ran 1 tests, 0 skipped, 0 warned, 0 failed. + Test reusability for third party tools ======================================