Skip to content

Commit

Permalink
fix run_test.r test files with R
Browse files Browse the repository at this point in the history
  • Loading branch information
msarahan committed Mar 24, 2017
1 parent 7775714 commit f4c547d
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 2 deletions.
7 changes: 6 additions & 1 deletion conda_build/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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:
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
9 changes: 9 additions & 0 deletions conda_build/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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, "
Expand Down Expand Up @@ -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"""
Expand Down
2 changes: 1 addition & 1 deletion conda_build/create_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
11 changes: 11 additions & 0 deletions tests/test-recipes/metadata/r_test_import/meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package:
name: r-test_conda_build_r_tests
version: 1.0

requirements:
run:
- r-base

tests:
imports:
- r-boot
1 change: 1 addition & 0 deletions tests/test-recipes/metadata/r_test_import/run_test.r
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
print("weee")

0 comments on commit f4c547d

Please sign in to comment.