From 878f963dea63e2535ba253a91e172249379d61a1 Mon Sep 17 00:00:00 2001 From: Martin Jaime Flores Jr Date: Fri, 19 Apr 2024 15:28:12 -0500 Subject: [PATCH] [#7704] Deprecate trimPrefix(...), trimSpaces(...), add irule test trimPrefix(...) and trimSpaces(...) are only used by irule in the two cases removed in the companion icommands commit, so they are now deprecated. A test was added to simulate the case that discovered the error. --- lib/core/include/irods/rcMisc.h | 6 ++++++ scripts/irods/test/test_irule.py | 16 ++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/lib/core/include/irods/rcMisc.h b/lib/core/include/irods/rcMisc.h index f55f8944d1..56a7a6b1e7 100644 --- a/lib/core/include/irods/rcMisc.h +++ b/lib/core/include/irods/rcMisc.h @@ -360,9 +360,15 @@ int getAttriInAttriArray(const char* objPath, int* outDataMode, char** outChksum); +// clang-format off +__attribute__((deprecated)) char* trimSpaces(char* str); +// clang-format on +// clang-format off +__attribute__((deprecated)) char* trimPrefix(char* str); +// clang-format on int convertListToMultiString(char* strInput, int input); diff --git a/scripts/irods/test/test_irule.py b/scripts/irods/test/test_irule.py index fbc647cb45..5e86083670 100644 --- a/scripts/irods/test/test_irule.py +++ b/scripts/irods/test/test_irule.py @@ -1,4 +1,5 @@ from __future__ import print_function +import os import sys if sys.version_info >= (2, 7): import unittest @@ -53,3 +54,18 @@ def test_irule_printVariables_on_stdout_4189(self): self.assertNotIn( "[1]", stdout ) self.assertIn( "badInput format error", stderr ) self.assertNotEqual( rc, 0 ) + + @unittest.skipUnless(plugin_name == 'irods_rule_engine_plugin-irods_rule_language', 'only applicable for irods_rule_language REP') + def test_irule_does_not_crash_on_bad_rule_file__issue_7740(self): + bad_rule = ''' + test_irule_does_not_crash_on_bad_rule_file__issue_7740 { + writeLine("Did I do this right?"); + } + OUTPUT + ''' + path_to_file = os.path.join(self.admin.local_session_dir, 'issue_7740.r') + + with open(path_to_file, 'w') as f: + f.write(bad_rule) + + self.admin.assert_icommand_fail(['irule', '-F', path_to_file, '-r', 'irods_rule_engine_plugin-irods_rule_language-instance'], desired_rc=2)