nim-lang / Nim

Nim is a statically typed compiled systems programming language. It combines successful concepts from mature languages like Python, Ada and Modula. Its design focuses on efficiency, expressiveness, and elegance (in that order of priority).
https://nim-lang.org
Other
16.55k stars 1.47k forks source link

nimscript.findExe should find .cmd files #16661

Open disruptek opened 3 years ago

disruptek commented 3 years ago

Per title, I want the following in my skiplists.nimble:

requires "https://github.com/disruptek/testes >= 0.7.1 & < 1.0.0"

task test, "run unit tests":
  exec findExe"testes"

but instead I need to use

requires "https://github.com/disruptek/testes >= 0.7.1 & < 1.0.0"

task test, "run unit tests":
  when defined(windows):
    exec "testes.cmd"
  else:
    exec findExe"testes"

because it seems that on Windows (such as found in GitHub Actions CI) Nimble doesn't install the testes binary in such a way that findExe can invoke it.

Perhaps relevant bits from https://github.com/disruptek/testes .nimble:

bin = @["testes"]      # build the binary for basic test running
installExt = @["nim"]  # we need to install testes.nim also
skipDirs = @["tests"]  # so stupid...  who doesn't want tests?

Annoyingly, nimble check complains that I need the skipDirs statement even when I include this.

dom96 commented 3 years ago

Not much we can do about this in Nimble AFAIK.

I think this is actually a Nim bug. The findExe in Nimscript should find .cmd, the os.findExe proc has a parameter to influence this: https://nim-lang.org/docs/os.html#findExe%2Cstring%2Cbool%2CopenArray%5Bstring%5D. I'll move it to the Nim repo.

Annoyingly, nimble check complains that I need the skipDirs statement even when I include this.

Have you tried installNim = ["testes.nim"]?

disruptek commented 3 years ago

This is what I get when I add installNim = ["testes.nim"] to my testes.nimble:

     Error: Could not validate package:
        ... Could not read package info file in /home/adavidoff/git/testes/testes.nimble;
        ...   Reading as ini file failed with: 
        ...     Invalid section: .
        ...   Evaluating as NimScript file failed with: 
        ...     /home/adavidoff/git/testes/testes.nimble(14, 1) Error: undeclared identifier: 'installNim'
        ... printPkgInfo() failed.
nimble v0.12.0 compiled at 2021-01-10 00:52:13
git hash: couldn't determine git hash

Despite the error message, this is the nightly release build of Nimble from the following nightly release:

Nim Compiler Version 1.5.1 [Linux: amd64]
Compiled at 2021-01-10
Copyright (c) 2006-2021 by Andreas Rumpf

git hash: dbff2cd938b326279de0f3f97b2dd8c54a90468a
active boot switches: -d:release
dom96 commented 3 years ago

Sorry, I meant installFiles.

disruptek commented 3 years ago
     Error: Package 'testes' has an incorrect structure. It should contain a single directory hierarchy for source files, named 'testespkg', but file 'testicles.nim' is in a directory named 'tests' instead. This will be an error in the future.
      Hint: If 'tests' contains source files for building 'testes', rename it to 'testespkg'. Otherwise, prevent its installation by adding `skipDirs = @["tests"]` to the .nimble file.
   Failure: Validation failed
timotheecour commented 3 years ago

The findExe in Nimscript should find .cmd, the os.findExe proc has a parameter to influence this

it should indeed find .cmd by default given these definitions:

proc findExe(exe: string; followSymlinks: bool = true; extensions: openArray[string] = ExeExts): string
ExeExts = ["exe", "cmd", "bat"]