Datasets:
Download code/robohome/src/tools/rplan_library/test_build_scripts.py from RoboParty/RoboHome: direct link, hf CLI and curl.
- Browser
- Download file 3.56 kB
-
https://huggingface.co/datasets/RoboParty/RoboHome/resolve/main/code/robohome/src/tools/rplan_library/test_build_scripts.py
- Command line
-
hf download hf://datasets/RoboParty/RoboHome/code/robohome/src/tools/rplan_library/test_build_scripts.py
-
curl -L -o test_build_scripts.py https://huggingface.co/datasets/RoboParty/RoboHome/resolve/main/code/robohome/src/tools/rplan_library/test_build_scripts.py
3.56 kB
| """Portable driver checks: no raw RPLAN data or geometry dependencies needed.""" | |
| import os | |
| from pathlib import Path | |
| import subprocess | |
| import tempfile | |
| import unittest | |
| TOOLS = Path(__file__).resolve().parent | |
| class BuildScriptTests(unittest.TestCase): | |
| def test_missing_mat_has_actionable_error_before_running_python(self): | |
| for script in ('build_conventional.sh', 'build_full.sh'): | |
| with self.subTest(script=script), tempfile.TemporaryDirectory() as folder: | |
| env = dict(os.environ) | |
| env.pop('RPLAN_MAT', None) | |
| result = subprocess.run(['bash', str(TOOLS / script), folder, str(TOOLS.parents[1])], | |
| env=env, capture_output=True, text=True) | |
| self.assertNotEqual(result.returncode, 0) | |
| self.assertIn('RPLAN_MAT', result.stderr) | |
| self.assertIn('data.mat', result.stderr) | |
| def test_relative_paths_spaces_and_python3_from_path(self): | |
| for script, calls in (('build_conventional.sh', 9), ('build_full.sh', 4)): | |
| with self.subTest(script=script), tempfile.TemporaryDirectory() as folder: | |
| root = Path(folder) | |
| binary = root / 'bin' | |
| binary.mkdir() | |
| fake = binary / 'python3' | |
| fake.write_text('#!/bin/bash\n' | |
| 'for arg in "$@"; do printf "%s\\n" "$arg"; done >> "$CALL_LOG"\n' | |
| 'printf "END\\n" >> "$CALL_LOG"\n') | |
| fake.chmod(0o755) | |
| (root / 'data.mat').touch() | |
| (root / 'code tree/engine/supervisor_site').mkdir(parents=True) | |
| log = root / 'calls.txt' | |
| env = {**os.environ, 'PATH': str(binary) + os.pathsep + os.environ['PATH'], | |
| 'RPLAN_MAT': 'data.mat', 'CALL_LOG': str(log)} | |
| result = subprocess.run(['bash', str(TOOLS / script), 'out dir', 'code tree'], | |
| cwd=root, env=env, capture_output=True, text=True) | |
| self.assertEqual(result.returncode, 0, result.stderr) | |
| args = log.read_text().splitlines() | |
| self.assertEqual(args.count('END'), calls) | |
| self.assertIn(str((root / 'data.mat').resolve()), args) | |
| self.assertIn(str((root / 'code tree').resolve()), args) | |
| self.assertTrue((root / 'out dir').is_dir()) | |
| def test_conversion_failure_stops_before_screening(self): | |
| with tempfile.TemporaryDirectory() as folder: | |
| root = Path(folder) | |
| (root / 'bin').mkdir() | |
| fake = root / 'bin/python3' | |
| fake.write_text('#!/bin/bash\nexit 7\n') | |
| fake.chmod(0o755) | |
| (root / 'data.mat').touch() | |
| (root / 'code/engine/supervisor_site').mkdir(parents=True) | |
| env = {**os.environ, 'PATH': str(fake.parent) + os.pathsep + os.environ['PATH'], | |
| 'RPLAN_MAT': str(root / 'data.mat')} | |
| for script in ('build_conventional.sh', 'build_full.sh'): | |
| with self.subTest(script=script): | |
| out = root / script | |
| result = subprocess.run(['bash', str(TOOLS / script), str(out), str(root / 'code')], | |
| env=env, capture_output=True, text=True) | |
| self.assertEqual(result.returncode, 7, result.stderr) | |
| self.assertFalse(list(out.glob('*.screened.log'))) | |
| if __name__ == '__main__': | |
| unittest.main() | |