Commit graph

277 commits

Author SHA1 Message Date
Avery Pennarun
0a5f424ef8 User-overridden targets stay overridden even if the last build failed.
Previously, if 'redo-ifchange foo' failed last time, then creating foo
manually wouldn't help; 'redo-ifchange foo' would still try to rebuild it.
But if the first run *did* create it, then manually overriding it *did*
work.

That inconsistency is pointless.  If the user creates it by hand, it doesn't
matter if it failed to build last time or not; the user wants it overridden.
So this way, something that can't build can at least be manually created as
a hack.
2011-03-30 23:35:20 -04:00
Avery Pennarun
fb20652d04 Test for precenting state.relpath fix. 2011-03-27 15:25:11 -04:00
Avery Pennarun
705722d612 state.relpath: correct broken paths ending with /, etc.
Bug reported by Elliott Hird.  Based on a patch by Tim Allen, but I didn't
do it the same way.
2011-03-27 15:25:11 -04:00
Avery Pennarun
49228ce01c Add a test for the preceding fix (nonexistent directories). 2011-03-22 23:02:12 -07:00
Avery Pennarun
2efbbc26b9 Don't crash on targets in directories that don't exist yet.
The reason we'd crash is that we tried to pre-create a file called
$target.redo.tmp, which wouldn't work because the directory containing
$target didn't exist.

We now try to generate a smarter filename by using the innermost directory
of target that *does* exist.  It's a little messy, but the idea is to make
sure we won't have to rename() across a filesystem boundary if, for example,
there's a mounted filesystem in the middle of the hierarchy somewhere.
2011-03-22 23:00:34 -07:00
Avery Pennarun
07af5d83f9 redo: only default to 'all' in the toplevel instance of redo.
We already did this in minimal/do, and redo-ifchange already did this, but
plain redo didn't.  This made constructs like:

	for d in *.x; do
		echo "${d%.x}"
	done | xargs redo

dangerous, because if there were no matching files, we'd try to 'redo all'.
2011-03-10 21:10:15 -08:00
Avery Pennarun
2260bdd30f md2man: fix compatibility problem with python-markdown 1.6.
Symptom: the following error message when building redo.1:

	ValueError: non-man-compatible html tag u'br'
2011-03-10 19:49:18 -08:00
Avery Pennarun
d26ec22d88 Test for previous atime/ctime fix. 2011-03-10 14:37:07 -08:00
Avery Pennarun
4bf569c2a4 builder.py: detect overrides by only ctime, not all of struct stat.
We were accidentally including things like the atime in the comparison,
which is obviously silly; someone reading the file shouldn't mark it as a
manual override.
2011-03-10 14:36:45 -08:00
Avery Pennarun
d5e6951111 t/curse/Makefile: delete.
I don't remember why it was there, but we clearly don't use it anymore.
2011-03-10 14:36:45 -08:00
Avery Pennarun
989eb6804b minimal/do: fix a typo: DO_BUILD -> DO_BUILT
...and remove the "disable-if-minimal-do" from the test that would have
caught this bug.

Reported by Ulrik Sverdrup.
2011-03-06 21:38:34 -08:00
Avery Pennarun
164e213582 Test for previous PREFIX fix to minimal/do. 2011-03-05 19:03:34 -08:00
Avery Pennarun
0e037b8c45 minimal/do: leak fewer variables, especially PREFIX.
Since we use ". filename.do" to run the .do files instead of just
"filename.do", shell local variables end up being inherited by the
subprogram.  Change all the local variables to be all lowercase, to avoid
conflicting with any typical environment variables someone might use.

The particular variable that triggered this was PREFIX (reported by "ulrik"
on the mailing list) and that fixes this, at least.

Arguably we shouldn't be using ".", but using it avoids unnecessary forks,
which is kind of nice.
2011-03-05 19:03:34 -08:00
Avery Pennarun
c1a1f32445 MacOS: "-e filename/." returns true even for non-directories.
This has something to do with resource forks.  So use "-d filename/."
instead, which returns false if filename is not a directory.
2011-03-05 19:03:30 -08:00
Avery Pennarun
97eea66830 redo-sh.do: add 'posh' as another possible shell.
It fails, but who knows, maybe someday it won't.
2011-02-28 22:11:28 -08:00
Avery Pennarun
ee32a965d8 shelltest.od: test that $1/$2/$3 are set correctly in "." scripts.
dash seems to fail this one, and it's not pretty.
2011-02-28 22:07:21 -08:00
Avery Pennarun
32f584cb1c shelltest: detect the ". of empty script" shell problem. 2011-02-28 22:06:57 -08:00
Avery Pennarun
1ed168e79e minimal/do: work around a bug with empty .do files.
If you ". ./filename" and ./filename contains no commands, apparently
ash/dash will give the exit code of the command *before* the ., rather than
defaulting to zero as it supposedly should.  This should work around it in
our .do files at least.

Reported by Tim Allen.
2011-02-28 21:13:55 -08:00
Avery Pennarun
2dde4dbced redo-sh: on Solaris, try /usr/xpg4/bin/sh for a POSIX shell.
Suggested by someone on news.ycombinator.
2011-02-28 05:45:20 -08:00
Avery Pennarun
cfc3f44d64 minimal/do: 'redo-ifchange' with no parameters shouldn't try to build all.
It should just build nothing.  Because sometimes you want to do something
like:
	redo-ifchange $(find -name '*.c')

And the find doesn't return any results.  This is consistent with what real
redo does.

Added a test to confirm that it works.
2011-02-26 18:01:31 -08:00
Avery Pennarun
94c254de77 Rename flush-cache.py to flush-cache, and rearrange the code a bit.
It was working fine, but the style wasn't exactly the way I like it, because
I'm unnecessarily picky. :)

Also, removed the file extension since we should probably learn from the
fact that it's already been rewritten once from one language to another.
Who knows, maybe it will be again someday.
2011-02-23 01:27:41 -08:00
Joseph Garvin
d039aad57b Fix tests when the sqlite3 command line utility isn't installed.
We know the user already has to have python, so use its bindings.
2011-02-23 01:22:04 -08:00
Joseph Garvin
e8790145be Use /usr/bin/env to detect python location
...in case it's installed in a nonstandard location.
2011-02-23 01:21:27 -08:00
Avery Pennarun
0a14db937c README.md: mention the mailing list nearer to the top. 2011-02-22 02:16:37 -08:00
Avery Pennarun
2ef9d69b7b README.md: typo fix for my previous fix. 2011-02-21 15:02:22 -08:00
Avery Pennarun
0ce949fb81 README: a bunch of improvements to answer recent questions.
Inspired by some questions send to me in private email.
2011-02-21 05:11:59 -08:00
Avery Pennarun
a2bce72255 Simplify autodependency examples.
Turns out we don't need sed to process the output of gcc -MD.  We can just
do this:

	read DEPS <filename.deps

The 'read' command in sh actually handles backslashes correctly, so we don't
have to sed them out after all.  And then a simple ${DEPS#*:} removes the
"target:" prefix from the dependency line, and we're done!
2011-02-21 04:00:53 -08:00
Avery Pennarun
ea7057d9b6 redo-ifchange: remove special case for zero arguments.
Not sure why I put there, but special cases aren't worth the hassle.
2011-02-21 03:55:18 -08:00
Avery Pennarun
60b34d81ec vars.do: an improvement on the previous patch.
It would still loop infinitely if a string was "master " (trailing space).
2011-02-17 01:05:52 -08:00
Henry Gebhardt
6508cc0a63 version/vars.do: avoid infinite loop if the tag string is " master"
(ie. with an extra space)
2011-02-15 15:12:53 -08:00
Tim Allen
e27aaf01e7 Make redo read byte-strings from the database.
By default, the database redo uses to store file state returns filenames
as Unicode strings, and if redo tries to run a build-script whose
fully-qualified path contains non-ASCII characters then redo crashes
when trying to promote the path to a Unicode string.

This patch ensures that the database always returns byte-strings, not
Unicode strings. That way, the fully-qualified path and the target name
are both byte-strings and can be joined without issue.

(Fixes a bug reported by Zoran Zaric.)
2011-02-14 18:48:33 -08:00
Avery Pennarun
b43317bb83 md-to-man.do: remove leftover pandoc cruft.
Reported by Jimmy Tang on the mailing list.
2011-01-31 04:12:31 -08:00
Avery Pennarun
e174b09d5f Replace pandoc-based md-to-man conversion with a custom python script.
Hopefully this will appease the people who can't install pandoc on MacOS.
2011-01-29 23:27:23 -08:00
Avery Pennarun
3fdaa7cb0c Merge remote branch 'origin/master'
* origin/master:
  minimal-do: deal with 'clean.do' operations better.
  Add --version flag to `redo`.
2011-01-29 23:22:46 -08:00
Avery Pennarun
304e88022a minimal-do: deal with 'clean.do' operations better.
Sometimes clean.do implementations want to delete our .do_built file and
directory.  If that happens, deal with it quietly, as long as they don't
request any *additional* redo-type operations.
2011-01-28 21:10:04 -08:00
Wayne Larsen
39cfdafd8a Add --version flag to redo.
Something to this effect would be useful, though I'm sure my
install.do changes are not how you'd do it.

(Slightly modified by apenwarr)
2011-01-25 23:14:18 -08:00
Avery Pennarun
71316cc99a shelltest.od: abort correctly if 'cd ~' fails.
It seems 'set -e' doesn't quite work, in some shells, in that case.

Eric Kow wrote:
> I saw this warning, by the way:
> redo      t/shelltest
>   warning: 94
> cd: 271: can't cd to /opt/redo-0.05/t/space
> rmdir: failed to remove pace home dir': No such file or directory
>   warning: 111
2011-01-19 13:54:51 -08:00
Jimmy
b18404aab7 redo-sh.do: add mksh to the list of possible shells. 2011-01-19 13:52:02 -08:00
Avery Pennarun
5ea0cb01f5 version/gitvars: use redo-always if using git commands.
Otherwise we won't rebuild files when the commit id changes.
2011-01-18 00:55:25 -08:00
Avery Pennarun
c077d77285 builder.py: correctly set $3 to include the subdir path.
If we're using a .do file from a parent directory, we should set $3 using
the same path prefix as $1.  We were previously using just the basename,
which mostly works (since we would rename it to $1$2 eventually anyway) but
is not quite right, and you can't safely rename files across filesystems, so
it could theoretically cause problems.

Also improved t/defaults-nested to test for this behaviour.

Reported by Eric Kow.
2011-01-18 00:48:52 -08:00
Avery Pennarun
f3ae4e4e00 vars_init.py: always add .../redo-sh to the PATH, even if it doesn't exist.
Otherwise a fresh 'redo test' in the redo repo won't switch to using
redo-sh/sh after redo-sh.do runs, and the tests aren't accurate.
2011-01-18 00:48:52 -08:00
Avery Pennarun
474f2e71fe shelltest: confirm that 'local' is definitely available.
Supposedly it's not POSIX, but every shell I have seems to support it, so
let's just reject any that don't.  And like magic, anybody using redo can
now count on the 'local' builtin working.
2011-01-18 00:48:51 -08:00
Avery Pennarun
5dbbfd4288 shelltest: die if 'cd ~' can't handle spaces in $HOME.
This fails on ash, dash, and busybox sh (for now).  But it's kind of
important since $HOME often has spaces on Win32.  I hope dash will be fixed
relatively soon.

I downgraded it to a warning since on Unix, this probably isn't a problem.
2011-01-18 00:48:51 -08:00
Jimmy
4a296d676c t/defaults-nested/clean fails on MacOS X.
It seems on OSX find behaves differently (probably from linux):

jtang@exia:~/develop/redo $ make clean
./redo clean
redo  clean
redo    t/clean
redo      t/example/clean
redo      t/curse/clean
redo      t/deps/clean
redo        t/deps/basic/clean
redo        t/deps/dirtest/clean
redo      t/space dir/clean
redo      t/stamp/clean
redo      t/defaults-flat/clean
redo      t/defaults-nested/clean
find: illegal option -- n
find: illegal option -- a
find: illegal option -- m
find: illegal option -- e
find: *~: No such file or directory
redo      t/defaults-nested/clean: exit code 1
redo    t/clean: exit code 1
redo  clean: exit code 1
make: *** [clean] Error 1

This fixes it for me.
2011-01-18 00:48:51 -08:00
Avery Pennarun
340aad1797 state.Lock: destructor: unlock before closing, not the other way around. 2011-01-18 00:48:51 -08:00
Avery Pennarun
642d60a7c9 state.File.set_static(): barf if we set_static() a nonexistent file.
If that ever happens, we probably got our paths mangled (like in the
previous commit) so we should die right away rather than allow weird things
to happen later.
2011-01-18 00:48:51 -08:00
Avery Pennarun
4c06332ea1 builder.py: we weren't stamping .do files correctly if dodir!='.'.
The result was that t/deps/dirtest was actually failing in some cases.  But
it wasn't failing quite reliably enough, because the failing test was
dirtest/dir1/all, which has the same name as some other 'all' files,
confusing the issue.  Renamed dirtest/dir1/all.do to dirtest/dir1/go.do instead.

Reported by Prakhar Goel and Berke Durak.
2011-01-18 00:48:51 -08:00
Tim Allen
204ac1411d Fix another "==" -> "=" bashism.
I notice it doesn't quite work on my Ubuntu system - if I "cd version"
and run "../redo", I get the following output:

   redo  all
   redo    vars
   redo      gitvars
   [: 24: %H: unexpected operator
   [: 24: %d: unexpected operator
   [: 24: %ci: unexpected operator

...and then a hang.
2011-01-18 00:48:51 -08:00
Avery Pennarun
94b34ea031 Generate redo version codes in Documentation/*.1 automatically.
We have to go through some pretty scary gyrations to extract this
information from git, but it can be done.  This works with both tarballs
generated by 'git archive', or with your local git repo.

(Requested by 'David' on the mailing list.)
2011-01-17 23:01:40 -08:00
Avery Pennarun
897c218f85 redo.md: explain .do file search-parent-dirs feature. 2011-01-16 16:33:22 -08:00