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

Feature: Task-level dependencies #482

Closed
mratsim opened this issue Apr 24, 2018 · 9 comments
Closed

Feature: Task-level dependencies #482

mratsim opened this issue Apr 24, 2018 · 9 comments

Comments

@mratsim
Copy link

mratsim commented Apr 24, 2018

I'd like to use Quickcheck for testing but it seems like currently either it's listed as a full dependency and get pulled on user machine, or it's not listed and it cannot be run as a nimble task.

Can we also allow requires at the task level.

@mratsim
Copy link
Author

mratsim commented Apr 24, 2018

Another use case: comparing against reference implementations/libraries. In my case a C++ wrapper that I rewrote in pure Nim.

@dom96 dom96 added the Feature label Apr 24, 2018
@dom96
Copy link
Collaborator

dom96 commented Apr 24, 2018

Perhaps you could run nimble install ... in the task?

@mratsim
Copy link
Author

mratsim commented May 3, 2018

I just tried, that unfortunately didn't work :/

  Executing task test_property_debug in /Users/<username>/Programming/Status/stint/stint.nimble
   Warning: Package 'stint' has an incorrect structure. The top level of the package source directory should contain at most one module, named 'stint.nim', but a file named 'io.nim' was found. This will be an error in the future.
      Hint: If this is the primary source file in the package, rename it to 'stint.nim'. If it's a source file required by the main module, or if it is one of several modules exposed by 'stint', then move it into a 'stint/' subdirectory. If it's a test file or otherwise not required to build thethe package 'stint.nim', prevent its installation by adding `skipFiles = @["io.nim"]` to the .nimble file. See https://github.com/nim-lang/nimble#libraries for more info.
Downloading https://github.com/alehander42/nim-quicktest using git
   Warning: Package 'quicktest' has an incorrect structure. The top level of the package source directory should contain at most one module, named 'quicktest.nim', but a file named 'js_lib.nim' was found. This will be an error in the future.
      Hint: If this is the primary source file in the package, rename it to 'quicktest.nim'. If it's a source file required by the main module, or if it is one of several modules exposed by 'quicktest', then move it into a 'quicktest/' subdirectory. If it's a test file or otherwise not required to build the the package 'quicktest.nim', prevent its installation by adding `skipFiles = @["js_lib.nim"]` to the .nimble file. See https://github.com/nim-lang/nimble#libraries for more info.
  Verifying dependencies for [email protected]
      Info: Dependency on random@#head already satisfied
  Verifying dependencies for random@#head
      Info: Dependency on https://github.com/alehander42/breeze.git@>= 0.0.5 already satisfied
  Verifying dependencies for [email protected]
 Installing [email protected]
    Prompt: [email protected] already exists. Overwrite? [y/N]
    Answer: y
   Success: quicktest installed successfully.
  Verifying dependencies for [email protected]
  Compiling tests/property_based.nim (from package stint) using c backend
Hint: used config file '/Users/<username>/.choosenim/toolchains/nim-#devel/config/nim.cfg' [Conf]
Hint: system [Processing]
Hint: property_based [Processing]
Hint: stint [Processing]
...
Hint: tables [Processing]
Hint: termios [Processing]
property_based.nim(10, 32) Error: cannot open 'quicktest'
       Tip: 4 messages have been suppressed, use --verbose to show them.
     Error: Execution failed with exit code 256
        ... Command: "/Users/<username>/.nimble/bin/nim" c --noNimblePath "--define:mpint_test" "--out:./build/property_based" "--run" "--nimcache:"nimcache""  "tests/property_based.nim"

@dom96
Copy link
Collaborator

dom96 commented Aug 20, 2018

After discussion on IRC I am tempted to implement this instead of #464.

https://irclogs.nim-lang.org/20-08-2018.html#16:05:30

For the Nimgen use case:

before install:
  requires "nimgen"
  exec "nimgen ngen.cfg"

For the test use case:

task test:
  requires "quickcheck"
  exec "nim c -r tests/tester"

Unlike the global requires, a task-level requires will immediately install the specified dependencies when the task is being executed.

Note: If nimble c -r tests/tester is used instead, the compilation will fail since the .nimble file only specifies quickcheck in the test task. This is why the workaround failed for you @mratsim. Nimble needs to allow the c task to be executed directly instead of via exec to solve this :(.

@dom96
Copy link
Collaborator

dom96 commented Aug 27, 2018

Okay, so I need to be able to override the NimScript task template for this. As such I will postpone this until another release.

@genotrance
Copy link
Contributor

Looking at @dom96 earlier comment, specifying a required package for a custom task can only install the package if it isn't already present. It doesn't actually make it seamless to use the package. User has to resort to exec calls to nim or nimble. Nim might even work if the dep is installed globally but nimble won't as seen above. Fixing that is not trivial given the new architecture where nimble spawns nim e instead of embedding the VM.

How about a testRequires option instead that specifies additional packages required when nimble test is called? This will not help custom tasks but at least make it seamless when you have a tests directory with a bunch of test files that nimble can then automatically call as required.

@mratsim
Copy link
Author

mratsim commented Feb 9, 2021

So another failure and lost time that could be avoided with task level dependencies so that test packages don't pollute everything:

image

nim-json-serialization is bringing Chronos because it needs to test and work with it, and then it turns Chronos is bringing BearSSL and a testutils a fuzzing framework. All those things pollute builds and could be avoided if task-level dependencies were supported.

@bung87
Copy link
Contributor

bung87 commented Jun 12, 2021

I've create a nimble fork for temporary solution , https://github.com/bung87/slim

@ire4ever1190
Copy link
Contributor

Implemented in #1035

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

6 participants