summaryrefslogtreecommitdiff
path: root/numpy/distutils/tests/test_fcompiler.py
diff options
context:
space:
mode:
authorIsuru Fernando <isuruf@gmail.com>2018-07-07 19:23:38 -0600
committerIsuru Fernando <isuruf@gmail.com>2018-07-07 19:23:38 -0600
commitfc9dacad18766d79dde16e14219c302a94bc29ff (patch)
tree286da35147c27dfbb8a5b38005ec8b33bc32c57d /numpy/distutils/tests/test_fcompiler.py
parent3c63e402f8348e75363ff833d5dfd869e16db5be (diff)
downloadnumpy-fc9dacad18766d79dde16e14219c302a94bc29ff.tar.gz
Test distutils flags appending
Diffstat (limited to 'numpy/distutils/tests/test_fcompiler.py')
-rw-r--r--numpy/distutils/tests/test_fcompiler.py47
1 files changed, 47 insertions, 0 deletions
diff --git a/numpy/distutils/tests/test_fcompiler.py b/numpy/distutils/tests/test_fcompiler.py
new file mode 100644
index 000000000..4ab1522d7
--- /dev/null
+++ b/numpy/distutils/tests/test_fcompiler.py
@@ -0,0 +1,47 @@
+from __future__ import division, absolute_import, print_function
+
+from numpy.testing import assert_
+import numpy.distutils.fcompiler
+import os
+
+customizable_flags = [
+ ('f77', 'F77FLAGS'),
+ ('f90', 'F90FLAGS'),
+ ('free', 'FREEFLAGS'),
+ ('arch', 'FARCH'),
+ ('debug', 'FDEBUG'),
+ ('flags', 'FFLAGS'),
+ ('linker_so', 'LDFLAGS'),
+]
+
+
+def test_fcompiler_flags_override(monkeypatch):
+ monkeypatch.setitem(os.environ, 'NPY_DISTUTILS_APPEND_FLAGS', '0')
+ fc = numpy.distutils.fcompiler.new_fcompiler(compiler='none')
+ flag_vars = fc.flag_vars.clone(lambda *args, **kwargs: None)
+
+ for opt, envvar in customizable_flags:
+ new_flag = '-dummy-{}-flag'.format(opt)
+ prev_flags = getattr(flag_vars, opt)
+
+ monkeypatch.setitem(os.environ, envvar, new_flag)
+ new_flags = getattr(flag_vars, opt)
+ assert_(new_flags == [new_flag])
+
+
+def test_fcompiler_flags_append(monkeypatch):
+ monkeypatch.setitem(os.environ, 'NPY_DISTUTILS_APPEND_FLAGS', '1')
+ fc = numpy.distutils.fcompiler.new_fcompiler(compiler='none')
+ flag_vars = fc.flag_vars.clone(lambda *args, **kwargs: None)
+
+ for opt, envvar in customizable_flags:
+ new_flag = '-dummy-{}-flag'.format(opt)
+ prev_flags = getattr(flag_vars, opt)
+
+ monkeypatch.setitem(os.environ, envvar, new_flag)
+ new_flags = getattr(flag_vars, opt)
+ if prev_flags is None:
+ assert_(new_flags == [new_flag])
+ else:
+ assert_(new_flags == prev_flags + [new_flag])
+