Skip to content

Commit

Permalink
Properly link filename compatibility checks into cabal check (#7479)
Browse files Browse the repository at this point in the history
* Properly link filename compatibility checks into `cabal check`

* Improve consistency and clarity of Check error messages
  • Loading branch information
ag-eitilt authored Aug 15, 2021
1 parent aff39d0 commit 0b06a13
Show file tree
Hide file tree
Showing 9 changed files with 93 additions and 100 deletions.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
'cpp-options': -traditional is not portable C-preprocessor flag
'cpp-options: -traditional' is not a portable C-preprocessor flag.
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,12 @@ tested-with:
|| ==8.8.1

extra-source-files:
-- this is fine
files/**/*.md
-- collection of invalid paths
files/**/*.txt/
files/../foo.txt
files/<>/*.txt

source-repository head
type: git
Expand Down Expand Up @@ -69,3 +73,6 @@ library

-- this is the only case catched by Cabal-3.0.2.0
hs-source-dirs: ../../assoc/src

-- globs not allowed in field
c-sources: c/**/*.c
19 changes: 9 additions & 10 deletions Cabal-tests/tests/ParserTests/regressions/denormalised-paths.check
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
The 'subdir' field of a source-repository is not a good relative path: "trailing same directory segment: ."
The paths 'files/<>/*.txt', 'c/**/*.c', 'C:foo/bar', '||s' are invalid on Windows, which would cause portability problems for this package. Windows file names cannot contain any of the characters ":*?<>|" and there a few reserved names including "aux", "nul", "con", "prn", "com1-9", "lpt1-9" and "clock$".
'hs-source-dirs: ../../assoc/src' is a relative path outside of the source tree. This will not work when generating a tarball with 'sdist'.
'extra-source-files: files/**/*.txt/' is not good relative path: trailing slash
'extra-source-files: files/../foo.txt' is not good relative path: parent directory segment: ..
'license-file: LICENSE2/' is not good relative path: trailing slash
'license-file: .' is not good relative path: trailing dot segment
'hs-source-dirs: src/.' is not good relative path: trailing same directory segment: .
'hs-source-dirs: src/../src' is not good relative path: parent directory segment: ..
'hs-source-dirs: src/../../assoc/src' is not good relative path: parent directory segment: ..
'hs-source-dirs: C:foo/bar' is not good relative path: reserved character ':'
'hs-source-dirs: ||s' is not good relative path: reserved character '|'
'hs-source-dirs: ../../assoc/src' is not good relative path: parent directory segment: ..
'extra-source-files: files/**/*.txt/' is not a good relative path: "trailing slash"
'extra-source-files: files/../foo.txt' is not a good relative path: "parent directory segment: .."
'license-file: LICENSE2/' is not a good relative path: "trailing slash"
'license-file: .' is not a good relative path: "trailing dot segment"
'hs-source-dirs: src/.' is not a good relative path: "trailing same directory segment: ."
'hs-source-dirs: src/../src' is not a good relative path: "parent directory segment: .."
'hs-source-dirs: src/../../assoc/src' is not a good relative path: "parent directory segment: .."
'hs-source-dirs: ../../assoc/src' is not a good relative path: "parent directory segment: .."
Original file line number Diff line number Diff line change
@@ -1 +1 @@
The package uses RebindableSyntax with OverloadedStrings or OverloadedLists in default-extensions, and also Paths_ autogen module. That configuration is known to cause compile failures with Cabal < 2.2. To use these default-extensions with Paths_ autogen module specify at least 'cabal-version: 2.2'.
Packages using RebindableSyntax with OverloadedStrings or OverloadedLists in default-extensions, in conjunction with the autogenerated module Paths_*, are known to cause compile failures with Cabal < 2.2. To use these default-extensions with a Paths_* autogen module, specify at least 'cabal-version: 2.2'.
144 changes: 62 additions & 82 deletions Cabal/src/Distribution/PackageDescription/Check.hs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ On executable 'Exe' an 'autogen-module' is not on 'other-modules'
On test suite 'Test' an 'autogen-module' is not on 'other-modules'
On benchmark 'Bench' an 'autogen-module' is not on 'other-modules'
Packages using 'cabal-version: 2.0' and the autogenerated module Paths_* must include it also on the 'autogen-modules' field besides 'exposed-modules' and 'other-modules'. This specifies that the module does not come with the package and is generated on setup. Modules built with a custom Setup.hs script also go here to ensure that commands like sdist don't fail.
The filename ./my.cabal does not match package name (expected: AutogenModules.cabal)
The filename './my.cabal' does not match package name (expected: 'AutogenModules.cabal')
Note: the public hackage server would reject this package.
Building source dist for AutogenModules-0.1...
cabal: Error: Could not find module: MyLibHelperModule with any suffix: ["gc","chs","hsc","x","y","ly","cpphs","hs","lhs","hsig","lhsig"]. If the module is autogenerated it should be added to 'autogen-modules'.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ On executable 'Exe' an 'autogen-module' is not on 'other-modules'
On test suite 'Test' an 'autogen-module' is not on 'other-modules'
On benchmark 'Bench' an 'autogen-module' is not on 'other-modules'
Packages using 'cabal-version: 2.0' and the autogenerated module Paths_* must include it also on the 'autogen-modules' field besides 'exposed-modules' and 'other-modules'. This specifies that the module does not come with the package and is generated on setup. Modules built with a custom Setup.hs script also go here to ensure that commands like sdist don't fail.
The filename ./my.cabal does not match package name (expected: AutogenModules.cabal)
The filename './my.cabal' does not match package name (expected: 'AutogenModules.cabal')
Note: the public hackage server would reject this package.
Building source dist for AutogenModules-0.1...
setup: Error: Could not find module: MyLibHelperModule with any suffix: ["gc","chs","hsc","x","y","ly","cpphs","hs","lhs","hsig","lhsig"]. If the module is autogenerated it should be added to 'autogen-modules'.
11 changes: 11 additions & 0 deletions changelog.d/path-validation
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
synopsis: Fix bugs in filename validation
packages: Cabal
prs: #7429 #7479
issues: #7426

description: {

- Relative paths starting with single-character directories are now properly allowed
- `cabal check` rejects paths which are invalid on Windows or in tarballs

}
4 changes: 0 additions & 4 deletions changelog.d/rel-path-check

This file was deleted.

0 comments on commit 0b06a13

Please sign in to comment.