Added tests on compiler's version detection (#10931)
* Split get_compiler_version into two functions: get_compiler_version_output runs the compiler with the relevant option to print the version; extract_version_from_output determines the version by examining this output. This makes it easier to test the customized version detection for each compiler. Users can customize this by overriding the following: * version_argument: this is the argument that tells the compiler to print its version. It assumes that the compiler will report its version if invoked with a single option (like "--version") * version_regex: the regular expression used to extract the version from the compiler argument. This assumes that a regular expression is sufficient to extract the version, and that the version can be extracted from a single capture group (Spack uses the first capture group) * default_version: allows you to completely override all version detection logic * get_compiler_version_output: if getting the compiler to report its version is more complex than invoking it with a single arg * extract_version_from_output: if it is difficult to define a regex that can be used to extract the version from the output * Added tests for version detection of most compilers * Removed redundant code from xl_r compiler class (by inheriting from xl compiler definition)
Showing
- lib/spack/spack/compiler.py 28 additions, 19 deletionslib/spack/spack/compiler.py
- lib/spack/spack/compilers/arm.py 14 additions, 18 deletionslib/spack/spack/compilers/arm.py
- lib/spack/spack/compilers/cce.py 4 additions, 5 deletionslib/spack/spack/compilers/cce.py
- lib/spack/spack/compilers/clang.py 8 additions, 15 deletionslib/spack/spack/compilers/clang.py
- lib/spack/spack/compilers/gcc.py 15 additions, 7 deletionslib/spack/spack/compilers/gcc.py
- lib/spack/spack/compilers/intel.py 4 additions, 18 deletionslib/spack/spack/compilers/intel.py
- lib/spack/spack/compilers/nag.py 5 additions, 13 deletionslib/spack/spack/compilers/nag.py
- lib/spack/spack/compilers/pgi.py 5 additions, 22 deletionslib/spack/spack/compilers/pgi.py
- lib/spack/spack/compilers/xl.py 25 additions, 52 deletionslib/spack/spack/compilers/xl.py
- lib/spack/spack/compilers/xl_r.py 2 additions, 87 deletionslib/spack/spack/compilers/xl_r.py
- lib/spack/spack/test/cmd/test_compiler_cmd.py 1 addition, 1 deletionlib/spack/spack/test/cmd/test_compiler_cmd.py
- lib/spack/spack/test/compilers.py 89 additions, 1 deletionlib/spack/spack/test/compilers.py
Loading
Please register or sign in to comment