Merge pull request #1891 from cognitree/unit-tests-duplicate-options

Unit tests for duplicate parameters in cli and scenario
This commit is contained in:
Madhavan 2024-04-01 14:16:45 -04:00 committed by GitHub
commit 6e379f78f0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 19 additions and 0 deletions

View File

@ -194,4 +194,11 @@ public class NBCLIScenarioPreprocessorTest {
assertThat(cmds1.get(0).getArgValueOrNull("cycles_test")).isNull(); assertThat(cmds1.get(0).getArgValueOrNull("cycles_test")).isNull();
} }
@Test
public void testThatDuplicateParamInScenarioDefThrowsError() {
assertThatExceptionOfType(BasicError.class)
.isThrownBy(() -> new NBCLIOptions(new String[]{"scenario_test", "duplicate_param"}, NBCLIOptions.Mode.ParseAllOptions))
.withMessageContaining("Duplicate occurrence of parameter \"threads\"");
}
} }

View File

@ -11,6 +11,10 @@ scenarios:
template_test: template_test:
with_template: run driver=stdout cycles=TEMPLATE(cycles-test,10) with_template: run driver=stdout cycles=TEMPLATE(cycles-test,10)
duplicate_param:
schema: run driver=stdout workload==scenario_test threads=auto tags=block:"schema.*" threads=1 doundef==undef
blocks: blocks:
schema: schema:
ops: ops:

View File

@ -26,6 +26,7 @@ import java.util.LinkedList;
import java.util.List; import java.util.List;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.junit.jupiter.api.Assertions.*; import static org.junit.jupiter.api.Assertions.*;
// test for dots and underscores in names // test for dots and underscores in names
@ -98,4 +99,11 @@ class CmdParserTest {
assertThat(cmds.getFirst().getArgValue("param1")).isEqualTo("value1"); assertThat(cmds.getFirst().getArgValue("param1")).isEqualTo("value1");
} }
@Test
public void testThatDuplicateParameterThrowsBasicError() {
assertThatExceptionOfType(BasicError.class)
.isThrownBy(() -> CmdParser.parseArgvCommands(new LinkedList<>(List.of("run", "threads=auto", "threads=1"))))
.withMessageContaining("Duplicate occurrence of option: threads");
}
} }