Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix various issues in the test makefiles #1032

Merged
merged 3 commits into from
Apr 8, 2015

Conversation

torarnv
Copy link
Contributor

@torarnv torarnv commented Apr 7, 2015

  • Fix broken glob dependency from test bin targets
  • Ensure sharness test (clean, build, test, aggregate) is run sequentially
  • Ensure we don't remake binaries due to missing IPFS-BUILD-OPTIONS

@jbenet jbenet added backlog and removed ready labels Apr 7, 2015

test_sharness_short:
cd test/sharness/ && make
test_sharness_expensive: SHARNESS_MAKE_FLAGS += TEST_EXPENSIVE=1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i prefer explicitness in these targets. adding flags like that is errorprone in my opinion.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine by me, not married to 7acee02 and 086f038, those were just drive-by changes on the way to the other two. Personally I think duplicated code is more error prone, as things are changed one place but missed in another, and as a new contributor to a project I find logic easier to understand when I don't have to scan 4 instances of it to see if there's any difference in them.

@torarnv
Copy link
Contributor Author

torarnv commented Apr 7, 2015

@chriscool 📟

@@ -14,6 +14,9 @@ IPFS_ROOT = ../..
# User might want to override those on the command line
GOFLAGS =

# The targets in this makefile depend on being run sequentially
.NOTPARALLEL:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 i would love to move towards being able to run them in parallel. wonder what git does + how it would manage the sharness output. cc @chriscool

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may get away with adding explicit deps in the makefile. I wasn't sure if the tests themselves could be run in parallell. The main problem that spawned this is that with make -j4 eg, the tests will start running before the clean and the deps targets have been run, which resulted in the missing ipfs binary error. Let me try that real quick.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To run tests in parallel I think we need something like:

all:
    make clean
    make deps
    make $(T)
    make aggregate

and then use make -j 4 for example.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

b8bc885 adds the proper deps. I'm sure if the tests actually support the parallelism, so .NOTPARALLEL: should possibly be added either way.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jbenet about Git I had a look and yeah some work has been done a long time ago so that the tests can run in parallel (see git/git@abc5d37).

And there are always some flags or options or other stuff in the IPFS-BUILD-OPTIONS like files, so that there is no problem with empty files.

@jbenet
Copy link
Member

jbenet commented Apr 7, 2015

copying comments from the commit:

  • We dont want to have to rebuild on every test run-- this is unnecessarily slow.
  • if **/*.go doesnt work with gnu make, maybe we can use something like
    $(shell find $(IPFS_ROOT) | egrep ".go$")
    (not sure if this works)

@jbenet
Copy link
Member

jbenet commented Apr 7, 2015

i dont feel strongly about most comments above. only the rebuilds.

let's hear @chriscool's opinions?

@jbenet
Copy link
Member

jbenet commented Apr 7, 2015

Also, good find on both the parallel and gnu make bugs.

@torarnv
Copy link
Contributor Author

torarnv commented Apr 7, 2015

@chriscool

the IPFS-BUILD-OPTIONS target depends on FORCE but that doesn't mean that we are re-building the binaries on every invocation of make.

Actually, as long as $(GOFLAGS) is never set, we never write IPFS-BUILD-OPTIONS, so the dependency will always fail, and we'll re-make the binaries every time:

{vegas:~/dev/ipfs/src/github.com/ipfs/go-ipfs/test} $ rm -f IPFS-BUILD-OPTIONS
{vegas:~/dev/ipfs/src/github.com/ipfs/go-ipfs/test} $ make bin/ipfs --debug
GNU Make 3.81
Copyright (C) 2006  Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.

This program built for i386-apple-darwin11.3.0
Reading makefiles...
Updating goal targets....
   File `IPFS-BUILD-OPTIONS' does not exist.
     File `FORCE' does not exist.
    Must remake target `FORCE'.
    Successfully remade target file `FORCE'.
  Must remake target `IPFS-BUILD-OPTIONS'.
 Prerequisite `IPFS-BUILD-OPTIONS' of target `bin/ipfs' does not exist.
Must remake target `bin/ipfs'.
*** installing bin/ipfs ***
go build  -o bin/ipfs ../cmd/ipfs
{vegas:~/dev/ipfs/src/github.com/ipfs/go-ipfs/test} $ make bin/ipfs --debug
GNU Make 3.81
Copyright (C) 2006  Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.

This program built for i386-apple-darwin11.3.0
Reading makefiles...
Updating goal targets....
   File `IPFS-BUILD-OPTIONS' does not exist.
     File `FORCE' does not exist.
    Must remake target `FORCE'.
    Successfully remade target file `FORCE'.
  Must remake target `IPFS-BUILD-OPTIONS'.
 Prerequisite `IPFS-BUILD-OPTIONS' of target `bin/ipfs' does not exist.
Must remake target `bin/ipfs'.
*** installing bin/ipfs ***
go build  -o bin/ipfs ../cmd/ipfs

I'll fix that in a separate commit.

@torarnv
Copy link
Contributor Author

torarnv commented Apr 7, 2015

Okey, ready for review now, removed the subjective refactoring and focused on fixing the issues.

@torarnv torarnv changed the title Clean up test makefiles Fix various issues in the test makefiles Apr 7, 2015
If the file doesn't exist, make will conclude that the missing
prerequisite should trigger a rebuild of the binaries.
Running make -jN would result in the tests starting to execute
before the tests binaries were built, resulting in the error:

 "Cannot find the tests' local ipfs tool"

Each test now depends on the deps. They also depend on a new
target for cleaning the test results, so that the tests can
write new clean results.

The aggregate target also needs to depend on the same test
results clean target, as well as the tests themselves, so
that the aggregation happens when all tests have finished
running.

By introducing a separate target for cleaning test results we
also ensure that we don't end up removing and rebuilding
the binary on each test run.

The result is that the tests *can* be run with with -jN > 1,
but individual tests may still not supports this, so to get
stable test results it's still recommended to run them in
sequence.
GNU Make's wildcard function does not recurse into subdirectories when
passed the '**' glob, which results in adding a dependency only to .go
files in the first level of subdirectories under the source root.

We shell out to 'find' instead, which catches all .go files in the
given directory.
@chriscool
Copy link
Contributor

Ok, it LGTM, thanks @torarnv !

@torarnv
Copy link
Contributor Author

torarnv commented Apr 7, 2015

Thanks! Happy to help! 😄

@jbenet
Copy link
Member

jbenet commented Apr 8, 2015

Thanks @torarnv !

jbenet added a commit that referenced this pull request Apr 8, 2015
Fix various issues in the test makefiles
@jbenet jbenet merged commit 20dbea5 into ipfs:master Apr 8, 2015
@jbenet jbenet removed the backlog label Apr 8, 2015
@torarnv torarnv deleted the cleanup-makefiles branch April 8, 2015 01:00
@aschmahmann aschmahmann mentioned this pull request May 14, 2021
71 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants