Fix tests to pass with the latest Nim

There are two issues fixed:

 - With the latest Nim version sometimes the files
   `<package_name>_<some_number>.nims`' generated on `nim install`
   contain warning for unused imports which causes the test
   "can validate package structure (#144)" to fail, because it was
   searching for the word "warning" in the output.

 - On Windows Subsystem for Linux, when an import starts sometimes with
   a lowercase, and sometimes with an uppercase, for example
   `import uri` and `import Uri`, this causes Nim to create and compile
   both `stdlib_uri.nim.c` and `stdlib_Uri.nim.c` and to fail on the
   linking step, because of the same symbols are being redefined.

Also the Travis CI build script is changed to test against currently the
latest working Nim version 212ae2f.

Related to #680
This commit is contained in:
Ivan Bobev 2019-08-11 15:48:14 +03:00 committed by Dominik Picheta
commit df11a6f6cf
3 changed files with 24 additions and 14 deletions

View file

@ -7,7 +7,8 @@ language: c
env:
- BRANCH=0.19.6
- BRANCH=0.20.2
- BRANCH=#44aadd50cfa647a759610a15967960632bf597ce
# This is the latest working Nim version against which Nimble is being tested
- BRANCH=#212ae2f1257628bd5d1760593ce0a1bad768831a
cache:
directories:

View file

@ -1,6 +1,6 @@
# Copyright (C) Dominik Picheta. All rights reserved.
# BSD License. Look at license.txt for more info.
import parsecfg, streams, strutils, os, tables, Uri
import parsecfg, streams, strutils, os, tables, uri
import version, cli

View file

@ -72,6 +72,12 @@ proc inLines(lines: seq[string], line: string): bool =
for i in lines:
if line.normalize in i.normalize: return true
proc hasLineStartingWith(lines: seq[string], prefix: string): bool =
for line in lines:
if line.strip(trailing = false).startsWith(prefix):
return true
return false
test "caching of nims and ini detects changes":
cd "caching":
var (output, exitCode) = execNimble("dump")
@ -117,7 +123,7 @@ test "can validate package structure (#144)":
let (output, exitCode) = execNimble(["install", "-y"])
check exitCode == QuitSuccess
let lines = output.strip.processOutput()
check(not inLines(lines, "warning"))
check(not lines.hasLineStartingWith("Warning:"))
# Test that warnings are produced for the incorrectly structured packages.
for package in ["x", "y", "z"]:
@ -128,17 +134,20 @@ test "can validate package structure (#144)":
checkpoint(output)
case package
of "x":
check inLines(lines, "Package 'x' has an incorrect structure. It should" &
check lines.hasLineStartingWith(
"Warning: Package 'x' has an incorrect structure. It should" &
" contain a single directory hierarchy for source files," &
" named 'x', but file 'foobar.nim' is in a directory named" &
" 'incorrect' instead.")
of "y":
check inLines(lines, "Package 'y' has an incorrect structure. It should" &
check lines.hasLineStartingWith(
"Warning: Package 'y' has an incorrect structure. It should" &
" contain a single directory hierarchy for source files," &
" named 'ypkg', but file 'foobar.nim' is in a directory named" &
" 'yWrong' instead.")
of "z":
check inLines(lines, "Package 'z' has an incorrect structure. The top level" &
check lines.hasLineStartingWith(
"Warning: Package 'z' has an incorrect structure. The top level" &
" of the package source directory should contain at most one module," &
" named 'z.nim', but a file named 'incorrect.nim' was found.")
else: