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

Fix order of runtime profiling args for tests (and benchmarks?) #2399

Closed
sjakobi opened this issue Jul 21, 2016 · 6 comments
Closed

Fix order of runtime profiling args for tests (and benchmarks?) #2399

sjakobi opened this issue Jul 21, 2016 · 6 comments

Comments

@sjakobi
Copy link
Member

sjakobi commented Jul 21, 2016

This behaves as if only +RTS -p was passed, when actually the manually specified -P should override the -p.

~/t/profile-repro $ stack --profile test :profile-repro-test --test-arguments "+RTS -P"
profile-repro-0.1.0.0: test (suite: profile-repro-test, args: +RTS -P +RTS -p -RTS)

I didn't check any benchmarks but I'd suspect that the behaviour would be the same.

@mgsloan
Copy link
Contributor

mgsloan commented Mar 19, 2017

I've flipped it around so that the extra opts get put at the beginning so they can be overridden.

issue2399-0.1.0.0: test (suite: issue2399-test, args: +RTS -p -RTS +RTS -P)

Should fix it, right?

@mgsloan mgsloan closed this as completed Mar 19, 2017
@sjakobi
Copy link
Member Author

sjakobi commented Mar 19, 2017

I don't understand why but I can't reproduce the fix?! 😕

~/t/2399repro $ stack --profile test --test-arguments "+RTS -P"
Warning: File listed in 2399repro.cabal file does not exist: README.md
2399repro-0.1.0.0: test (suite: 2399repro-test, args: +RTS -P +RTS -p -RTS)
~/t/2399repro $ stack --version
Version 1.4.1, Git revision ce6560571e79562cb7d3ccc0a251550926a13884 (dirty) (4688 commits) x86_64 hpack-0.17.0

(That's the current HEAD)

@mgsloan
Copy link
Contributor

mgsloan commented Mar 22, 2017

Strange, works for me! Longshot, but maybe a stack clean?

@sjakobi
Copy link
Member Author

sjakobi commented Mar 22, 2017

Strange, works for me! Longshot, but maybe a stack clean?

I'm using a fresh project:

~/tmp $ stack new issue2399
...
~/tmp $ cd issue2399/
~/t/issue2399 $ stack --profile test --test-arguments "+RTS -P"
Warning: File listed in issue2399.cabal file does not exist: README.md
issue2399-0.1.0.0: configure (lib + exe + test)
Configuring issue2399-0.1.0.0...
issue2399-0.1.0.0: build (lib + exe + test)
Preprocessing library issue2399-0.1.0.0...
[1 of 1] Compiling Lib              ( src/Lib.hs, .stack-work/dist/x86_64-linux/Cabal-1.24.2.0/build/Lib.o )
[1 of 1] Compiling Lib              ( src/Lib.hs, .stack-work/dist/x86_64-linux/Cabal-1.24.2.0/build/Lib.p_o )
Preprocessing executable 'issue2399-exe' for issue2399-0.1.0.0...
[1 of 1] Compiling Main             ( app/Main.hs, .stack-work/dist/x86_64-linux/Cabal-1.24.2.0/build/issue2399-exe/issue2399-exe-tmp/Main.p_o )
Linking .stack-work/dist/x86_64-linux/Cabal-1.24.2.0/build/issue2399-exe/issue2399-exe ...
Preprocessing test suite 'issue2399-test' for issue2399-0.1.0.0...
[1 of 1] Compiling Main             ( test/Spec.hs, .stack-work/dist/x86_64-linux/Cabal-1.24.2.0/build/issue2399-test/issue2399-test-tmp/Main.p_o )
Linking .stack-work/dist/x86_64-linux/Cabal-1.24.2.0/build/issue2399-test/issue2399-test ...
Warning: File listed in issue2399.cabal file does not exist: README.md
issue2399-0.1.0.0: copy/register
Installing library in
/home/simon/tmp/issue2399/.stack-work/install/x86_64-linux/lts-8.5/8.0.2/lib/x86_64-linux-ghc-8.0.2/issue2399-0.1.0.0-I4tF5RjauY1BzuYYBoMrW6
Installing executable(s) in
/home/simon/tmp/issue2399/.stack-work/install/x86_64-linux/lts-8.5/8.0.2/bin
Registering issue2399-0.1.0.0...
issue2399-0.1.0.0: test (suite: issue2399-test, args: +RTS -P +RTS -p -RTS)
             
Progress: 1/2Test suite not yet implemented
             
Completed 2 action(s).
~/t/issue2399 $ stack --version
Version 1.4.1, Git revision 86e7ae2bc60ccc2906fde4825be794a80f948a7e (dirty) (4714 commits) x86_64 hpack-0.17.0

@mgsloan
Copy link
Contributor

mgsloan commented Mar 22, 2017

Figured it out! The options before build are parsed as one BuildOptsMonoid, and the ones after are parsed as another. The transformation of adding the extra arguments happens while parsing the BuildOptsMonoid. This means we get the following strange behavior:

$ stack --profile test --profile --test-arguments "+RTS -P"
...
issue2399-0.1.0.0: test (suite: issue2399-test, args: +RTS -p -RTS +RTS -P +RTS -p -RTS)

Before I couldn't reproduce the issue because I was passing --profile after build.

I've fixed it by applying this transformation while converting BuildOptsMonoid to BuildOpts, rather than applying it while parsing BuildOptsMonoid.

@sjakobi
Copy link
Member Author

sjakobi commented Mar 22, 2017

Nice sleuthing! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants