Skip to content
This repository has been archived by the owner on Apr 1, 2022. It is now read-only.

Integration testing: prerequisites #119

Merged
merged 13 commits into from
Aug 25, 2020
Merged

Integration testing: prerequisites #119

merged 13 commits into from
Aug 25, 2020

Conversation

cnr
Copy link
Contributor

@cnr cnr commented Aug 24, 2020

For integration testing, we want to use a different interpreter of the Exec effect. As currently written, discover functions use runStrategy to internally interpret the Exec effect, which prevents us from doing so.

Instead, these changes force the Has Exec/Has ReadFS constraints upward, through the discover, so we can interpret Exec with a different interpreter in our tests.


This also fixes a few issues discovered while building integration tests:

  • rebar3tree would treat dependencies as top-level projects
  • the setup.py parser would horribly break if you even looked at it the wrong way (didn't allow double-quotes, was whitespace-sensitive, didn't allow trailing commas in the dependency list)

@cnr cnr requested review from skilly-lily and zlav August 24, 2020 18:38
else Right stdout
(_, Always) -> Right stdout

(ExitSuccess, _) -> Right stdout
Copy link
Contributor Author

Choose a reason for hiding this comment

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

a lot of unrelated formatting changes in this commit; continuing to do formatting with ormolu piecemeal as I edit files

Nothing -> pure WalkContinue
Just _ -> do
runSimpleStrategy "erlang-rebar3tree" ErlangGroup $ analyze dir
pure WalkSkipAll
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the fix for the rebar3tree issue

Copy link
Member

Choose a reason for hiding this comment

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

Why does this fix the issue? Shouldn't we continue walking to find other rebar.config files?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Specifically, the issue is that dependencies are downloaded into a subdirectory, and those dependencies also contain rebar.configs, e.g., (.rebar/deps isn't accurate here; I forget what the directories are actually called)

myproject/rebar.config
myproject/.rebar/deps/packageA/rebar.config
myproject/.rebar/deps/packageB/rebar.config

..so we end up treating those as direct dependencies.

Worse though, anytime rebar3 tree is called on one of those dependencies, it then downloads another level of dependencies under it, which also contain rebar.configs:

myproject/rebar.config
myproject/.rebar/deps/packageA/rebar.config
myproject/.rebar/deps/packageA/.rebar/deps/packageC/rebar.config
myproject/.rebar/deps/packageB/rebar.config
myproject/.rebar/deps/packageB/.rebar/deps/packageD/rebar.config

and this expands an additional level each time we run analysis


I don't know if the correct option is to ignore rebar.config in subdirectories, or just to blacklist the .rebar/deps (or whatever it's actually called)

Copy link
Member

Choose a reason for hiding this comment

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

Ah, this makes sense. I like your change for now and we can revert or modify in the future. Thanks for the very detailed response.

prefix = skipManyTill anySingle (string "install_requires=[")
entries = between quote quote requirementParser `sepBy` char ','
end = char ']'
prefix = skipManyTill anySingle (symbol "install_requires") *> symbol "=" *> symbol "["
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These are the setup.py parser fixes (I didn't know about symbol/lexemes when I first wrote this)

Copy link
Member

Choose a reason for hiding this comment

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

Do you have an example of what this fixes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  • whitespace between things, e.g., install_requires = \n[ 'foo']
  • trailing commas install_requires=['foo',]
  • double-quotes used instead of single-quotes install_requires=["foo"]

@@ -70,15 +68,15 @@ runStrategy name strategyGroup act = forkTask $ do
let (bodies, ()) = resultValue result
in traverse_ (output . toProjectClosure strategyGroup name) bodies -- TODO: warnings

type TaskC m = ExecIOC (ReadFSIOC (DiagnosticsC m))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Rather than using ExecIOC and ReadFSIOC as part of running the task, we send the constraints upward (see the below additions to HasDiscover)

Copy link
Member

@zlav zlav left a comment

Choose a reason for hiding this comment

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

Looks good. I'm surprised that Github didn't pick up that all the maven changes are mostly formatting.

Nothing -> pure WalkContinue
Just _ -> do
runSimpleStrategy "erlang-rebar3tree" ErlangGroup $ analyze dir
pure WalkSkipAll
Copy link
Member

Choose a reason for hiding this comment

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

Why does this fix the issue? Shouldn't we continue walking to find other rebar.config files?

prefix = skipManyTill anySingle (string "install_requires=[")
entries = between quote quote requirementParser `sepBy` char ','
end = char ']'
prefix = skipManyTill anySingle (symbol "install_requires") *> symbol "=" *> symbol "["
Copy link
Member

Choose a reason for hiding this comment

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

Do you have an example of what this fixes?

@cnr cnr merged commit a9e2d08 into master Aug 25, 2020
@cnr cnr deleted the integration branch August 25, 2020 19:55
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants