This repository was archived by the owner on Aug 30, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +33
-1
lines changed
standalone/src/test/java/com/trivadis/plsql/formatter/sqlcl/tests Expand file tree Collapse file tree 2 files changed +33
-1
lines changed Original file line number Diff line number Diff line change @@ -260,11 +260,27 @@ var getCdPath = function (path) {
260260 }
261261}
262262
263+ var replaceAll = function ( input , pattern , replacement ) {
264+ var p = javaPattern . compile ( pattern ) ;
265+ var m = p . matcher ( input ) ;
266+ var result = "" ;
267+ var pos = 0 ;
268+ while ( m . find ( ) ) {
269+ result += input . substring ( pos , m . start ( ) ) ;
270+ result += replacement ;
271+ pos = m . end ( ) ;
272+ }
273+ if ( input . length > pos ) {
274+ result += input . substring ( pos ) ;
275+ }
276+ return result ;
277+ }
278+
263279var createIgnoreMatcher = function ( ignorePath ) {
264280 var globPattern = "glob:{"
265281 var lines = javaFiles . readAllLines ( javaPaths . get ( ignorePath ) ) ;
266282 for ( var i = 0 ; i < lines . size ( ) ; i ++ ) {
267- var line = lines [ i ] . trim ( ) ;
283+ var line = replaceAll ( lines [ i ] . trim ( ) , "(\\\\)" , "/" ) ;
268284 if ( line . length > 0 && line . indexOf ( '#' ) === - 1 ) {
269285 if ( globPattern . length > 6 ) {
270286 globPattern += "," ;
Original file line number Diff line number Diff line change @@ -52,4 +52,20 @@ public void ignore_two_files() throws IOException {
5252 var actual = runCommand ( "tvdformat " + tempDir .toString () + " ignore=" + tempDir + File .separator + "ignore.txt" );
5353 Assertions .assertTrue (actual .contains ("2 of 2" ));
5454 }
55+
56+ @ Test
57+ public void ignore_two_files_windows_separator () throws IOException {
58+ // must run in an own test class, reason is not clear
59+ var ignoreFileContent = """
60+ # ignore package bodies (single backslash)
61+ **\\ *.pkb
62+
63+ # Ignore files with syntax errors (single backslash)
64+ **\\ *syntax*
65+ """ ;
66+ final Path ignoreFile = Paths .get (tempDir + File .separator + "ignore2.txt" );
67+ Files .write (ignoreFile , ignoreFileContent .getBytes ());
68+ var actual = runCommand ( "tvdformat " + tempDir .toString () + " ignore=" + tempDir + File .separator + "ignore2.txt" );
69+ Assertions .assertTrue (actual .contains ("2 of 2" ));
70+ }
5571}
You can’t perform that action at this time.
0 commit comments