mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2025-02-25 18:55:28 -06:00
nosqlbench-308 Arg parsing broken since v4.15.33 - unrecognized option
This commit is contained in:
parent
2261264411
commit
b8f6d38f07
@ -264,7 +264,16 @@ public class NBIO implements NBPathsAPI.Facets {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// for testing
|
/**
|
||||||
|
* Given names and suffixes, expand a list of names which may be valid.
|
||||||
|
* If no name is given, then <pre>{@code .*}</pre> is used.
|
||||||
|
* If suffixes are given, then all returned results must include at least
|
||||||
|
* one of the suffixes. If the name includes one of the suffixes given,
|
||||||
|
* then additional names are expanded to match the additional suffixes.
|
||||||
|
* @param _names base filenames or path fragment, possibly fully-qualified
|
||||||
|
* @param _suffixes zero or more suffixes, which, if given, imply that one of them must match
|
||||||
|
* @return Expanded names of valid filename fragments according to the above rules
|
||||||
|
*/
|
||||||
public LinkedHashSet<String> expandNamesAndSuffixes(
|
public LinkedHashSet<String> expandNamesAndSuffixes(
|
||||||
List<String> _names,
|
List<String> _names,
|
||||||
Set<String> _suffixes) {
|
Set<String> _suffixes) {
|
||||||
@ -279,20 +288,20 @@ public class NBIO implements NBPathsAPI.Facets {
|
|||||||
_suffixes.stream().map(s -> ".*" + s).forEach(searches::add);
|
_suffixes.stream().map(s -> ".*" + s).forEach(searches::add);
|
||||||
} else {
|
} else {
|
||||||
for (String name : _names) {
|
for (String name : _names) {
|
||||||
if (!name.equals(".*")) {
|
// if (!name.equals(".*")) {
|
||||||
searches.add(name);
|
// searches.add(name);
|
||||||
}
|
// }
|
||||||
|
String basename = name;
|
||||||
boolean suffixed = false;
|
boolean suffixed = false;
|
||||||
for (String suffix : _suffixes) {
|
for (String suffix : _suffixes) {
|
||||||
if (name.endsWith(suffix)) {
|
if (name.endsWith(suffix)) {
|
||||||
suffixed = true;
|
suffixed = true;
|
||||||
|
basename = name.substring(0,name.length()-suffix.length());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!suffixed) {
|
for (String suffix : _suffixes) {
|
||||||
for (String suffix : _suffixes) {
|
searches.add(basename + suffix);
|
||||||
searches.add(name + suffix);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,10 +28,10 @@ public class NBIOTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testExpandNameOnly() {
|
public void testExpandNameAndAllSuffixesOnly() {
|
||||||
NBIO extensions = (NBIO) NBIO.all().name("foo.bar").extension();
|
NBIO extensions = (NBIO) NBIO.all().name("foo.bar").extension("test1","test2");
|
||||||
LinkedHashSet<String> searches = extensions.expandNamesAndSuffixes();
|
LinkedHashSet<String> searches = extensions.expandNamesAndSuffixes();
|
||||||
assertThat(searches).containsExactly("foo.bar");
|
assertThat(searches).containsExactly("foo.bar.test1","foo.bar.test2");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -43,9 +43,9 @@ public class NBIOTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testExpandNamesAndExtensionsAvoidsExtendedAlreadyExtended() {
|
public void testExpandNamesAndExtensionsAvoidsExtendedAlreadyExtended() {
|
||||||
NBIO extensions = (NBIO) NBIO.all().name("foo.bar").extension("baz","beez");
|
NBIO extensions = (NBIO) NBIO.all().name("foo.baz").extension("baz","beez");
|
||||||
LinkedHashSet<String> searches = extensions.expandNamesAndSuffixes();
|
LinkedHashSet<String> searches = extensions.expandNamesAndSuffixes();
|
||||||
assertThat(searches).contains("foo.bar");
|
assertThat(searches).contains("foo.baz","foo.beez");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -69,10 +69,10 @@ public class NBIOTest {
|
|||||||
public void testExpandAddExtensionNeeded() {
|
public void testExpandAddExtensionNeeded() {
|
||||||
NBIO extensions = (NBIO) NBIO.all().name("foo").extension("bar");
|
NBIO extensions = (NBIO) NBIO.all().name("foo").extension("bar");
|
||||||
LinkedHashSet<String> searches = extensions.expandNamesAndSuffixes();
|
LinkedHashSet<String> searches = extensions.expandNamesAndSuffixes();
|
||||||
assertThat(searches).containsExactly("foo","foo.bar");
|
assertThat(searches).containsExactly("foo.bar");
|
||||||
NBIO extensionsDot = (NBIO) NBIO.all().name("foo").extension(".bar");
|
NBIO extensionsDot = (NBIO) NBIO.all().name("foo").extension(".bar");
|
||||||
LinkedHashSet<String> searchesDot = extensionsDot.expandNamesAndSuffixes();
|
LinkedHashSet<String> searchesDot = extensionsDot.expandNamesAndSuffixes();
|
||||||
assertThat(searchesDot).containsExactly("foo","foo.bar");
|
assertThat(searchesDot).containsExactly("foo.bar");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -166,8 +166,8 @@ public class NBIOTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testLoadNamedFileAsYmlExtension() {
|
public void testLoadNamedFileAsYmlExtension() {
|
||||||
List<Content<?>> list = NBIO.classpath()
|
List<Content<?>> list = NBIO.classpath()
|
||||||
.name("nesteddir1/nesteddir2/testworkload1.yml")
|
.name("nesteddir1/nesteddir2/testworkload1")
|
||||||
.extension("abc")
|
.extension("yml")
|
||||||
.list();
|
.list();
|
||||||
assertThat(list).hasSize(1);
|
assertThat(list).hasSize(1);
|
||||||
|
|
||||||
@ -229,4 +229,32 @@ public class NBIOTest {
|
|||||||
assertThat(gammas).hasSize(1);
|
assertThat(gammas).hasSize(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void onlyMatchExtensionFilesWhenExtensionsProvided() {
|
||||||
|
|
||||||
|
// This search is invalid because by providing extensions, all results
|
||||||
|
// are required to match one of the extensions, thus the only valid
|
||||||
|
// match here would be alpha-gamma.yaml.js
|
||||||
|
NBPathsAPI.DoSearch invalidSearch = NBIO.all()
|
||||||
|
.prefix(Paths.get("target/test-classes/").toString())
|
||||||
|
.name("alpha-gamma.yaml")
|
||||||
|
.extension("js");
|
||||||
|
|
||||||
|
NBPathsAPI.DoSearch validSearch1 = NBIO.all()
|
||||||
|
.prefix(Paths.get("target/test-classes/").toString())
|
||||||
|
.name("alpha-gamma")
|
||||||
|
.extension("js");
|
||||||
|
|
||||||
|
NBPathsAPI.DoSearch validSearch2 = NBIO.all()
|
||||||
|
.prefix(Paths.get("target/test-classes/").toString())
|
||||||
|
.name("alpha-gamma.js")
|
||||||
|
.extension();
|
||||||
|
|
||||||
|
|
||||||
|
assertThat(invalidSearch.list()).hasSize(0);
|
||||||
|
assertThat(validSearch1.list()).hasSize(1);
|
||||||
|
assertThat(validSearch2.list()).hasSize(1);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1 @@
|
|||||||
|
println("test of alpha-gamma.js")
|
Loading…
Reference in New Issue
Block a user