|
35 | 35 | import os |
36 | 36 | import re |
37 | 37 | import signal |
| 38 | +import string |
38 | 39 | import stat |
39 | 40 | import subprocess |
40 | 41 | import sys |
|
51 | 52 | from easybuild.tools.config import update_build_option |
52 | 53 | from easybuild.tools.filetools import adjust_permissions, change_dir, mkdir, read_file, write_file |
53 | 54 | from easybuild.tools.run import RunShellCmdResult, RunShellCmdError, check_async_cmd, check_log_for_errors |
54 | | -from easybuild.tools.run import complete_cmd, get_output_from_process, parse_log_for_error |
| 55 | +from easybuild.tools.run import complete_cmd, fileprefix_from_cmd, get_output_from_process, parse_log_for_error |
55 | 56 | from easybuild.tools.run import run_cmd, run_cmd_qa, run_shell_cmd, subprocess_terminate |
56 | 57 | from easybuild.tools.config import ERROR, IGNORE, WARN |
57 | 58 |
|
@@ -193,6 +194,24 @@ def test_run_shell_cmd_basic(self): |
193 | 194 | self.assertTrue(isinstance(res.output, str)) |
194 | 195 | self.assertTrue(res.work_dir and isinstance(res.work_dir, str)) |
195 | 196 |
|
| 197 | + def test_fileprefix_from_cmd(self): |
| 198 | + """test simplifications from fileprefix_from_cmd.""" |
| 199 | + cmds = { |
| 200 | + 'abd123': 'abd123', |
| 201 | + 'ab"a': 'aba', |
| 202 | + 'a{:$:S@"a': 'aSa', |
| 203 | + } |
| 204 | + for cmd, expected_simplification in cmds.items(): |
| 205 | + self.assertEqual(fileprefix_from_cmd(cmd), expected_simplification) |
| 206 | + |
| 207 | + cmds = { |
| 208 | + 'abd123': 'abd', |
| 209 | + 'ab"a': 'aba', |
| 210 | + '0a{:$:2@"a': 'aa', |
| 211 | + } |
| 212 | + for cmd, expected_simplification in cmds.items(): |
| 213 | + self.assertEqual(fileprefix_from_cmd(cmd, allowed_chars=string.ascii_letters), expected_simplification) |
| 214 | + |
196 | 215 | def test_run_cmd_log(self): |
197 | 216 | """Test logging of executed commands.""" |
198 | 217 | fd, logfile = tempfile.mkstemp(suffix='.log', prefix='eb-test-') |
|
0 commit comments