Skip to content

Commit

Permalink
[irods#7704] Deprecate trimPrefix(...), trimSpaces(...), add irule test
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
MartinFlores751 authored and alanking committed Jul 1, 2024
1 parent 72e1f6c commit 878f963
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/core/include/irods/rcMisc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
16 changes: 16 additions & 0 deletions scripts/irods/test/test_irule.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from __future__ import print_function
import os
import sys
if sys.version_info >= (2, 7):
import unittest
Expand Down Expand Up @@ -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)

0 comments on commit 878f963

Please sign in to comment.