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

Wrong dependency order after updating to the latest Fake causes tests to be run before built #1515

Closed
ovatsus opened this issue Apr 10, 2017 · 33 comments

Comments

@ovatsus
Copy link

ovatsus commented Apr 10, 2017

Description

Before:

image

After
image

Repro steps

@forki
Copy link
Member

forki commented Apr 11, 2017

@BlythMeister can you please take a quick look at this? I assume it's related to your recent changes.

@BlythMeister
Copy link
Contributor

BlythMeister commented Apr 11, 2017

Yeah sure, can you please provide your dependency trees from the fsx file.

Just looking at the cut down tree, it looks like your tests are not dependent on the build. If this is the case, it previously worked a bit by luck.
Stating the test is dependent on the build will force it to only run when the build has finished.

@forki
Copy link
Member

forki commented Apr 11, 2017

Should be at the bottom of https://github.com/fsharp/FSharp.Data/blob/master/build.fsx

@BlythMeister
Copy link
Contributor

Yeah just realised that.
From what i can see, there is no dependency between build tests, build and run tests.
Therefore that dependency structure states these things can run in any order.

If you have a dependency between targets you should state that in the dependencies for the build.

@forki
Copy link
Member

forki commented Apr 11, 2017

I think the problem is at https://github.com/fsharp/FSharp.Data/blob/master/build.fsx#L126

@ovatsus you define that the targets should run before the runtest target. That condition is fulfilled. I think want you want is to reverse the arrow.

@forki
Copy link
Member

forki commented Apr 11, 2017

@BlythMeister yes it seems to be unspecified in the script. I will send a pull request to fsharp.data. But it's still a bit unfortunate that we changed behavior here.

@BlythMeister
Copy link
Contributor

BlythMeister commented Apr 11, 2017

Agreed, it's a shame the behaviour changed. But arguably it's now correct in that it obeys the dependencies you set in your script rather than being down to chance/ordering.

If you don't state that b is dependent on a, then that states they can run in any order.

I had assumed in making this change that dependencies were specified by users. Maybe this was a bad assumption.

@forki
Copy link
Member

forki commented Apr 11, 2017

It obeyed it before as well.

@BlythMeister
Copy link
Contributor

True, but a lot of it came down to the order dependency was specified rather than making targets actually dependant.

I can try and make those orders be the same without having to make the change?
Would be an easy test case to add.

@forki
Copy link
Member

forki commented Apr 11, 2017

I just looked at @ovatsus's project
It really relies on dependency specification order. Everywhere. We broke such assumptions.

@forki forki reopened this Apr 11, 2017
@forki
Copy link
Member

forki commented Apr 11, 2017

@BlythMeister I think we should restore that behaviour

@BlythMeister
Copy link
Contributor

Ok, I'll have a look into why that situation does not work.
I can knock a test up and repo it.

@forki
Copy link
Member

forki commented Apr 11, 2017

thanks!

@BlythMeister
Copy link
Contributor

This is the commit that broke it i think... e87f690

I didn't know that target specification ordering impacted target ordering.

@forki
Copy link
Member

forki commented Apr 11, 2017

@BlythMeister it was never intended to do so, but since important project rely on it...

@BlythMeister
Copy link
Contributor

Ahh as i expected...it worked by chance 😋

I will try and restore it.

@BlythMeister
Copy link
Contributor

@forki I've had a look at this, and it's because it's running the targets as early as possible now.

Since those "RunTests_" are not dependant on anything, they can run really early.

Previously targets ran in the order they were visited, hence why they would run later in the build.

The way the current solution works does take into account the ordering in the file to state the order of execution, but "RunTests_" is defined ahead of all the other targets.

The way i see it we have 2 choices.

  1. accept the behaviour & users add missing dependencies
  2. Revert the change to we go back to pure visit order and running targets as late as possible.

@forki
Copy link
Member

forki commented Apr 11, 2017

I'm tending towards 2

@ovatsus
Copy link
Author

ovatsus commented Apr 11, 2017

The reason I did not specify test to depend on build, was that I wanted to be able to do 'build RunTests' without forcing to build again, that's very useful when manually editing some tests and just reruning. There are probably a lot of projects with similar issues as the FSharp.Data build script was then used as an example for Deedle and the for project scaffolding, so it would be great if we could get the old behaviour. Or if it's still possible to achieve what I had in a different way, I'm happy to change the scrip as well

@BlythMeister
Copy link
Contributor

I feared you would say that...it feels wrong to me.

Things should run as early as they can.

Maybe we could have a flag set to retain old run function?

A "RunInVisitOrder" environment variable?

@forki
Copy link
Member

forki commented Apr 11, 2017 via email

@forki
Copy link
Member

forki commented Apr 11, 2017

@ovatsus there is a run-single-target command line parameter for FAKE. But you are probably not the only one

@BlythMeister
Copy link
Contributor

@forki running dependencies early means it fails faster.

I am happy to revert the logic if you think that is best.

@forki
Copy link
Member

forki commented Apr 11, 2017

yes we see that here. it fails pretty fast ;-)

@BlythMeister
Copy link
Contributor

haha :)

@ovatsus i don't understand the scenario where you would want to run something you have yet to build

@forki
Copy link
Member

forki commented Apr 11, 2017

@BlythMeister it's already built. he just wants to rerun tests

@BlythMeister
Copy link
Contributor

@forki would you accept a configuration switch to use old logic?

that way, if someone has issues, they can revert to the old logic?

@forki
Copy link
Member

forki commented Apr 11, 2017

tbh. I don't see why that's needed. We usually strive to be backwards compatible and don't want to break existing build scripts. usualy these scripts are not touched for very long time.
When we break such things we usally revert.

@BlythMeister
Copy link
Contributor

ok, i'll get a revert in so single thread just runs in the order they are visited rather than as early as possible.

@forki
Copy link
Member

forki commented Apr 11, 2017

yes that sounds good.

@BlythMeister
Copy link
Contributor

revert raised, should probably be tested on your PR to f# data?

@BlythMeister
Copy link
Contributor

i guess on a parallel build, it makes sense to run things as early as possible, but on a non parallel, it does not.

I think this code could be simplified to reflect that...

@BlythMeister
Copy link
Contributor

@forki suggest this should be closed now?

@forki forki closed this as completed Apr 11, 2017
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

3 participants