Skip to content

SelectorUtils.matchPath(): inconsistent behaviour on POSIX-like and Windows for single Wildcard pattern #191

Closed
@fishermans

Description

@fishermans

Hi,

I was wondering why maven-shade-plugin produces different results on Windows and MAC. The single wildcard match is working inconsistently depending on the OS.

Please find a test to reproduce this (see comments in test file):

import org.codehaus.plexus.util.SelectorUtils;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

public class PatternMatcherTest {

  @Test
  void testPatternMatchSingleWildCardLinux() {

    /* Passes on Linux - fails on Windows */
    Assertions.assertFalse(SelectorUtils.matchPath(
            "/com/test/*",
            "/com/test/test/hallo"));
  }


  @Test
  void testPatternMatchDoubleWildCardCaseInLinux() {

    /* OK */
    Assertions.assertTrue(SelectorUtils.matchPath(
            "/com/test/**",
            "/com/test/test/hallo"));
  }


  @Test
  void testPatternMatchDoubleWildCardLinux() {

    /* OK */
    Assertions.assertTrue(SelectorUtils.matchPath(
            "/com/test/**",
            "/com/test/test/hallo"));
  }


  @Test
  void testPatternMatchSingleWildCardWindows() {

    /* Fails on Linux - passes on Windows */
    Assertions.assertFalse(SelectorUtils.matchPath(
            "D:\\com\\test\\*",
            "D:\\com\\test\\test\\hallo"));
  }


  @Test
  void testPatternMatchDoubleWildCardWindows() {

    /* OK */
    Assertions.assertTrue(SelectorUtils.matchPath(
            "D:\\com\\test\\**",
            "D:\\com\\test\\test\\hallo"));
  }


  @Test
  void testPatternMatchSingleWildCardDotLinux() {

    /* Fails on Linux - fails on Windows */
    Assertions.assertFalse(SelectorUtils.matchPath(
            "com.test.*",
            "com.test.test.hallo"));
  }


  @Test
  void testPatternMatchDoubleWildCardDotLinux() {

    /* OK */
    Assertions.assertTrue(SelectorUtils.matchPath(
            "com.test.**",
            "com.test.test.hallo"));
  }
}

BG

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions