From f4c547df36b7700506c9805f37c5eec8d5c49cb5 Mon Sep 17 00:00:00 2001 From: Michael Sarahan Date: Thu, 23 Mar 2017 20:27:17 -0500 Subject: [PATCH] fix run_test.r test files with R --- conda_build/build.py | 7 ++++++- conda_build/config.py | 9 +++++++++ conda_build/create_test.py | 2 +- tests/test-recipes/metadata/r_test_import/meta.yaml | 11 +++++++++++ tests/test-recipes/metadata/r_test_import/run_test.r | 1 + 5 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 tests/test-recipes/metadata/r_test_import/meta.yaml create mode 100644 tests/test-recipes/metadata/r_test_import/run_test.r diff --git a/conda_build/build.py b/conda_build/build.py index 35eedb1e47..d2fd2442e1 100644 --- a/conda_build/build.py +++ b/conda_build/build.py @@ -1197,6 +1197,8 @@ def test(recipedir_or_package_or_metadata, config, move_broken=True): test_script = join(config.test_dir, "conda_test_runner.{suffix}".format(suffix=suffix)) with open(test_script, 'w') as tf: + if not utils.on_win: + tf.write('set -x -e\n') if config.activate: ext = ".bat" if utils.on_win else "" tf.write('{source} "{conda_root}activate{ext}" "{test_env}" {squelch}\n'.format( @@ -1230,7 +1232,7 @@ def test(recipedir_or_package_or_metadata, config, move_broken=True): if utils.on_win: tf.write("if errorlevel 1 exit 1\n") if r_files: - tf.write('"{r}" "{test_file}"\n'.format( + tf.write('"{r}" CMD BATCH "{test_file}"\n'.format( r=config.r_bin(config.test_prefix), test_file=join(config.test_dir, 'run_test.r'))) if utils.on_win: @@ -1254,6 +1256,7 @@ def test(recipedir_or_package_or_metadata, config, move_broken=True): except subprocess.CalledProcessError: tests_failed(metadata, move_broken=move_broken, broken_dir=metadata.config.broken_dir, config=metadata.config) + raise if need_cleanup: utils.rm_rf(recipe_dir) environ.remove_env(actions, index, config) @@ -1389,6 +1392,8 @@ def build_tree(recipe_list, config, build_only=False, post=False, notest=False, build_meta['string'] = build_str dict_and_meta[1].meta['build'] = build_meta test(dict_and_meta[1], config=metadata.config) + except subprocess.CalledProcessError: + has_exception.add(metadata.dist()) built_packages.update({pkg: dict_and_meta}) else: built_packages.update(packages_from_this) diff --git a/conda_build/config.py b/conda_build/config.py index 2117d3a836..5183187f59 100644 --- a/conda_build/config.py +++ b/conda_build/config.py @@ -315,6 +315,13 @@ def _get_lua(self, prefix): res = join(prefix, 'bin/{}'.format(binary_name)) return res + def _get_r(self, prefix): + if sys.platform == 'win32': + res = join(prefix, 'R.exe') + else: + res = join(prefix, 'bin/R') + return res + def compute_build_id(self, package_name, reset=False): if self.set_build_id and (not self._build_id or reset): assert not os.path.isabs(package_name), ("package name should not be a absolute path, " @@ -424,6 +431,8 @@ def perl_bin(self, prefix): def lua_bin(self, prefix): return self._get_lua(prefix) + def r_bin(self, prefix): + return self._get_r(prefix) @property def info_dir(self): """Path to the info dir in the build prefix, where recipe metadata is stored""" diff --git a/conda_build/create_test.py b/conda_build/create_test.py index b4eef9d092..b46c94b40a 100644 --- a/conda_build/create_test.py +++ b/conda_build/create_test.py @@ -127,7 +127,7 @@ def _create_test_files(m, ext, comment_char='# '): if os.path.isfile(test_file): with open(out_file, 'w') as fo: fo.write("%s tests for %s (this is a generated file)\n" % (comment_char, m.dist())) - fo.write(header + '\n') + # fo.write(header + '\n') fo.write("print('===== testing package: %s =====')\n" % m.dist()) try: diff --git a/tests/test-recipes/metadata/r_test_import/meta.yaml b/tests/test-recipes/metadata/r_test_import/meta.yaml new file mode 100644 index 0000000000..a87b4e4f40 --- /dev/null +++ b/tests/test-recipes/metadata/r_test_import/meta.yaml @@ -0,0 +1,11 @@ +package: + name: r-test_conda_build_r_tests + version: 1.0 + +requirements: + run: + - r-base + +tests: + imports: + - r-boot diff --git a/tests/test-recipes/metadata/r_test_import/run_test.r b/tests/test-recipes/metadata/r_test_import/run_test.r new file mode 100644 index 0000000000..e764557c82 --- /dev/null +++ b/tests/test-recipes/metadata/r_test_import/run_test.r @@ -0,0 +1 @@ +print("weee") \ No newline at end of file