diff options
author | Massimiliano Culpo <massimiliano.culpo@gmail.com> | 2020-06-05 14:44:57 +0200 |
---|---|---|
committer | Peter Scheibel <scheibel1@llnl.gov> | 2020-06-11 10:06:32 -0700 |
commit | bbac630aac7a06dd681eb8483a2f89f905f10ed3 (patch) | |
tree | 69fc6300a4ecff5474c1c1c7f6bf672fdf47cd7b | |
parent | b50b930d6a5af82e04dc61788a919e2e2d0b4561 (diff) | |
download | spack-bbac630aac7a06dd681eb8483a2f89f905f10ed3.tar.gz spack-bbac630aac7a06dd681eb8483a2f89f905f10ed3.tar.bz2 spack-bbac630aac7a06dd681eb8483a2f89f905f10ed3.tar.xz spack-bbac630aac7a06dd681eb8483a2f89f905f10ed3.zip |
Reworked tests on compilers to separate version detection
Tests on version detection are now separate from other
tests done on compiler.
-rw-r--r-- | lib/spack/spack/test/compilers/__init__.py | 4 | ||||
-rw-r--r-- | lib/spack/spack/test/compilers/detection.py | 179 | ||||
-rw-r--r-- | lib/spack/spack/test/compilers/flags.py (renamed from lib/spack/spack/test/compilers.py) | 170 |
3 files changed, 183 insertions, 170 deletions
diff --git a/lib/spack/spack/test/compilers/__init__.py b/lib/spack/spack/test/compilers/__init__.py new file mode 100644 index 0000000000..9f87532b85 --- /dev/null +++ b/lib/spack/spack/test/compilers/__init__.py @@ -0,0 +1,4 @@ +# Copyright 2013-2020 Lawrence Livermore National Security, LLC and other +# Spack Project Developers. See the top-level COPYRIGHT file for details. +# +# SPDX-License-Identifier: (Apache-2.0 OR MIT) diff --git a/lib/spack/spack/test/compilers/detection.py b/lib/spack/spack/test/compilers/detection.py new file mode 100644 index 0000000000..26a559443b --- /dev/null +++ b/lib/spack/spack/test/compilers/detection.py @@ -0,0 +1,179 @@ +# Copyright 2013-2020 Lawrence Livermore National Security, LLC and other +# Spack Project Developers. See the top-level COPYRIGHT file for details. +# +# SPDX-License-Identifier: (Apache-2.0 OR MIT) +import pytest + +import spack.compilers.arm +import spack.compilers.cce +import spack.compilers.clang +import spack.compilers.fj +import spack.compilers.gcc +import spack.compilers.intel +import spack.compilers.nag +import spack.compilers.pgi +import spack.compilers.xl +import spack.compilers.xl_r + + +@pytest.mark.parametrize('version_str,expected_version', [ + ('Arm C/C++/Fortran Compiler version 19.0 (build number 73) (based on LLVM 7.0.2)\n' # NOQA + 'Target: aarch64--linux-gnu\n' + 'Thread model: posix\n' + 'InstalledDir:\n' + '/opt/arm/arm-hpc-compiler-19.0_Generic-AArch64_RHEL-7_aarch64-linux/bin\n', # NOQA + '19.0.0.73'), + ('Arm C/C++/Fortran Compiler version 19.3.1 (build number 75) (based on LLVM 7.0.2)\n' # NOQA + 'Target: aarch64--linux-gnu\n' + 'Thread model: posix\n' + 'InstalledDir:\n' + '/opt/arm/arm-hpc-compiler-19.0_Generic-AArch64_RHEL-7_aarch64-linux/bin\n', # NOQA + '19.3.1.75') +]) +def test_arm_version_detection(version_str, expected_version): + version = spack.compilers.arm.Arm.extract_version_from_output(version_str) + assert version == expected_version + + +@pytest.mark.parametrize('version_str,expected_version', [ + ('Cray C : Version 8.4.6 Mon Apr 15, 2019 12:13:39\n', '8.4.6'), + ('Cray C++ : Version 8.4.6 Mon Apr 15, 2019 12:13:45\n', '8.4.6'), + ('Cray Fortran : Version 8.4.6 Mon Apr 15, 2019 12:13:55\n', '8.4.6') +]) +def test_cce_version_detection(version_str, expected_version): + version = spack.compilers.cce.Cce.extract_version_from_output(version_str) + assert version == expected_version + + +@pytest.mark.regression('10191') +@pytest.mark.parametrize('version_str,expected_version', [ + # macOS clang + ('Apple clang version 11.0.0 (clang-1100.0.33.8)\n' + 'Target: x86_64-apple-darwin18.7.0\n' + 'Thread model: posix\n' + 'InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin\n', # noqa + '11.0.0-apple'), + ('Apple LLVM version 7.0.2 (clang-700.1.81)\n' + 'Target: x86_64-apple-darwin15.2.0\n' + 'Thread model: posix\n', '7.0.2-apple'), + # Other platforms + ('clang version 6.0.1-svn334776-1~exp1~20181018152737.116 (branches/release_60)\n' # noqa + 'Target: x86_64-pc-linux-gnu\n' + 'Thread model: posix\n' + 'InstalledDir: /usr/bin\n', '6.0.1'), + ('clang version 3.1 (trunk 149096)\n' + 'Target: x86_64-unknown-linux-gnu\n' + 'Thread model: posix\n', '3.1'), + ('clang version 8.0.0-3~ubuntu18.04.1 (tags/RELEASE_800/final)\n' + 'Target: x86_64-pc-linux-gnu\n' + 'Thread model: posix\n' + 'InstalledDir: /usr/bin\n', '8.0.0'), + ('clang version 9.0.1-+201911131414230800840845a1eea-1~exp1~20191113231141.78\n' # noqa + 'Target: x86_64-pc-linux-gnu\n' + 'Thread model: posix\n' + 'InstalledDir: /usr/bin\n', '9.0.1'), + ('clang version 8.0.0-3 (tags/RELEASE_800/final)\n' + 'Target: aarch64-unknown-linux-gnu\n' + 'Thread model: posix\n' + 'InstalledDir: /usr/bin\n', '8.0.0') +]) +def test_clang_version_detection(version_str, expected_version): + version = spack.compilers.clang.Clang.extract_version_from_output( + version_str + ) + assert version == expected_version + + +@pytest.mark.parametrize('version_str,expected_version', [ + # C compiler + ('fcc (FCC) 4.0.0 20190314\n' + 'simulating gcc version 6.1\n' + 'Copyright FUJITSU LIMITED 2019', + '4.0.0'), + # C++ compiler + ('FCC (FCC) 4.0.0 20190314\n' + 'simulating gcc version 6.1\n' + 'Copyright FUJITSU LIMITED 2019', + '4.0.0'), + # Fortran compiler + ('frt (FRT) 4.0.0 20190314\n' + 'Copyright FUJITSU LIMITED 2019', + '4.0.0') +]) +def test_fj_version_detection(version_str, expected_version): + version = spack.compilers.fj.Fj.extract_version_from_output(version_str) + assert version == expected_version + + +@pytest.mark.parametrize('version_str,expected_version', [ + # Output of -dumpversion changed to return only major from GCC 7 + ('4.4.7\n', '4.4.7'), + ('7\n', '7') +]) +def test_gcc_version_detection(version_str, expected_version): + version = spack.compilers.gcc.Gcc.extract_version_from_output(version_str) + assert version == expected_version + + +@pytest.mark.parametrize('version_str,expected_version', [ + ('icpc (ICC) 12.1.5 20120612\n' + 'Copyright (C) 1985-2012 Intel Corporation. All rights reserved.\n', + '12.1.5'), + ('ifort (IFORT) 12.1.5 20120612\n' + 'Copyright (C) 1985-2012 Intel Corporation. All rights reserved.\n', + '12.1.5') +]) +def test_intel_version_detection(version_str, expected_version): + version = spack.compilers.intel.Intel.extract_version_from_output( + version_str + ) + assert version == expected_version + + +@pytest.mark.parametrize('version_str,expected_version', [ + ('NAG Fortran Compiler Release 6.0(Hibiya) Build 1037\n' + 'Product NPL6A60NA for x86-64 Linux\n', '6.0') +]) +def test_nag_version_detection(version_str, expected_version): + version = spack.compilers.nag.Nag.extract_version_from_output(version_str) + assert version == expected_version + + +@pytest.mark.parametrize('version_str,expected_version', [ + # Output on x86-64 + ('pgcc 15.10-0 64-bit target on x86-64 Linux -tp sandybridge\n' + 'The Portland Group - PGI Compilers and Tools\n' + 'Copyright (c) 2015, NVIDIA CORPORATION. All rights reserved.\n', + '15.10'), + # Output on PowerPC + ('pgcc 17.4-0 linuxpower target on Linuxpower\n' + 'PGI Compilers and Tools\n' + 'Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved.\n', + '17.4'), + # Output when LLVM-enabled + ('pgcc-llvm 18.4-0 LLVM 64-bit target on x86-64 Linux -tp haswell\n' + 'PGI Compilers and Tools\n' + 'Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.\n', + '18.4') +]) +def test_pgi_version_detection(version_str, expected_version): + version = spack.compilers.pgi.Pgi.extract_version_from_output(version_str) + assert version == expected_version + + +@pytest.mark.parametrize('version_str,expected_version', [ + ('IBM XL C/C++ for Linux, V11.1 (5724-X14)\n' + 'Version: 11.01.0000.0000\n', '11.1'), + ('IBM XL Fortran for Linux, V13.1 (5724-X16)\n' + 'Version: 13.01.0000.0000\n', '13.1'), + ('IBM XL C/C++ for AIX, V11.1 (5724-X13)\n' + 'Version: 11.01.0000.0009\n', '11.1'), + ('IBM XL C/C++ Advanced Edition for Blue Gene/P, V9.0\n' + 'Version: 09.00.0000.0017\n', '9.0') +]) +def test_xl_version_detection(version_str, expected_version): + version = spack.compilers.xl.Xl.extract_version_from_output(version_str) + assert version == expected_version + + version = spack.compilers.xl_r.XlR.extract_version_from_output(version_str) + assert version == expected_version diff --git a/lib/spack/spack/test/compilers.py b/lib/spack/spack/test/compilers/flags.py index 4598605fe4..a7d442d48a 100644 --- a/lib/spack/spack/test/compilers.py +++ b/lib/spack/spack/test/compilers/flags.py @@ -17,17 +17,6 @@ import spack.spec import spack.compiler import spack.compilers as compilers -import spack.compilers.arm -import spack.compilers.cce -import spack.compilers.clang -import spack.compilers.fj -import spack.compilers.gcc -import spack.compilers.intel -import spack.compilers.nag -import spack.compilers.pgi -import spack.compilers.xl -import spack.compilers.xl_r - from spack.compiler import Compiler @@ -582,165 +571,6 @@ def test_xl_r_flags(): 'xl@1.0') -@pytest.mark.parametrize('version_str,expected_version', [ - ('Arm C/C++/Fortran Compiler version 19.0 (build number 73) (based on LLVM 7.0.2)\n' # NOQA - 'Target: aarch64--linux-gnu\n' - 'Thread model: posix\n' - 'InstalledDir:\n' - '/opt/arm/arm-hpc-compiler-19.0_Generic-AArch64_RHEL-7_aarch64-linux/bin\n', # NOQA - '19.0.0.73'), - ('Arm C/C++/Fortran Compiler version 19.3.1 (build number 75) (based on LLVM 7.0.2)\n' # NOQA - 'Target: aarch64--linux-gnu\n' - 'Thread model: posix\n' - 'InstalledDir:\n' - '/opt/arm/arm-hpc-compiler-19.0_Generic-AArch64_RHEL-7_aarch64-linux/bin\n', # NOQA - '19.3.1.75') -]) -def test_arm_version_detection(version_str, expected_version): - version = spack.compilers.arm.Arm.extract_version_from_output(version_str) - assert version == expected_version - - -@pytest.mark.parametrize('version_str,expected_version', [ - ('Cray C : Version 8.4.6 Mon Apr 15, 2019 12:13:39\n', '8.4.6'), - ('Cray C++ : Version 8.4.6 Mon Apr 15, 2019 12:13:45\n', '8.4.6'), - ('Cray Fortran : Version 8.4.6 Mon Apr 15, 2019 12:13:55\n', '8.4.6') -]) -def test_cce_version_detection(version_str, expected_version): - version = spack.compilers.cce.Cce.extract_version_from_output(version_str) - assert version == expected_version - - -@pytest.mark.regression('10191') -@pytest.mark.parametrize('version_str,expected_version', [ - # macOS clang - ('Apple clang version 11.0.0 (clang-1100.0.33.8)\n' - 'Target: x86_64-apple-darwin18.7.0\n' - 'Thread model: posix\n' - 'InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin\n', # noqa - '11.0.0-apple'), - ('Apple LLVM version 7.0.2 (clang-700.1.81)\n' - 'Target: x86_64-apple-darwin15.2.0\n' - 'Thread model: posix\n', '7.0.2-apple'), - # Other platforms - ('clang version 6.0.1-svn334776-1~exp1~20181018152737.116 (branches/release_60)\n' # noqa - 'Target: x86_64-pc-linux-gnu\n' - 'Thread model: posix\n' - 'InstalledDir: /usr/bin\n', '6.0.1'), - ('clang version 3.1 (trunk 149096)\n' - 'Target: x86_64-unknown-linux-gnu\n' - 'Thread model: posix\n', '3.1'), - ('clang version 8.0.0-3~ubuntu18.04.1 (tags/RELEASE_800/final)\n' - 'Target: x86_64-pc-linux-gnu\n' - 'Thread model: posix\n' - 'InstalledDir: /usr/bin\n', '8.0.0'), - ('clang version 9.0.1-+201911131414230800840845a1eea-1~exp1~20191113231141.78\n' # noqa - 'Target: x86_64-pc-linux-gnu\n' - 'Thread model: posix\n' - 'InstalledDir: /usr/bin\n', '9.0.1'), - ('clang version 8.0.0-3 (tags/RELEASE_800/final)\n' - 'Target: aarch64-unknown-linux-gnu\n' - 'Thread model: posix\n' - 'InstalledDir: /usr/bin\n', '8.0.0') -]) -def test_clang_version_detection(version_str, expected_version): - version = compilers.clang.Clang.extract_version_from_output(version_str) - assert version == expected_version - - -@pytest.mark.parametrize('version_str,expected_version', [ - # C compiler - ('fcc (FCC) 4.0.0 20190314\n' - 'simulating gcc version 6.1\n' - 'Copyright FUJITSU LIMITED 2019', - '4.0.0'), - # C++ compiler - ('FCC (FCC) 4.0.0 20190314\n' - 'simulating gcc version 6.1\n' - 'Copyright FUJITSU LIMITED 2019', - '4.0.0'), - # Fortran compiler - ('frt (FRT) 4.0.0 20190314\n' - 'Copyright FUJITSU LIMITED 2019', - '4.0.0') -]) -def test_fj_version_detection(version_str, expected_version): - version = spack.compilers.fj.Fj.extract_version_from_output(version_str) - assert version == expected_version - - -@pytest.mark.parametrize('version_str,expected_version', [ - # Output of -dumpversion changed to return only major from GCC 7 - ('4.4.7\n', '4.4.7'), - ('7\n', '7') -]) -def test_gcc_version_detection(version_str, expected_version): - version = spack.compilers.gcc.Gcc.extract_version_from_output(version_str) - assert version == expected_version - - -@pytest.mark.parametrize('version_str,expected_version', [ - ('icpc (ICC) 12.1.5 20120612\n' - 'Copyright (C) 1985-2012 Intel Corporation. All rights reserved.\n', - '12.1.5'), - ('ifort (IFORT) 12.1.5 20120612\n' - 'Copyright (C) 1985-2012 Intel Corporation. All rights reserved.\n', - '12.1.5') -]) -def test_intel_version_detection(version_str, expected_version): - version = compilers.intel.Intel.extract_version_from_output(version_str) - assert version == expected_version - - -@pytest.mark.parametrize('version_str,expected_version', [ - ('NAG Fortran Compiler Release 6.0(Hibiya) Build 1037\n' - 'Product NPL6A60NA for x86-64 Linux\n', '6.0') -]) -def test_nag_version_detection(version_str, expected_version): - version = spack.compilers.nag.Nag.extract_version_from_output(version_str) - assert version == expected_version - - -@pytest.mark.parametrize('version_str,expected_version', [ - # Output on x86-64 - ('pgcc 15.10-0 64-bit target on x86-64 Linux -tp sandybridge\n' - 'The Portland Group - PGI Compilers and Tools\n' - 'Copyright (c) 2015, NVIDIA CORPORATION. All rights reserved.\n', - '15.10'), - # Output on PowerPC - ('pgcc 17.4-0 linuxpower target on Linuxpower\n' - 'PGI Compilers and Tools\n' - 'Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved.\n', - '17.4'), - # Output when LLVM-enabled - ('pgcc-llvm 18.4-0 LLVM 64-bit target on x86-64 Linux -tp haswell\n' - 'PGI Compilers and Tools\n' - 'Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.\n', - '18.4') -]) -def test_pgi_version_detection(version_str, expected_version): - version = spack.compilers.pgi.Pgi.extract_version_from_output(version_str) - assert version == expected_version - - -@pytest.mark.parametrize('version_str,expected_version', [ - ('IBM XL C/C++ for Linux, V11.1 (5724-X14)\n' - 'Version: 11.01.0000.0000\n', '11.1'), - ('IBM XL Fortran for Linux, V13.1 (5724-X16)\n' - 'Version: 13.01.0000.0000\n', '13.1'), - ('IBM XL C/C++ for AIX, V11.1 (5724-X13)\n' - 'Version: 11.01.0000.0009\n', '11.1'), - ('IBM XL C/C++ Advanced Edition for Blue Gene/P, V9.0\n' - 'Version: 09.00.0000.0017\n', '9.0') -]) -def test_xl_version_detection(version_str, expected_version): - version = spack.compilers.xl.Xl.extract_version_from_output(version_str) - assert version == expected_version - - version = spack.compilers.xl_r.XlR.extract_version_from_output(version_str) - assert version == expected_version - - @pytest.mark.parametrize('compiler_spec,expected_result', [ ('gcc@4.7.2', False), ('clang@3.3', False), ('clang@8.0.0', True) ]) |