From 747061795393a1f4e8ac7d9f3d297b733a34230b Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Mon, 9 Mar 2020 16:53:26 -0700 Subject: project_tests: Add the option to the test format to mark the language This is needed when mixing D and C code, as it's possible to end up witha combination of linkers and compilres such that C produces pdb files but D does not. --- docs/markdown/Contributing.md | 11 ++++++++++- run_project_tests.py | 10 +++++++++- test cases/d/1 simple/test.json | 2 +- test cases/d/2 static library/test.json | 2 +- test cases/d/3 shared library/test.json | 4 ++-- test cases/d/4 library versions/test.json | 8 ++++---- test cases/d/5 mixed/test.json | 6 +++--- test cases/d/6 unittest/test.json | 2 +- test cases/d/7 multilib/test.json | 6 +++--- 9 files changed, 34 insertions(+), 17 deletions(-) diff --git a/docs/markdown/Contributing.md b/docs/markdown/Contributing.md index 4d52ce1..49b485b 100644 --- a/docs/markdown/Contributing.md +++ b/docs/markdown/Contributing.md @@ -227,6 +227,8 @@ to be installed. Each dict contains the following keys: - `file` - `type` - `platform` (optional) +- `version` (optional) +- `language` (optional) The `file` entry contains the relative path (from the install root) to the actually installed file. @@ -246,8 +248,15 @@ current platform. The following values are currently supported: Except for the `file` and `expr` types, all paths should be provided *without* a suffix. +| Argument | Applies to | Description | +| :---------:|----------------------------|-------------------------------------------------------------------------------| +| `version` | `shared_lib`, `pdb` | Sets the version to look for appropriately per-platform | +| `language` | `pdb` | Determines which compiler/linker determines the existence of this file | + The `shared_lib` and `pdb` types takes an optional additional parameter, `version`, this is us a string in `X.Y.Z` format that will be applied to the library. Each version to be tested must have a single version. The harness will apply this correctly per platform: +`pdb` takes an optional `language` argument. This determines which compiler/linker should generate the pdb file. Because it's possible to mix compilers that do and don't generate pdb files (dmd's optlink doesn't). Currently this is only needed when mixing D and C code. + ```json { "type": "shared_lib", "file": "usr/lib/lib", @@ -256,7 +265,7 @@ The `shared_lib` and `pdb` types takes an optional additional parameter, `versio } ``` -This will be applied appropraitly per platform. On windows this expects `lib.dll` and `lib-1.dll`. on MacOS it expects `liblib.dylib` and `liblib.1.dylib`. On other Unices it expects `liblib.so`, `liblib.so.1`, and `liblib.so.1.2.3`. +This will be applied appropriatly per platform. On windows this expects `lib.dll` and `lib-1.dll`. on MacOS it expects `liblib.dylib` and `liblib.1.dylib`. On other Unices it expects `liblib.so`, `liblib.so.1`, and `liblib.so.1.2.3`. If the `platform` key is present, the installed file entry is only considered if the platform matches. The following values for `platform` are currently supported: diff --git a/run_project_tests.py b/run_project_tests.py index 1ae151b..3b20025 100755 --- a/run_project_tests.py +++ b/run_project_tests.py @@ -96,6 +96,7 @@ class InstalledFile: self.path = raw['file'] self.typ = raw['type'] self.platform = raw.get('platform', None) + self.language = raw.get('language', 'c') # type: str version = raw.get('version', '') # type: str if version: @@ -111,6 +112,13 @@ class InstalledFile: (env.machines.host.is_windows() and compiler in {'pgi', 'dmd', 'ldc'})): canonical_compiler = 'msvc' + has_pdb = False + if self.language in {'c', 'cpp'}: + has_pdb = canonical_compiler == 'msvc' + elif self.language == 'd': + # dmd's optlink does not genearte pdb iles + has_pdb = env.coredata.compilers.host['d'].linker.id in {'link', 'lld-link'} + # Abort if the platform does not match matches = { 'msvc': canonical_compiler == 'msvc', @@ -155,7 +163,7 @@ class InstalledFile: elif self.typ == 'pdb': if self.version: p = p.with_name('{}-{}'.format(p.name, self.version[0])) - return p.with_suffix('.pdb') if canonical_compiler == 'msvc' else None + return p.with_suffix('.pdb') if has_pdb else None elif self.typ == 'implib' or self.typ == 'implibempty': if env.machines.host.is_windows() and canonical_compiler == 'msvc': # only MSVC doesn't generate empty implibs diff --git a/test cases/d/1 simple/test.json b/test cases/d/1 simple/test.json index ca64a36..62f907a 100644 --- a/test cases/d/1 simple/test.json +++ b/test cases/d/1 simple/test.json @@ -1,6 +1,6 @@ { "installed": [ {"type": "exe", "file": "usr/bin/dsimpleapp"}, - {"type": "pdb", "file": "usr/bin/dsimpleapp"} + {"type": "pdb", "file": "usr/bin/dsimpleapp", "language": "d"} ] } diff --git a/test cases/d/2 static library/test.json b/test cases/d/2 static library/test.json index 2296bd7..6abb934 100644 --- a/test cases/d/2 static library/test.json +++ b/test cases/d/2 static library/test.json @@ -1,7 +1,7 @@ { "installed": [ {"type": "exe", "file": "usr/bin/app_s"}, - {"type": "pdb", "file": "usr/bin/app_s"}, + {"type": "pdb", "file": "usr/bin/app_s", "language": "d"}, {"type": "file", "file": "usr/lib/libstuff.a"} ] } diff --git a/test cases/d/3 shared library/test.json b/test cases/d/3 shared library/test.json index c08833d..50eb9cb 100644 --- a/test cases/d/3 shared library/test.json +++ b/test cases/d/3 shared library/test.json @@ -1,9 +1,9 @@ { "installed": [ {"type": "exe", "file": "usr/bin/app_d"}, - {"type": "pdb", "file": "usr/bin/app_d"}, + {"type": "pdb", "file": "usr/bin/app_d", "language": "d"}, {"type": "shared_lib", "platform": "msvc", "file": "usr/bin/stuff"}, - {"type": "pdb", "file": "usr/bin/stuff"}, + {"type": "pdb", "file": "usr/bin/stuff", "language": "d"}, {"type": "shared_lib", "platform": "gcc", "file": "usr/lib/stuff"}, {"type": "file", "platform": "msvc", "file": "usr/lib/stuff.lib"}, {"type": "file", "file": "usr/lib/pkgconfig/test.pc"} diff --git a/test cases/d/4 library versions/test.json b/test cases/d/4 library versions/test.json index 0956dca..23c95dd 100644 --- a/test cases/d/4 library versions/test.json +++ b/test cases/d/4 library versions/test.json @@ -10,13 +10,13 @@ {"type": "shared_lib", "platform": "gcc", "file": "usr/lib/onlysoversion"}, {"type": "shared_lib", "platform": "gcc", "file": "usr/lib/onlysoversion", "version": "5"}, {"type": "shared_lib", "platform": "msvc", "file": "usr/bin/noversion"}, - {"type": "pdb", "file": "usr/bin/noversion"}, + {"type": "pdb", "file": "usr/bin/noversion", "language": "d"}, {"type": "shared_lib", "platform": "msvc", "file": "usr/bin/onlysoversion", "version": "5"}, - {"type": "pdb", "file": "usr/bin/onlysoversion", "version": "5"}, + {"type": "pdb", "file": "usr/bin/onlysoversion", "version": "5", "language": "d"}, {"type": "shared_lib", "platform": "msvc", "file": "usr/bin/onlyversion", "version": "1"}, - {"type": "pdb", "file": "usr/bin/onlyversion", "version": "1"}, + {"type": "pdb", "file": "usr/bin/onlyversion", "version": "1", "language": "d"}, {"type": "shared_lib", "platform": "msvc", "file": "usr/bin/some", "version": "0"}, - {"type": "pdb", "file": "usr/bin/some", "version": "0"}, + {"type": "pdb", "file": "usr/bin/some", "version": "0", "language": "d"}, {"type": "implib", "file": "usr/lib/noversion"}, {"type": "implib", "file": "usr/lib/onlysoversion"}, {"type": "implib", "file": "usr/lib/onlyversion"}, diff --git a/test cases/d/5 mixed/test.json b/test cases/d/5 mixed/test.json index e2c6245..c95d0ca 100644 --- a/test cases/d/5 mixed/test.json +++ b/test cases/d/5 mixed/test.json @@ -1,13 +1,13 @@ { "installed": [ {"type": "exe", "file": "usr/bin/appdc_d"}, - {"type": "pdb", "file": "usr/bin/appdc_d"}, + {"type": "pdb", "file": "usr/bin/appdc_d", "language": "d"}, {"type": "exe", "file": "usr/bin/appdc_s"}, - {"type": "pdb", "file": "usr/bin/appdc_s"}, + {"type": "pdb", "file": "usr/bin/appdc_s", "language": "d"}, {"type": "file", "file": "usr/lib/libstuff.a"}, {"type": "shared_lib", "platform": "gcc", "file": "usr/lib/stuff"}, {"type": "shared_lib", "platform": "msvc", "file": "usr/bin/stuff"}, - {"type": "pdb", "file": "usr/bin/stuff"}, + {"type": "pdb", "file": "usr/bin/stuff", "language": "c"}, {"type": "file", "platform": "msvc", "file": "usr/lib/stuff.lib"} ] } diff --git a/test cases/d/6 unittest/test.json b/test cases/d/6 unittest/test.json index 88e94e9..adc4d75 100644 --- a/test cases/d/6 unittest/test.json +++ b/test cases/d/6 unittest/test.json @@ -1,6 +1,6 @@ { "installed": [ {"type": "exe", "file": "usr/bin/dapp"}, - {"type": "pdb", "file": "usr/bin/dapp"} + {"type": "pdb", "file": "usr/bin/dapp", "language": "d"} ] } diff --git a/test cases/d/7 multilib/test.json b/test cases/d/7 multilib/test.json index a9c5706..5944ae0 100644 --- a/test cases/d/7 multilib/test.json +++ b/test cases/d/7 multilib/test.json @@ -1,7 +1,7 @@ { "installed": [ {"type": "exe", "file": "usr/bin/app_d"}, - {"type": "pdb", "file": "usr/bin/app_d"}, + {"type": "pdb", "file": "usr/bin/app_d", "language": "d"}, {"type": "shared_lib", "platform": "gcc", "file": "usr/lib/say1"}, {"type": "shared_lib", "platform": "gcc", "file": "usr/lib/say1", "version": "0"}, {"type": "shared_lib", "platform": "gcc", "file": "usr/lib/say1", "version": "1.2.3"}, @@ -9,9 +9,9 @@ {"type": "shared_lib", "platform": "gcc", "file": "usr/lib/say2", "version": "1"}, {"type": "shared_lib", "platform": "gcc", "file": "usr/lib/say2", "version": "1.2.4"}, {"type": "shared_lib", "platform": "msvc", "file": "usr/bin/say1", "version": "0"}, - {"type": "pdb", "file": "usr/bin/say1", "version": "0"}, + {"type": "pdb", "file": "usr/bin/say1", "version": "0", "language": "d"}, {"type": "shared_lib", "platform": "msvc", "file": "usr/bin/say2", "version": "1"}, - {"type": "pdb", "file": "usr/bin/say2", "version": "1"}, + {"type": "pdb", "file": "usr/bin/say2", "version": "1", "language": "d"}, {"type": "implib", "file": "usr/lib/say1"}, {"type": "implib", "file": "usr/lib/say2"} ] -- cgit v1.1