Commit graph

126 commits

Author SHA1 Message Date
Avery Pennarun
02220d4318 t/110-compile and t/111-example: skip if no C compiler installed.
It's nice to validate "real" use with a C compiler, but silly to
completely fail validation just because a C compiler is missing.
2018-11-19 15:46:22 -05:00
Seamus Connor
190b4c34ff Replaced all instances of 'python' with 'python2'
On systems where 'python' refers to python3, redo
failed to launch. All invocations of python have been
made explicitly python2 invocations. All tests pass
on an Arch Linux system as of this commit.
2018-11-14 10:52:09 -08:00
Alexey Shamrin
59eb7e8f1e add link to projects using redo; fix t/example mention (#20)
also rename t/111-compile2 to t/111-example
2018-11-07 00:54:57 -05:00
Avery Pennarun
2023d36676 minimal/do: didn't work correctly with multi-level auto dir creation.
If we tried to build target a/b/c/d and a/b/c didn't exist yet, we
would correctly name the temp file something like a__b/c__d.tmp.  But
if a/b didn't exist yet, we named the temp file a/b__c/d.tmp, which
didn't work.  Instead, name it a/b__c__d.tmp as expected.
2018-11-02 04:27:28 -04:00
Avery Pennarun
ec72beb343 minimal/do: don't create a .did file until after a file is actually built.
With the new "continue" feature on by default, it turned out that
ctrl-c during a build, or a .do file returning an error, would mark a
target as "built" even though it hadn't been.  This would prevent
retrying it when you started minimal/do again.  Use a temp file
instead.

It's a little tricky: to prevent accidental recursion, we want to
create a file *before* building, but clean up that file when starting
the next session.  And we rename that file to the actual .did file
*after* building successfully.
2018-11-02 04:25:35 -04:00
Avery Pennarun
a14aa4c86d minimal/do whichdo: should print ../default.do if ../$1.do exists.
It would be incorrect to print ../$1.do (we only use $1.do in the
*current* directly, not prefix dirs; we only use default*.do in
those).  However, when we found ../default.do, we forgot to print it,
because of a silly logic error.
2018-11-02 03:13:45 -04:00
Avery Pennarun
e40dc5bad2 redo-whichdo: fix a bug where the last dir was checked twice, and add tests.
When we can't find a .do file, we walk all the way back to the root
directory.  When that happens, the root directory is actually searched
twice.  This is harmless (since a .do file doesn't exist there anyway)
but causes redo-whichdo to produce the wrong output.

Also, add a test, which I forgot to do when writing whichdo in the
first place.

To make the test work from the root directory, we need a way to
initialize redo without actually creating a .redo directory.  Add a
init_no_state() function for that purpose, and split the necessary path
functions into their own module so we can avoid importing builder.py.
2018-11-02 02:20:52 -04:00
Avery Pennarun
f4f9ed97ec t/clean.do: don't forget to run s??/clean. 2018-11-02 02:20:52 -04:00
Avery Pennarun
eb004d531e shelltest: downgrade #48 to a warning.
This is the test that
   x=y f
does *not* unset x after running f, if f is a shell function.  Apparently
that's the right thing to do, but freebsd dash 0.5.10.2 fails it.  This is
surprising because debian dash 0.5.8-2.4 passes, and it is presumably older.
Downgrade this to a warning because we want freebsd to have some cheap sh
variant that passes with redo, and nobody should be *relying* on this
insane behaviour anyway.

freebsd 11.2 sh (but not freebsd dash) fails test #24.  That one seems
rather serious, so I don't want to downgrade it to a warning.
2018-10-29 07:35:56 +00:00
Avery Pennarun
6c81b110be Tests: use cc instead of gcc.
This fixes problems where llvm is installed without a 'gcc' alias.
2018-10-29 07:20:33 +00:00
Avery Pennarun
f345eae290 minimal/do: redo vs redo-ifchange, and fix empty target handling.
We previously assumed that redo and redo-ifchange are the same in
minimal/do's design, because it rebuilds all targets on every run, and
so there's no reason to ever build the same target more than once.

Unfortunately that's incorrect: if you run 'redo x' from two points in
a single run (or even twice in the same .do file), we expect x to be
built twice.  If you wanted redo to decide whether to build it the
second time, you should have used redo-ifchange.

t/102-empty/touchtest was trying to test for this.  However, a
second bug in minimal/do made the test pass anyway.  minimal/do would
*always* rebuild any target x that produced no output, not caring
whether it had tried to build before, whether you used redo or
redo-ifchange.  And while we tested that redo would redo a file that
had been deleted, we didn't ensure that it would redo a file that was
*not* deleted, nor that redo-ifchange would *not* redo that file.

Fix both bugs in minimal/do, and make t/102-empty/touchtest cover the
missing cases.
2018-10-17 01:54:29 -04:00
Avery Pennarun
887df98ead builder.py: refresh the File object after obtaining the lock.
We need to create the File object to get its f.id, then lock that id.
During that gap, another instance of redo may have modified the file or
its state data, so we have to refresh it.

This fixes 'redo -j10 t/stress'.
2018-10-13 01:37:08 -04:00
Avery Pennarun
999ba4fb13 t/stress: add a test that usually triggers a bug using 950-curse.
It looks like we're updating the stamp for t/countall while another
task is replacing the file, which suggests a race condition in our
state management database.
2018-10-12 05:48:56 -04:00
Avery Pennarun
aa423a723f t/660-stamp: don't run at the same time as other tests in redo -j.
flush-cache can cause files affected by redo-stamp to get rebuilt
unnecessarily, which the test is specifically trying to validate.
Since other tests run flush-cache at random times when using -j, this
would cause random test failures.
2018-10-12 05:20:27 -04:00
Avery Pennarun
728a19cd52 t/*: some cleanups so switching between redo and minimal/do works.
Because the two programs use separate state databases, it helps if we
clean up some temp files between runs.  Otherwise they might think you
created some targets "by hand" and refuse to rebuild them.
2018-10-12 05:20:27 -04:00
Avery Pennarun
637521070b t/all.do: use redo instead of redo-ifchange.
I'm not quite sure what I was thinking, using redo-ifchange there, but
the result was that some tests wouldn't run if you run 'redo test'
repeatedly, even after modifying redo itself.

Also tweaked t/950-curse so that it always runs, not just the first
time.
2018-10-12 05:19:43 -04:00
Avery Pennarun
0d174f92c3 redo-sh: downgrade failures that affected dash; add a bash warning.
I feel a little dirty doing this, but the way the code was before, redo
almost always picked bash as the shell.  bash is way too overpowered
and this led to bashisms in do scripts unnecessarily.  The two failures
in dash are things that I would really like to have, but they haven't
materialized after 6 years, so I guess we should be realistic.

To appropriately penalize bash for asking for trouble, I added a
warning about [ 1 == 1 ] syntax being valid (as opposed to the POSIX
correct [ 1 = 1 ]).  This allows dash to be selected ahead of bash.

I also moved 'sh' to the end of the list, because although it's the
weakest shell on some systems, on other systems it's just bash.  And I
put zsh in front of bash, because fewer people have zsh and we want
them to test zsh.
2018-10-12 05:18:25 -04:00
Avery Pennarun
93d2515bc5 Missing a couple of rules in t/clean.do files. 2018-10-11 03:28:05 -04:00
Robert L. Bocchino Jr
7dd63efb37 Add cyclic dependence detection.
If a depends on b which depends on a, redo would just freeze.  Now it
aborts with a somewhat helpful error message.

[Updated by apenwarr for coding style and to add a test.]
2018-10-11 03:28:05 -04:00
Robert L. Bocchino Jr
63f9dcb640 Remove deprecated old-args feature. 2018-10-11 03:28:05 -04:00
Mildred Ki'Lya
1f32d06c4e Fix t/130-mode: "ls -l" output is not always as expected
[tweaked by apenwarr to remove dependency on non-portable /usr/bin/stat]
2018-10-11 03:28:05 -04:00
Alan Falloon
67c1d4f7d8 We sometimes missed deps when more than one dep required a stamp check.
If must_build was nonempty when recursively calling isdirty() that
returned a list, we'd lose the original value of must_build.
2018-10-11 03:28:05 -04:00
Tommi Virtanen
c2c013970e Avoid bashism >&file
The >& form is only for file descriptors, passing a file name there is
a bash extension.

    $ /bin/dash -c 'echo foo >&/dev/null'
    /bin/dash: 1: Syntax error: Bad fd number
2018-10-11 03:28:05 -04:00
Avery Pennarun
34669fba65 Use os.lstat() instead of os.stat().
I think this aligns better with how redo works.  Otherwise, if a.do
creates a as a symlink, then changes to the symlink's *target* will
change a's stat/stamp information without re-running a.do, which looks
to redo like you modified a by hand, which causes it to stop running
a.do altogether.

With this change, modifications to a's target are okay, but they don't
trigger any redo dependency changes.  If you want that, then a.do
should redo-ifchange on its symlink target explicitly.
2018-10-06 00:14:02 -04:00
Avery Pennarun
c28181e26f minimal/do: fix a really scary bugs in "set -e" behaviour.
If you run something like

  blah_function || return 1

then everything even *inside* blah_function is *not* subject to the "set -e"
that would otherwise be in effect.  That's true even for ". subfile" inside
blah_function - which is exactly how minimal/do runs .do files.

Instead, rewrite it as

  blah_function
  [ "$?" = "0" ] || return 1

And add a bit to the unit tests to ensure that "set -e" behaviour is enabled
in .do files as we expect, and crash loudly otherwise.

(This weird behaviour may only happen in some shells and not others.)

Also, we had a "helpful" alias of redo() defined at the bottom of the file.
Combined with the way we use '.' to source the .do files, this would make it
not start a new shell just to run a recursive 'redo' command.  It almost
works, but this stupid "set -e" bug could cause a nested .do file to not
honour "set -e" if someone ran "redo foo || exit 1" from inside a .do
script.  The performance optimization is clearly not worth it here, so
rename it to _redo(); that causes it to actually re-exec the redo program
(which is a symlink to minimal/do).
2012-02-09 00:42:41 -05:00
Avery Pennarun
ede182cb84 Add a test for install.do. 2012-02-09 00:42:41 -05:00
Avery Pennarun
a9ebabd6b7 Add a test for --keep-going option. 2012-02-09 00:42:41 -05:00
Avery Pennarun
9f6447e2cb Add a test for --shuffle option. 2012-02-09 00:42:41 -05:00
Avery Pennarun
34ce233f5e Rename 111-compile to 111-compile2.
Not a great name, but make it obvious that this is a slightly different test
from 110-compile.
2012-02-09 00:42:40 -05:00
Avery Pennarun
1f304f4d1d t/100-args: add a test for --old-args feature. 2012-02-09 00:42:40 -05:00
Avery Pennarun
a8bec74449 t/350-deps: 'redo clean' was crashing. 2012-02-08 22:56:04 -05:00
Avery Pennarun
c38e2bee92 t/201-fail: add a simple test for non-existent source files.
(This actually went uncaught in my redo rewrite.  Oops.)
2012-02-08 22:51:04 -05:00
Avery Pennarun
7822f5a5bb t/*: rearrange tests into numbered directories.
It was getting way too ad-hoc in there.  Let's reorganize the tests so that
there's a good, obvious, suggested sequence to run them in.
2012-02-08 01:56:50 -05:00
Avery Pennarun
116c279e96 t/*: update some tests from my rewrite branch.
Just some minor test fixes so that tests pass on both current redo and the
upcoming rewritten one.
2012-02-08 01:56:43 -05:00
Avery Pennarun
21f88094d5 Change definitions of $1,$2,$3 to match djb's redo.
If you use "redo --old-args", it will switch back to the old
(apenwarr-style) arguments for now, to give you time to update your .do
scripts.  This option will go away eventually.

Note: minimal/do doesn't understand the --old-args option.  If you're using
minimal/do in your project, keep using the old one until you update your use
of $1/$2, and then update to the new one.

apenwarr-style default.o.do:
   $1      foo
   $2      .o
   $3      whatever.tmp

djb-style default.o.do:
   $1      foo.o
   $2      foo
   $3      whatever.tmp

apenwarr-style foo.o.do:
   $1      foo.o
   $2      ""
   $3      whatever.tmp

djb-style foo.o.do:
   $1      foo.o
   $2      foo.o  (I think?)
   $3      whatever.tmp
2011-12-31 02:49:39 -05:00
Avery Pennarun
20951f9e6e t/pytest.do: don't run in minimal/do.
And add a reminder to test.do to run 'minimal/do test'.
2011-12-31 02:49:39 -05:00
Avery Pennarun
c6020cf1cd t/shelltest.od: quiet some error messages that get printed during testing.
If the error message only triggered a shelltest warning instead of a
failure, then they're harmless, so we might as well silence them when
running 'redo test' (which runs t/shelltest.do, which enables
SHELLTEST_QUIET).  We still want to print them when actually testing out
shelltest.od, though, to help with debugging the script.
2011-05-08 01:25:20 -04:00
Avery Pennarun
b993e449f8 shelltest: use a more magical magic number for success.
There may be some odd situation where a shell returns 0 despite not executing
the script correctly; now 0 is an error condition.
2011-04-17 23:39:53 -04:00
Avery Pennarun
e9e24bb450 t/shelltest.od: another test for ${x#y} behaviour.
If y contains a * character, it's a case-esac style wildcard unless it's in
"" or '', which tells it to match a literal *.  But in dash/busybox, the ''
quoting doesn't actually work, only "" does.

Since there's a workaround - just always use "" quoting - it's not that
fatal.  If the "" quoting doesn't work, then we'll make it fail.
2011-04-02 16:30:14 -07:00
Avery Pennarun
03763177ff shelltest.od: a few more/better tests and clarification comments. 2011-04-02 15:41:52 -07:00
Avery Pennarun
92c3e7c5af Test for previous override fix. 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
49228ce01c Add a test for the preceding fix (nonexistent directories). 2011-03-22 23:02:12 -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
d26ec22d88 Test for previous atime/ctime fix. 2011-03-10 14:37:07 -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
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
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