Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

What's the problem with "make clean test"? A test target would have a test-build prerequisite anyways, so

- clean out build artefacts - rebuild test builds - run tests

sounds very much ok to me.



One obvious problem is that that isn't what `make clean test` does.

Order isn't guaranteed, and most clean targets won't have any dependency relationship with test targets, so it could test and then clean. Or interleave them (clean between test dependencies). Or run them both simultaneously if someone has set the -j flag, and then who knows what happens. It does often work out, but it depends on a lot of things.

It's a consequence of make making things, not running tasks. You've told it to make two things that you've said are completely unrelated to each other. Order doesn't matter there, so make is free to do whatever it wants.

---

Other than that, make's behavior when a target updates dependencies of another target which do not share dependencies can get extremely complicated, and often depends on execution order. Clean generally affects many/most, so it's sometimes very problematic to run with any other.

You might also have computed test dependencies at parse time based on what's on disk, which have changed unexpectedly due to clean deleting those files. That can cause `make clean test` vs `make clean` and then `make test` to behave completely differently. The latter is the only consistently safe option, and the only one where your intent will always match what make will do.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: