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

sharness/t0060-daemon: don't reuse expect/actual names #1297

Merged
merged 2 commits into from
May 29, 2015
Merged

Conversation

cryptix
Copy link
Contributor

@cryptix cryptix commented May 28, 2015

If the names are reused, you might stare at the wrong output from another command, wondering what is going on.

@jbenet jbenet added the status/in-progress In progress label May 28, 2015
test_cmp_repeat_10_sec expected actual_daemon
echo "Initializing daemon..." >expected_daemon &&
echo "initializing ipfs node at $IPFS_PATH" >>expected_daemon &&
echo "generating 2048-bit RSA keypair...done" >>expected_daemon &&
Copy link
Member

Choose a reason for hiding this comment

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

how was this passing? ...

Copy link
Member

Choose a reason for hiding this comment

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

Oh it's disabled (test_expect_failure)

Copy link
Member

Choose a reason for hiding this comment

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

@cryptix any idea why it's failing? have we fixed it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure what you mean, It passes now.

I wanted to see if it does so in the test runners before I change the expectation.

Copy link
Member

Choose a reason for hiding this comment

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

the test is disabled:

test_expect_failure ...

Copy link
Member

Choose a reason for hiding this comment

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

ah it's fixed now nvm.

@chriscool
Copy link
Contributor

I am not sure doing that this kind of changes is worth it.
Git has been using "test_cmp expected actual" or "test_cmp expect actual" a lot and people don't complain about it:

$ git grep test_cmp -- 't*.sh' | wc -l
3895
$ git grep 'test_cmp expect actual'  -- 't*.sh' | wc -l
1343
$ git grep 'test_cmp expected actual'  -- 't*.sh' | wc -l
567

@chriscool
Copy link
Contributor

Also it might give a false sense of security while making test scripts more difficult to review.

For example if someone uses "expected_msg" at the top of a test script then you would want to make sure that "expected_msg" is used nowhere else in the same test script, which is difficult to maintain given that people often copy-paste tests.

@cryptix
Copy link
Contributor Author

cryptix commented May 29, 2015

@chriscool in general i'd agree. The problem here was, that test_expect_success passed because it tested the wrong assumption. Later tests then overwrote the previous output files, making it impossible to trace the original one.

@cryptix
Copy link
Contributor Author

cryptix commented May 29, 2015

I also don't like to make sure the names all add up but other than a nifty helper that creates these file names for me, I don't see how to deal with this other than stopping test execution after the first error, which might not be what we want for all tests (edit: which also isn't satisfactory in the light of false positives)?

@@ -14,6 +14,9 @@ test_expect_success "setup IPFS_PATH" '
'

# NOTE: this should remove bootstrap peers (needs a flag)
# TODO(cryptix):
# - we won't see daemon startup failure because we put the daemon in the background - fix: fork with exit code after api listen
# - also default ports: might clash with local clients. Failure in that case isn't clear as well because pollEndpoint just uses the already running node
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think, this is what drove us in circles in #1277 - On dev box, there might be another daemon running (on test env there might be an unkilled daemon still running). The effect is that pollEndpoint passes by dialing another daemon.

Copy link
Member

Choose a reason for hiding this comment

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

yeah, this issue is why iptb polls the 'ipfs id' endpoint and compares the returned ID against the expected one.

Copy link
Contributor Author

@cryptix cryptix May 29, 2015 via email

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

we could dump out the node id on the /version endpoints

@cryptix cryptix mentioned this pull request May 29, 2015
49 tasks
@jbenet
Copy link
Member

jbenet commented May 29, 2015

Also it might give a false sense of security while making test scripts more difficult to review.

agreed

For example if someone uses "expected_msg" at the top of a test script then you would want to make sure that "expected_msg" is used nowhere else in the same test script, which is difficult to maintain given that people often copy-paste tests.

I'm not sure what a good solution. i think reusing the names can be annoying to debug. but also a partial solution isn't safe either.

dont think it's a big deal either way

jbenet added a commit that referenced this pull request May 29, 2015
sharness/t0060-daemon: don't reuse expect/actual names
@jbenet jbenet merged commit 97d7589 into master May 29, 2015
@jbenet jbenet removed the status/in-progress In progress label May 29, 2015
@jbenet jbenet deleted the sharness/daemon branch May 29, 2015 19:54
@chriscool
Copy link
Contributor

I'm not sure what a good solution. i think reusing the names can be annoying to debug. but also a partial solution isn't safe either.

Yeah, there is no easy way to be safe, we just have to accept that and be careful.

It's easier to be careful when you can do fast pattern matching which is easier if the names are very often the same. For example if I see test_cmp actual expected I can easily see that it should probably be test_cmp expected actual because I am used a lot to seing the later and not the former. But if I see test_cmp foo bar, it's more difficult to quickly see if there might be a problem or not.

By the way, I created the following PR https://github.com/mlafeldt/sharness/pull/20 to add test_pause() from Git which might help debugging.

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