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

Error: "grep: unrecognized option `--null-data' " #14

Closed
HappyRay opened this issue Jul 30, 2015 · 15 comments
Closed

Error: "grep: unrecognized option `--null-data' " #14

HappyRay opened this issue Jul 30, 2015 · 15 comments

Comments

@HappyRay
Copy link

Hi,

Your tool looks great and would save a lot of work for me.

However when I tried your tool with one of my wiki page

gh-md-toc https://github.com/box/TestScribe/wiki/FAQ

I got the following error

Table of Contents
=================

grep: unrecognized option `--null-data'
usage: grep [-abcDEFGHhIiJLlmnOoqRSsUVvwxZ] [-A num] [-B num] [-C[num]]
        [-e pattern] [-f file] [--binary-files=value] [--color=when]
        [--context[=num]] [--directories=action] [--label] [--line-buffered]
      [--null] [pattern] [file ...]


Created by [gh-md-toc](https://github.com/ekalinin/github-markdown-toc)

I got the same error when I run it with a local .md file.

What did I miss?

@ekalinin
Copy link
Owner

Hi @HappyRay ,

Your tool looks great and would save a lot of work for me.

Glad to hear that. Thanks!

I got the following error

What OS do you use?

Here's my try:

➥ uname -r -s -v -m -o
Linux 3.19.0-26-generic #27-Ubuntu SMP Tue Jul 28 18:27:31 UTC 2015 x86_64 GNU/Linux
➥ grep --version | head -n1
grep (GNU grep) 2.20
➥ cat /etc/issue
Ubuntu 15.04 \n \l
➥ ./gh-md-toc --version
0.4.4
➥ ./gh-md-toc https://github.com/box/TestScribe/wiki/FAQ

Table of Contents
=================

        * [What else can I use this tool for other than generating unit tests?](#what-else-can-i-use-this-tool-for-other-than-generating-unit-tests)
        * [Will this tool fully automate the creation of unit tests?](#will-this-tool-fully-automate-the-creation-of-unit-tests)
        * [How can I find the help when I forget the input format when prompted for inputs](#how-can-i-find-the-help-when-i-forget-the-input-format-when-prompted-for-inputs)
        * [How can I make sure that all branches of my code are covered by unit tests?](#how-can-i-make-sure-that-all-branches-of-my-code-are-covered-by-unit-tests)
        * [How does the tool handle dependencies such as dependent classes?](#how-does-the-tool-handle-dependencies-such-as-dependent-classes)
        * [The tool basically would take the current implementation as the contract. What if the current implementation is wrong?](#the-tool-basically-would-take-the-current-implementation-as-the-contract-what-if-the-current-implementation-is-wrong)
        * [What are the files under test_generator/history folder after I run the tool?](#what-are-the-files-under-test_generatorhistory-folder-after-i-run-the-tool)
        * [Will this tool encourage developers to be sloppy and create tests that test wrong behaviors.](#will-this-tool-encourage-developers-to-be-sloppy-and-create-tests-that-test-wrong-behaviors)
        * [Can I generate multiple tests of the same method with different inputs?](#can-i-generate-multiple-tests-of-the-same-method-with-different-inputs)
        * [Does this technique work for languages other than PHP?](#does-this-technique-work-for-languages-other-than-php)
        * [Are tests of private or protected methods supported?](#are-tests-of-private-or-protected-methods-supported)
        * [Does this tool support test driven development?](#does-this-tool-support-test-driven-development)
        * [Can I modify the generated tests manually?](#can-i-modify-the-generated-tests-manually)
        * [Is there a plan to use constants and variables instead of literals such as 12, 'foo' etc in the generated tests?](#is-there-a-plan-to-use-constants-and-variables-instead-of-literals-such-as-12-foo-etc-in-the-generated-tests)
        * [Has the same technique been used elsewhere?](#has-the-same-technique-been-used-elsewhere)
        * [Does the tool support data providers?](#does-the-tool-support-data-providers)
        * [How do I know if the tool will work for the test method I would like to test?](#how-do-i-know-if-the-tool-will-work-for-the-test-method-i-would-like-to-test)
        * [Is the tool only useful for new code? What if I am modifying an existing code?](#is-the-tool-only-useful-for-new-code-what-if-i-am-modifying-an-existing-code)
        * [Can the tool still help when I run into the tool's limitations?](#can-the-tool-still-help-when-i-run-into-the-tools-limitations)
      * [How do I update the unit tests after I update the contract of my production code](#how-do-i-update-the-unit-tests-after-i-update-the-contract-of-my-production-code)
      * [I need to create tests with a few variations of a long array. How do I do it more efficiently?](#i-need-to-create-tests-with-a-few-variations-of-a-long-array-how-do-i-do-it-more-efficiently)
      * [Can the tool be enhanced to choose the inputs for me.](#can-the-tool-be-enhanced-to-choose-the-inputs-for-me)
      * [Can you fix the formatting of the generated code?](#can-you-fix-the-formatting-of-the-generated-code)
      * [Can I use the tool to generate integration tests?](#can-i-use-the-tool-to-generate-integration-tests)
      * [Is the tool useful for generating unit tests for simple methods?](#is-the-tool-useful-for-generating-unit-tests-for-simple-methods)
      * [How is the readability of the generated tests?](#how-is-the-readability-of-the-generated-tests)
        * [Can the tool generate tests that will fail when the production code calls methods that are not expected?](#can-the-tool-generate-tests-that-will-fail-when-the-production-code-calls-methods-that-are-not-expected)
        * [Intellij can also give warning or errors. Can't we just rely on it to find errors?](#intellij-can-also-give-warning-or-errors-cant-we-just-rely-on-it-to-find-errors)
        * [Can the test generator handle methods that have side effects?](#can-the-test-generator-handle-methods-that-have-side-effects)
        * [Does the tool support HHVM?](#does-the-tool-support-hhvm)

Created by [gh-md-toc](https://github.com/ekalinin/github-markdown-toc)

@ekalinin
Copy link
Owner

Btw, try go-based analogue of this tool:

It hasn't any dependencies (grep, curl, etc) and should work for you.
On the releases page there're pre-compiled binaries. Please, find one for you OS and try it.

@HappyRay
Copy link
Author

I am on a Mac. After I downloaded the version with Darwin in the names, both go based and the one from this project worked for me.

The only change I had to make is to remove the leading spaces. Otherwise the content showed up as preformatted text. Is there any reason to generate the output with leading spaces?

see the result at
https://github.com/box/TestScribe/wiki/FAQ

Thanks for your help!

@ekalinin
Copy link
Owner

ekalinin commented Aug 1, 2015

Great! Glad it works for you.

@ekalinin ekalinin closed this as completed Aug 1, 2015
@HappyRay
Copy link
Author

HappyRay commented Aug 1, 2015

Any comment on the space issue?

"The only change I had to make is to remove the leading spaces. Otherwise the content showed up as preformatted text. Is there any reason to generate the output with leading spaces?"

@ekalinin ekalinin reopened this Aug 2, 2015
@ekalinin
Copy link
Owner

ekalinin commented Aug 2, 2015

Any comment on the space issue?

The only change I had to make is to remove the leading spaces. Otherwise the content showed up as preformatted text. Is there any reason to generate the output with leading spaces?

Sorry, missed that. Would you able to provide more details?
As i didn't get where did you "remove the leading spaces"? In the wiki page?
Where can i get that version of wiki page on which bash-based tool doesn't work?
And show your's version of the grep, please.

The only problem i see atm is that mac's version of the grep doesnt have --null-data option.

@HappyRay
Copy link
Author

HappyRay commented Aug 2, 2015

In both this version and the go version, the output for me is similar to what you referenced above:

e.g.

eg.

➥ ./gh-md-toc https://github.com/box/TestScribe/wiki/FAQ

Table of Contents
=================

        * [What else can I use this tool for other than generating unit tests?](#what-else-can-i-use-this-tool-for-other-than-generating-unit-tests)
        * [Will this tool fully automate the creation of unit tests?](#will-this-tool-fully-automate-the-creation-of-unit-tests)

Notice the leading spaces before '*' character? I had to remove them manually.

Hope it helps.

@ekalinin
Copy link
Owner

ekalinin commented Aug 3, 2015

Notice the leading spaces before '*' character? I had to remove them manually.

Yeah, now i see.

It's not a bug :) it's a feature.

For every header i put two spaces before asterisk corrsponding to the level of the header.
This is for tree-like output of the TOC.
Usually, headers are located as follows h1 > h2 > h3 .. > h6.

For example. Page:

There's one h1 header and two h2 headers.

And here's an output:

➥ ./gh-md-toc https://github.com/ekalinin/nodeenv/wiki/Who-Uses-Nodeenv

Table of Contents
=================

  * [Who Uses Nodeenv?](#who-uses-nodeenv)
    * [OpenStack](#openstack)
    * [pre-commit.com](#pre-commitcom)

So, in your case i see a lot of headers like h3 and h4.
And that's the reason of such amout of leading spaces.

@HappyRay
Copy link
Author

HappyRay commented Aug 3, 2015

I have only h4 headers on my page. That explained the leading spaces.

But the effect for my page is that the formatting needs to be manually adjusted. Maybe there is an easier way than removing all the leading spaces.
It would be nice to be able to configure the tool to not generate leading spaces at all. But even with the manual workaround, your tool is helpful to me. I will keep using it.

BTW, just curious, why do you need to create different binaries for different platforms even though the go version is supposed to be platform independent. Is it because you need to distribute the go language run time itself which is platform dependent?

Thanks

@ekalinin
Copy link
Owner

ekalinin commented Aug 4, 2015

I have only h4 headers on my page. That explained the leading spaces.

Seems, you have not only h4, but h3 headers as well:

➥ ./gh-md-toc https://github.com/box/TestScribe/wiki/FAQ | grep -E "^\s{6}\*"                                                                                                                                     Вт. авг.  4 09:42:01 MSK 2015
      * [How do I update the unit tests after I update the contract of my production code](#how-do-i-update-the-unit-tests-after-i-update-the-contract-of-my-production-code)
      * [I need to create tests with a few variations of a long array. How do I do it more efficiently?](#i-need-to-create-tests-with-a-few-variations-of-a-long-array-how-do-i-do-it-more-efficiently)
      * [Can the tool be enhanced to choose the inputs for me.](#can-the-tool-be-enhanced-to-choose-the-inputs-for-me)
      * [Can you fix the formatting of the generated code?](#can-you-fix-the-formatting-of-the-generated-code)
      * [Can I use the tool to generate integration tests?](#can-i-use-the-tool-to-generate-integration-tests)
      * [Is the tool useful for generating unit tests for simple methods?](#is-the-tool-useful-for-generating-unit-tests-for-simple-methods)
      * [How is the readability of the generated tests?](#how-is-the-readability-of-the-generated-tests)

And here it is:

➥ curl -s https://github.com/box/TestScribe/wiki/FAQ | grep -B1 "How do I update the unit tests after I update the contract of my production code</h3>"                                                           Вт. авг.  4 09:43:25 MSK 2015
<h3>
<a id="user-content-how-do-i-update-the-unit-tests-after-i-update-the-contract-of-my-production-code" class="anchor" href="#how-do-i-update-the-unit-tests-after-i-update-the-contract-of-my-production-code" aria-hidden="true"><span class="octicon octicon-link"></span></a>How do I update the unit tests after I update the contract of my production code</h3>

@ekalinin
Copy link
Owner

ekalinin commented Aug 4, 2015

But the effect for my page is that the formatting needs to be manually adjusted. Maybe there is an easier way than removing all the leading spaces.

Yeah, it make sense to add option like --plain to show all headers on one level. And not format a tree-like TOC.

@ekalinin
Copy link
Owner

ekalinin commented Aug 4, 2015

But even with the manual workaround, your tool is helpful to me. I will keep using it.

Cool! Thanks!

@ekalinin
Copy link
Owner

ekalinin commented Aug 4, 2015

BTW, just curious, why do you need to create different binaries for different platforms even though the go version is supposed to be platform independent. Is it because you need to distribute the go language run time itself which is platform dependent?

Yes. User would have to first install go if there wasn't a precompiled binary.

@HappyRay
Copy link
Author

HappyRay commented Aug 5, 2015

Thanks for your explanation.

@ekalinin
Copy link
Owner

ekalinin commented Aug 5, 2015

You're wellcome.

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

No branches or pull requests

2 participants