mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-05 01:50:56 +07:00
PY-27500: For tox, environment should go first.
This is how it was: tox [arguments] -e py27 It worked for all cases except tox -- args-for-env -e py27 This is how it works now tox -e py27 [arguments]
This commit is contained in:
@@ -116,11 +116,11 @@ public final class PyToxConfiguration extends AbstractPythonTestRunConfiguration
|
||||
|
||||
@Override
|
||||
public void addTestSpecsAsParameters(@NotNull final ParamsGroup paramsGroup, @NotNull final List<String> testSpecs) {
|
||||
if (myArguments != null) {
|
||||
paramsGroup.addParameters(myArguments);
|
||||
}
|
||||
if (!testSpecs.isEmpty()) {
|
||||
paramsGroup.addParameter(String.format("-e %s", StringUtil.join(testSpecs, ",")));
|
||||
}
|
||||
if (myArguments != null) {
|
||||
paramsGroup.addParameters(myArguments);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
6
python/testData/toxtest/toxDoubleDash/tox.ini
Normal file
6
python/testData/toxtest/toxDoubleDash/tox.ini
Normal file
@@ -0,0 +1,6 @@
|
||||
[tox]
|
||||
skipsdist=True
|
||||
envlist = py27, py35
|
||||
[testenv]
|
||||
deps=pytest
|
||||
commands=pytest {posargs:DEFAULTS}
|
||||
76
python/testSrc/com/jetbrains/env/PyToxTest.java
vendored
76
python/testSrc/com/jetbrains/env/PyToxTest.java
vendored
@@ -208,21 +208,15 @@ public final class PyToxTest extends PyEnvTestCase {
|
||||
@NotNull
|
||||
@Override
|
||||
protected PyAbstractTestProcessRunner<PyToxConfiguration> createProcessRunner() {
|
||||
return new PyAbstractTestProcessRunner<PyToxConfiguration>(PyToxConfigurationFactory.INSTANCE, PyToxConfiguration.class, 0) {
|
||||
@Override
|
||||
protected void configurationCreatedAndWillLaunch(@NotNull final PyToxConfiguration configuration) throws IOException {
|
||||
super.configurationCreatedAndWillLaunch(configuration);
|
||||
PyToxTestTools.setArguments(configuration, "-v");
|
||||
PyToxTestTools.setRunOnlyEnvs(configuration, envsToRun);
|
||||
}
|
||||
};
|
||||
return new RunnerWithArguments(envsToRun, "-v");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkTestResults(@NotNull final PyAbstractTestProcessRunner<PyToxConfiguration> runner,
|
||||
@NotNull final String stdout,
|
||||
@NotNull final String stderr,
|
||||
@NotNull final String all, int exitCode) {
|
||||
@NotNull final String all,
|
||||
final int exitCode) {
|
||||
final Set<String> environments = runner.getTestProxy().getChildren().stream().map(t -> t.getName()).collect(Collectors.toSet());
|
||||
assertThat(environments)
|
||||
.describedAs("Wrong environments launched")
|
||||
@@ -238,6 +232,42 @@ public final class PyToxTest extends PyEnvTestCase {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide certain env and check it is launched
|
||||
*/
|
||||
@Test
|
||||
public void testDoubleDash() {
|
||||
runPythonTest(
|
||||
new PyProcessWithConsoleTestTask<PyAbstractTestProcessRunner<PyToxConfiguration>>("/toxtest/toxDoubleDash/",
|
||||
SdkCreationType.EMPTY_SDK) {
|
||||
@NotNull
|
||||
@Override
|
||||
protected PyAbstractTestProcessRunner<PyToxConfiguration> createProcessRunner() {
|
||||
return new RunnerWithArguments(new String[]{"py27"}, "--", "--version");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkTestResults(@NotNull final PyAbstractTestProcessRunner<PyToxConfiguration> runner,
|
||||
@NotNull final String stdout,
|
||||
@NotNull final String stderr,
|
||||
@NotNull final String all,
|
||||
final int exitCode) {
|
||||
Assert.assertThat("Pytest should provide version because of --version", runner.getAllConsoleText(),
|
||||
Matchers.containsString("This is pytest version"));
|
||||
Assert.assertEquals("Only 2.7 should be launched", "Test tree:\n" +
|
||||
"[root]\n" +
|
||||
".py27(+)\n", runner.getFormattedTestTree());
|
||||
runner.getFormattedTestTree();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<String> getTags() {
|
||||
return Sets.newHashSet("tox");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private static final class MyPyProcessWithConsoleTestTask extends PyProcessWithConsoleTestTask<MyTestProcessRunner> {
|
||||
private static final Logger LOGGER = Logger.getInstance(MyPyProcessWithConsoleTestTask.class);
|
||||
@@ -277,11 +307,11 @@ public final class PyToxTest extends PyEnvTestCase {
|
||||
|
||||
final Set<String> expectedInterpreters =
|
||||
myInterpreters.entrySet().stream()
|
||||
.filter(intAndExp -> intAndExp.getValue() != null)
|
||||
.filter(o -> o.getValue().myUntilStep >
|
||||
runner.getCurrentRerunStep()) // Remove interp. which shouldn't be launched on this step
|
||||
.map(intAndExp -> intAndExp.getKey())
|
||||
.collect(Collectors.toSet());
|
||||
.filter(intAndExp -> intAndExp.getValue() != null)
|
||||
.filter(o -> o.getValue().myUntilStep >
|
||||
runner.getCurrentRerunStep()) // Remove interp. which shouldn't be launched on this step
|
||||
.map(intAndExp -> intAndExp.getKey())
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
// Interpreters are used in tox.ini, so there should be such text
|
||||
for (final String interpreterName : expectedInterpreters) {
|
||||
@@ -461,4 +491,22 @@ public final class PyToxTest extends PyEnvTestCase {
|
||||
this(expectedOutput, expectedSuccess, Integer.MAX_VALUE);
|
||||
}
|
||||
}
|
||||
|
||||
private static class RunnerWithArguments extends PyAbstractTestProcessRunner<PyToxConfiguration> {
|
||||
private final String[] myEnvsToRun;
|
||||
private final String[] myArgs;
|
||||
|
||||
RunnerWithArguments(@NotNull final String[] envsToRun, @NotNull final String... args) {
|
||||
super(PyToxConfigurationFactory.INSTANCE, PyToxConfiguration.class, 0);
|
||||
myEnvsToRun = envsToRun;
|
||||
myArgs = args;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configurationCreatedAndWillLaunch(@NotNull final PyToxConfiguration configuration) throws IOException {
|
||||
super.configurationCreatedAndWillLaunch(configuration);
|
||||
PyToxTestTools.setArguments(configuration, myArgs);
|
||||
PyToxTestTools.setRunOnlyEnvs(configuration, myEnvsToRun);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user