-
Notifications
You must be signed in to change notification settings - Fork 585
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
WIP fix for shell script executable bit and scaffolding for template tests #1990
Conversation
GAH! We can't actually set the executable bit because of a few outstanding templating/coreclr bugs: dotnet/templating#1547 However we should still add this because a) it'll be fixed at some point, and b) even if it fails it leaves a helpful error message:
|
@baronfel I don't think we can expect them to change the behavior again, the flag just was used incorrectly all the years - I agree that using it like this is not portable at all. Therefore we should probably change to |
that's fair 👍 |
hard to test the
|
Ok, I've added a test for both the tool and project variants. It would be easy to write more. The hard part will be interacting with the tests because now we have to answer 'yes' for each test of the template. For this reason I've marked them pending but I think we should use them when working on the template locally for sure, at least until the input question is solved. |
We can either try to set all options beforehand via command line or just redirect and write standard input |
Apparently there is |
@@ -1,11 +1,75 @@ | |||
module Fake.Dotnet.Cli.IntegrationTests.TemplateTests | |||
module Fake.DotNet.Cli.IntegrationTests.TemplateTests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please also rename the folder in git, otherwise there will be problems (which is a bit unfortunate to do on windows as you have to temporarily rename to something else)
Ok, I did it via redirecting stdin |
x.WithWorkingDirectory(dir) | ||
.WithFileName(fullScriptPath) | ||
.WithArguments "--help" ) (System.TimeSpan.FromSeconds 60.) | ||
|> shouldSucceed "should invoke the script file" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer a test which actually checks if ./fake build
works (ie all dependencies still work)
Also can we add a failing test (ie that the scripts correctly return nonzero exit-codes on failure). For example by executing ./fake.sh run nonexisting.fsx
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can do
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a test around ./fake.sh build -t All
and ./fake.sh build -t Nonexistent
) | ||
|
||
proc.Start () |> ignore | ||
do! Async.Sleep 2000 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really need that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I was guessing at how long to wait after invoking the template gen, so that the prompt would be active at the point that I sent the Y character.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you try --allow-scripts yes
(not the most important - but I guess it would not introduce a potential race condition)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I'll give that a try when I add the new tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
worked like a charm.
Thanks a lot for taking care of this! Just two more things I noticed. |
Alright, if this is green I think we're in a better place. |
Is there anything else here I missed that you'd like me to cover? |
Only the one comment, but otherwise looks good |
I'm sorry, which comment do you mean? I thought I just needed to look into |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I forgot to actually submit the review, sorry ;)
Directory.ensure tempDir | ||
runTemplate tempDir Project | ||
let result = invokeScript tempDir scriptFile "build -t Nonexistent" | ||
Expect.isFalse (result.OK && missingTarget "Nonexistent" result) "Should fail to build a target that doesn't exist" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think because result.OK is false missingTarget will not be executed.
What we want is probably 'isTrue(not OK && missingTarget)'?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah you are of course correct. I updated the test checks to be more clear about the two conditions.
5b611ad
to
e02f56c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh we do not actually run the new tests in the build process, do we? |
ah yeah. I'm looking at how to place them post-dotnet-pack right now. |
You can also integrate it into the |
Yeah but I'm relying on the pack task having packaged the nuget package, so I can just install it. That seems harder to orchestrate than just running the template tests sometime after packaging. What do you think? |
Ah yeah whatever you think is easier :) |
Ok, I think I got them. The template tests are a little fragile (meaning towards future changes) because they point to the nuget directory precisely, but they do actually get invoked now. |
Thanks a lot for taking care of this thing! |
dotnet/templating#1547 has been fixed by dotnet/templating#1555, so I suspect it'll be in the next .Net Core bugfix release. But since version 2.1.300 was released with the bug in it, it'll be a while before it's safe to use the |
No description provided.