Skip to content

New PR for --print option without printing --actual results #24

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

Merged
merged 6 commits into from
Aug 23, 2020

Conversation

schoettl
Copy link
Contributor

@simonmichael for review.

There is now --print support for v1-3

I added tests in tests/print/

Specifics:

  • Comments before the first test in v2/v3 are currently not printed because of the shared input feature which is not yet parsed.
  • Missing newline at EOF will not be preserved.
  • Most tests in tests/ when printed, are not identical because
    • redundant/empty results
    • >=1 instead of >= 1
    • comments before first test
    • shared input
    • no newline at EOF
    • no tests at all, just comments
    • no input/output marker <<</>>>

After review, I can squash the commits to one.

@schoettl
Copy link
Contributor Author

What's the problem with the tests? I use shelltest in my shelltest test cases, how can I fix that?

@simonmichael
Copy link
Owner

simonmichael commented Aug 22, 2020

We run the tests with -w NEWSHELLTEST to make sure we test with the newly built shelltest, not an old one in $PATH. This replaces the first word in each test command with NEWSHELLTEST, unless there is an extra space preceding the command. So test commands which don't begin with shelltest, like:

$$$ false
>>>= 1

should have an extra space:

$$$  false
>>>= 1

@simonmichael
Copy link
Owner

Great @schoettl. Please go ahead and combine these into a single commit, I think it'll be easier for me in this case.

@@ -5,7 +5,6 @@ cat
foo
>>>
foo
>>>2
>>>= 0
Copy link
Owner

Choose a reason for hiding this comment

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

The test no longer matches its description. Why remove the >>>2 ?

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 thought, it doesn't matter to remove the line. But you're right, it is less explicit. I removed the line, to have one more example file for shelltests of --print

$$$ false
>>>= 1

# no comment at begin of file because they are currently not parsed because of shared input
Copy link
Owner

Choose a reason for hiding this comment

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

We should mention this limitation in docs. Where should we document --print ? In the CLI help and readme ?

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'd document it in the CLI help and (not in this commit) in the readme. Because I think it's easier to write the doc when the bigger feature is ready (--actual-results)

Copy link
Owner

Choose a reason for hiding this comment

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

It's normally better to commit the doc along with the new feature being committed. We might forget, or there might be a delay in the next feature. At least, let's add the option to the --help output in README.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How about this:

At least it's up to date then and don't have to be fixed manually.

Copy link
Owner

Choose a reason for hiding this comment

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

Good, thanks for updating that.

-- running tests

testFileParseToHUnitTest :: Args -> Either ParseError [ShellTest] -> Test.HUnit.Test
testFileParseToHUnitTest args (Right ts) = TestList $ map (shellTestToHUnitTest args) ts
testFileParseToHUnitTest args (Right ts) = TestList $ map (\t -> testname t ~: prepareShellTest args t) ts
testFileParseToHUnitTest _ (Left e) = ("parse error in " ++ (sourceName $ errorPos e)) ~: (assertFailure :: (String -> IO ())) $ show e

Copy link
Owner

Choose a reason for hiding this comment

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

This feels non-ideal, but it works. I don't see how exactly the types work - how does assertString become an IO action in the Nothing case ?

Perhaps we could describe it a little more clearly:
Convert this test to an IO action that either runs the test or prints it to stdout, depending on the arguments.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@schoettl
Copy link
Contributor Author

@simonmichael Should we add this section already to the readme?

https://github.com/schoettl/shelltestrunner/tree/print#printing-tests

I plan to add the print results feature soon.

@simonmichael
Copy link
Owner

Should we add this section already to the readme?

Sounds great! But please remove the mentions of future work, there's no need to include those in this PR.

@simonmichael
Copy link
Owner

Looks good! Thanks a lot!

@simonmichael simonmichael merged commit 77684ea into simonmichael:master Aug 23, 2020
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.

2 participants