Repository: spack/spack

Issue:
Failed to build icu4c against intel@17.0.1 within spack
I failed to build icu4c against intel@17.0.1 within spack due to `NumberFormatRoundTripTest` tests failed. However, I do successfully download icu4c source pack and build it without spack support. All icu4c tests passed. Any idea on such issues?

```
$ spack purge; spack clean icu4c; spack install icu4c %intel@17.0.1
==> Installing icu4c
==> Using cached archive: /tmp/rpm/spack_source_cache/icu4c/icu4c-57.1.tgz
==> Staging archive: /home/rpm/spack/var/spack/stage/icu4c-57.1-ive55vxpgugcpa5geuflcx7zs43zhkgr/icu4c-57_1-src.tgz
==> Created stage in /home/rpm/spack/var/spack/stage/icu4c-57.1-ive55vxpgugcpa5geuflcx7zs43zhkgr
==> No patches needed for icu4c
==> Building icu4c [Package]
==> Executing phase : 'install'
==> Error: ProcessError: Command exited with status 2:
    'make' '-j32' 'check'
/home/rpm/spack/var/spack/repos/builtin/packages/icu4c/package.py:50, in install:
     43       def install(self, spec, prefix):
     44           with working_dir('source'):
     45               configure('--prefix={0}'.format(prefix),
     46                         '--enable-rpath')
     47
     48               make()
     49               make('check')
  >> 50               make('install')

See build log for details:
  /tmp/pytest-of-rpm/pytest-2/test_keep_exceptions0/tmp/spack-stage/spack-stage-kIWxiU/icu/spack-build.out

$ tail -50 /tmp/pytest-of-rpm/pytest-2/test_keep_exceptions0/tmp/spack-stage/spack-stage-kIWxiU/icu/spack-build.out
PortableFontInstance.cpp:92: ../..//test/testdata/DejaVuSans.ttf: FNF
"   Test OrientBug: can't open font DejaVuSans.ttf - test skipped.
   }                                         ---[OK]   /c_layout/DataDrivenTest  (8ms) 
  }   /c_layout  (8ms)
  c_paragraph  {
   GlyphToCharTest                           ---[OK]
  }
 }   / (./letest)  (24ms)

[All tests passed successfully...]
Elapsed Time: 00:00:00.024
make[2]: Leaving directory `/tmp/pytest-of-rpm/pytest-2/test_keep_exceptions0/tmp/spack-stage/spack-stage-kIWxiU/icu/source/test/letest'
-------------
| ***     FAILING TEST SUMMARY FOR:              intltest
         start
      NumberFormatRoundTripTest
   format
| *** END FAILING TEST SUMMARY FOR:              intltest
---------------
ALL TESTS SUMMARY:
ok:  testdata iotest cintltst letest
===== ERRS:  intltest
make[1]: *** [check-recursive] Error 1
make[1]: Leaving directory `/tmp/pytest-of-rpm/pytest-2/test_keep_exceptions0/tmp/spack-stage/spack-stage-kIWxiU/icu/source/test'
make: *** [check-recursive] Error 2
```

More details on the failing test `NumberFormatRoundTripTest`:

```
...
NumberFormatRoundTripTest {
         start {
         *** STRING ERROR "-0.00000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000002225073
8585072" != "-0"
...
```

However, I can downnload icu4c package and build it without spack's support. The compiler is the same as the one used in spack.

```
export TOP=/lustre/spack/tools/linux-centos7-x86_64/gcc-4.8.5/intel-parallel-studio-cluster.2017.1-4uy7iwkuftkrg5wx2sg5zi6r5355rqbe
export PATH=$TOP/bin:$PATH
export CPPFLAGS="$CPPFLAGS -DNO_IDENT"
export LD_LIBRARY_PATH=$TOP/lib/intel64:$LD_LIBRARY_PATH
export LIBRARY_PATH=$TOP/lib:$LIBRARY_PATH
export C_INCLUDE_PATH=$TOP/include
export CPLUS_INCLUDE_PATH=$TOP/include:$TOP/include/c++
export CC=icc
export CXX=icpc

wget http://download.icu-project.org/files/icu4c/57.1/icu4c-57_1-src.tgz
tar xzvpf icu4c-57_1-src.tgz
cd icu/source
./configure
make -j32
make check
```


Discussion:
Based on the test result:

> "-0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000022250738585072" != "-0"

I think it's safe to say that the answer is "close enough". Unfortunately, poorly designed test suites don't understand "close enough", and since the two numbers aren't identical, it fails. I would say it's safe to ignore this error. I'll put out a PR shortly that updates `icu4c` so that the test suite is only run when you specify `spack install --run-tests`. As it is now, there's no way to build `icu4c` without commenting out `make('check')`.

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/icu4c/package.py b/var/spack/repos/builtin/packages/icu4c/package.py
--- a/var/spack/repos/builtin/packages/icu4c/package.py
+++ b/var/spack/repos/builtin/packages/icu4c/package.py
@@ -25,26 +25,24 @@
 from spack import *
 
 
-class Icu4c(Package):
+class Icu4c(AutotoolsPackage):
     """ICU is a mature, widely used set of C/C++ and Java libraries providing
     Unicode and Globalization support for software applications. ICU4C is the
     C/C++ interface."""
 
     homepage = "http://site.icu-project.org/"
     url      = "http://download.icu-project.org/files/icu4c/57.1/icu4c-57_1-src.tgz"
+    list_url = "http://download.icu-project.org/files/icu4c"
+    list_depth = 2
 
+    version('58.2', 'fac212b32b7ec7ab007a12dff1f3aea1')
     version('57.1', '976734806026a4ef8bdd17937c8898b9')
 
-    def url_for_version(self, version):
-        base_url = "http://download.icu-project.org/files/icu4c"
-        return "{0}/{1}/icu4c-{2}-src.tgz".format(
-            base_url, version, version.underscored)
+    configure_directory = 'source'
 
-    def install(self, spec, prefix):
-        with working_dir('source'):
-            configure('--prefix={0}'.format(prefix),
-                      '--enable-rpath')
+    def url_for_version(self, version):
+        url = "http://download.icu-project.org/files/icu4c/{0}/icu4c-{1}-src.tgz"
+        return url.format(version.dotted, version.underscored)
 
-            make()
-            make('check')
-            make('install')
+    def configure_args(self):
+        return ['--enable-rpath']


Test patch: