diff options
author | Jan Belle | 2019-05-05 20:26:00 +0000 |
---|---|---|
committer | Jan Belle | 2019-05-07 17:24:22 +0000 |
commit | 1b54f1147b4de985ae2254151ab224e6544e68ba (patch) | |
tree | 41c9122ca2c3f4cc4be2b0d2683f76d48ed74f6b /plugins | |
parent | 60a8377a08defc5a52e2199990d6fc8a7bd98f26 (diff) | |
download | org.eclipse.etrice-1b54f1147b4de985ae2254151ab224e6544e68ba.tar.gz org.eclipse.etrice-1b54f1147b4de985ae2254151ab224e6544e68ba.tar.xz org.eclipse.etrice-1b54f1147b4de985ae2254151ab224e6544e68ba.zip |
[generator.tests] Migrate tests to new import system
Bug 545235
Change-Id: I5f349f7ab6cf12e23cfc68323987e24c998ae263
Diffstat (limited to 'plugins')
9 files changed, 49 insertions, 79 deletions
diff --git a/plugins/org.eclipse.etrice.core.room.ui/eTrice-rt.launch b/plugins/org.eclipse.etrice.core.room.ui/eTrice-rt.launch index 98fc0beb4..6e4b0ece6 100644 --- a/plugins/org.eclipse.etrice.core.room.ui/eTrice-rt.launch +++ b/plugins/org.eclipse.etrice.core.room.ui/eTrice-rt.launch @@ -13,7 +13,7 @@ <booleanAttribute key="default" value="true"/> <stringAttribute key="deselected_workspace_plugins" value="org.eclipse.etrice.example,org.eclipse.etrice.integration.tests"/> <booleanAttribute key="includeOptional" value="true"/> -<stringAttribute key="location" value="${workspace_loc}/../eTrice-rt"/> +<stringAttribute key="location" value=""/> <mapAttribute key="org.eclipse.debug.core.environmentVariables"> <mapEntry key="etModellib" value="org.eclipse.etrice.modellib.c"/> </mapAttribute> diff --git a/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/args/IntegerOption.java b/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/args/IntegerOption.java deleted file mode 100644 index b3cec8e30..000000000 --- a/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/args/IntegerOption.java +++ /dev/null @@ -1,30 +0,0 @@ -/******************************************************************************* -* Copyright (c) 2018 protos software gmbh (http://www.protos.de). -* All rights reserved. -* -* This program and the accompanying materials are made -* available under the terms of the Eclipse Public License 2.0 -* which is available at https://www.eclipse.org/legal/epl-2.0/ -* -* SPDX-License-Identifier: EPL-2.0 -* -* CONTRIBUTORS: -* Jan Belle (initial contribution) -* - *******************************************************************************/ - -package org.eclipse.etrice.generator.base.args; - -/** - * Describes an option that takes an {@link Integer} value. - */ -public class IntegerOption extends Option<Integer> { - - /** - * @see Option#Option - */ - public IntegerOption(String group, String name, String argumentName, String description, int defaultValue) { - super(Integer.class, group, name, argumentName, description, defaultValue); - } - -} diff --git a/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/args/PathOption.java b/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/args/PathOption.java new file mode 100644 index 000000000..41efa7a70 --- /dev/null +++ b/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/args/PathOption.java @@ -0,0 +1,26 @@ +/******************************************************************************* + * Copyright (c) 2019 protos software gmbh (http://www.protos.de). + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * CONTRIBUTORS: + * Jan Belle (initial contribution) + * + *******************************************************************************/ + +package org.eclipse.etrice.generator.base.args; + +public class PathOption extends Option<String[]> { + + /** + * @see Option#Option + */ + public PathOption(String group, String name, String argumentName, String description, String[] defaultValue) { + super(String[].class, group, name, argumentName, description, defaultValue); + } + +} diff --git a/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/args/StringArrayOption.java b/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/args/StringArrayOption.java deleted file mode 100644 index 5e09e4f61..000000000 --- a/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/args/StringArrayOption.java +++ /dev/null @@ -1,27 +0,0 @@ -/******************************************************************************* -* Copyright (c) 2018 protos software gmbh (http://www.protos.de). -* All rights reserved. -* -* This program and the accompanying materials are made -* available under the terms of the Eclipse Public License 2.0 -* which is available at https://www.eclipse.org/legal/epl-2.0/ -* -* SPDX-License-Identifier: EPL-2.0 -* -* CONTRIBUTORS: -* Jan Belle (initial contribution) -* - *******************************************************************************/ - -package org.eclipse.etrice.generator.base.args; - -public class StringArrayOption extends Option<String[]> { - - /** - * @see Option#Option - */ - public StringArrayOption(String group, String name, String argumentName, String description, String[] defaultValue) { - super(String[].class, group, name, argumentName, description, defaultValue); - } - -} diff --git a/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/cli/CommandLineParser.java b/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/cli/CommandLineParser.java index 539bfb9f7..9e6e65271 100644 --- a/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/cli/CommandLineParser.java +++ b/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/cli/CommandLineParser.java @@ -15,14 +15,18 @@ package org.eclipse.etrice.generator.base.cli; +import java.io.File; import java.util.LinkedList; import java.util.List; import java.util.ListIterator; import org.eclipse.etrice.generator.base.args.Arguments; +import org.eclipse.etrice.generator.base.args.BooleanOption; +import org.eclipse.etrice.generator.base.args.EnumOption; import org.eclipse.etrice.generator.base.args.Option; import org.eclipse.etrice.generator.base.args.Options; -import org.eclipse.etrice.generator.base.args.StringArrayOption; +import org.eclipse.etrice.generator.base.args.PathOption; +import org.eclipse.etrice.generator.base.args.StringOption; /** * Simple implementation of a command line parser. @@ -39,7 +43,7 @@ public class CommandLineParser implements ICommandLineParser { } @Override - public Arguments parseArgs(Options options, StringArrayOption defaultOption, List<String> args) throws CommandLineParseException { + public Arguments parseArgs(Options options, Option<String[]> defaultOption, List<String> args) throws CommandLineParseException { Arguments parsedArgs = new Arguments(options); List<String> nArgs = normalize(args); ListIterator<String> iterator = nArgs.listIterator(); @@ -81,23 +85,20 @@ public class CommandLineParser implements ICommandLineParser { } private Object parseValue(Option<?> opt, ListIterator<String> iterator) throws CommandLineParseException { - Class<?> type = opt.getType(); - - if(type == Boolean.class) { + if(opt instanceof BooleanOption) { return true; } if(iterator.hasNext()) { String str = iterator.next(); - if(type == String.class) { + if(opt instanceof StringOption) { return str; } - else if(type == String[].class) { - String[] strArray = str.split(";"); - return strArray; + else if(opt instanceof PathOption) { + return str.split(File.pathSeparator); } - else if(type.isEnum()) { + else if(opt instanceof EnumOption<?>) { return parseEnum(opt, str); } diff --git a/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/cli/HelpFormatter.java b/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/cli/HelpFormatter.java index e1aa1fafd..0b578250e 100644 --- a/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/cli/HelpFormatter.java +++ b/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/cli/HelpFormatter.java @@ -19,7 +19,6 @@ import java.util.Formatter; import org.eclipse.etrice.generator.base.args.Option; import org.eclipse.etrice.generator.base.args.Options; -import org.eclipse.etrice.generator.base.args.StringArrayOption; /** * Simple implementation for command line help formatting. @@ -30,7 +29,7 @@ public class HelpFormatter implements IHelpFormatter { } @Override - public String getHelp(String name, Options options, StringArrayOption defaultOption) { + public String getHelp(String name, Options options, Option<String[]> defaultOption) { try(Formatter formatter = new Formatter()) { formatter.format("%s usage: [options] %s...%n", name, defaultOption.getName()); formatter.format("Options:%n"); diff --git a/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/cli/ICommandLineParser.java b/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/cli/ICommandLineParser.java index f3c3759e4..e17b55af1 100644 --- a/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/cli/ICommandLineParser.java +++ b/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/cli/ICommandLineParser.java @@ -19,8 +19,8 @@ import java.util.Arrays; import java.util.List; import org.eclipse.etrice.generator.base.args.Arguments; +import org.eclipse.etrice.generator.base.args.Option; import org.eclipse.etrice.generator.base.args.Options; -import org.eclipse.etrice.generator.base.args.StringArrayOption; import com.google.inject.ImplementedBy; @@ -37,7 +37,7 @@ public interface ICommandLineParser { * @param defaultOption the option for arguments without option identifier * @param args the command line arguments */ - Arguments parseArgs(Options options, StringArrayOption defaultOption, List<String> args) throws CommandLineParseException; + Arguments parseArgs(Options options, Option<String[]> defaultOption, List<String> args) throws CommandLineParseException; /** @@ -47,7 +47,7 @@ public interface ICommandLineParser { * @param defaultOption the option to store arguments without identifier * @param args the command line arguments */ - default Arguments parseArgs(Options options, StringArrayOption defaultOption, String[] args) throws CommandLineParseException { + default Arguments parseArgs(Options options, Option<String[]> defaultOption, String[] args) throws CommandLineParseException { return parseArgs(options, defaultOption, Arrays.asList(args)); } } diff --git a/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/cli/IHelpFormatter.java b/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/cli/IHelpFormatter.java index ac6a5f791..7a8e42bdb 100644 --- a/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/cli/IHelpFormatter.java +++ b/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/cli/IHelpFormatter.java @@ -15,8 +15,8 @@ package org.eclipse.etrice.generator.base.cli; +import org.eclipse.etrice.generator.base.args.Option; import org.eclipse.etrice.generator.base.args.Options; -import org.eclipse.etrice.generator.base.args.StringArrayOption; import com.google.inject.ImplementedBy; @@ -34,6 +34,6 @@ public interface IHelpFormatter { * @param defaultOption the option for arguments without option identifier * @return the help message */ - String getHelp(String name, Options options, StringArrayOption defaultOption); + String getHelp(String name, Options options, Option<String[]> defaultOption); } diff --git a/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/setup/GeneratorApplicationOptions.java b/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/setup/GeneratorApplicationOptions.java index 31e1f0882..4ebb88e0e 100644 --- a/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/setup/GeneratorApplicationOptions.java +++ b/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/setup/GeneratorApplicationOptions.java @@ -21,7 +21,7 @@ import org.eclipse.etrice.generator.base.args.BooleanOption; import org.eclipse.etrice.generator.base.args.EnumOption; import org.eclipse.etrice.generator.base.args.IOptionModule; import org.eclipse.etrice.generator.base.args.Option; -import org.eclipse.etrice.generator.base.args.StringArrayOption; +import org.eclipse.etrice.generator.base.args.PathOption; import org.eclipse.etrice.generator.base.args.StringOption; import org.eclipse.etrice.generator.base.logging.Loglevel; @@ -32,18 +32,19 @@ public class GeneratorApplicationOptions implements IOptionModule { public static final String GROUP_APPLICATION = "application"; - public static final StringArrayOption FILES = new StringArrayOption( + public static final Option<String[]> FILES = new Option<String[]>( + String[].class, GROUP_APPLICATION, "files", "input files", "input files for the generator", new String[0]); - public static final StringArrayOption MODELPATH = new StringArrayOption( + public static final PathOption MODELPATH = new PathOption( GROUP_APPLICATION, "modelpath", "paths", - "model imported paths separated by ';'", + "model import paths separated by path separators", new String[0]); public static final BooleanOption HELP = new BooleanOption( |