Changeset 18776 in josm


Ignore:
Timestamp:
2023-07-10T22:19:01+02:00 (17 months ago)
Author:
taylor.smock
Message:

See #23049, fix an issue where tests might visit the entire dataset during upload

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/upload/ValidateUploadHook.java

    r18775 r18776  
    1515import org.openstreetmap.josm.data.APIDataSet;
    1616import org.openstreetmap.josm.data.osm.OsmPrimitive;
    17 import org.openstreetmap.josm.data.preferences.sources.ValidatorPrefHelper;
    1817import org.openstreetmap.josm.data.validation.OsmValidator;
    19 import org.openstreetmap.josm.data.validation.Severity;
    2018import org.openstreetmap.josm.data.validation.TestError;
    2119import org.openstreetmap.josm.data.validation.ValidationTask;
     
    5351        OsmValidator.initializeTests();
    5452        new ValidationTask(errors -> {
    55             if (!Boolean.TRUE.equals(ValidatorPrefHelper.PREF_OTHER_UPLOAD.get())) {
    56                 // Use >= just in case we add additional levels.
    57                 errors.removeIf(error -> error.getSeverity().getLevel() >= Severity.OTHER.getLevel());
    58             }
    5953            if (errors.stream().allMatch(TestError::isIgnored)) {
    6054                returnCode.set(true);
  • trunk/src/org/openstreetmap/josm/data/validation/ValidationTask.java

    r18752 r18776  
    108108        }
    109109        if (this.onFinish != null) {
     110            // Remove any low severity issues if they are not desired.
     111            if (!(Boolean.TRUE.equals(ValidatorPrefHelper.PREF_OTHER.get()) &&
     112                    (!this.beforeUpload || Boolean.TRUE.equals(ValidatorPrefHelper.PREF_OTHER_UPLOAD.get())))) {
     113                // Use >= just in case we add additional levels.
     114                this.errors.removeIf(error -> error.getSeverity().getLevel() >= Severity.OTHER.getLevel());
     115            }
    110116            this.onFinish.accept(this.errors);
    111117        }
     
    125131            getProgressMonitor().setCustomText(tr("Test {0}/{1}: Starting {2}", testCounter, tests.size(), test.getName()));
    126132            test.setBeforeUpload(this.beforeUpload);
    127             test.setPartialSelection(formerValidatedPrimitives != null);
     133            // Pre-upload checks only run on a partial selection.
     134            test.setPartialSelection(this.beforeUpload || formerValidatedPrimitives != null);
    128135            test.startTest(getProgressMonitor().createSubTaskMonitor(validatedPrimitives.size(), false));
    129136            test.visit(validatedPrimitives);
  • trunk/test/unit/org/openstreetmap/josm/actions/upload/ValidateUploadHookTest.java

    r18775 r18776  
    66
    77import java.util.Collections;
     8import java.util.stream.Stream;
    89
    910import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     
    1213import org.junit.jupiter.api.extension.RegisterExtension;
    1314import org.junit.jupiter.params.ParameterizedTest;
    14 import org.junit.jupiter.params.provider.ValueSource;
     15import org.junit.jupiter.params.provider.Arguments;
     16import org.junit.jupiter.params.provider.MethodSource;
    1517import org.openstreetmap.josm.TestUtils;
    1618import org.openstreetmap.josm.data.APIDataSet;
     
    4850    }
    4951
     52    static Stream<Arguments> testUploadOtherErrors() {
     53        return Stream.of(
     54                Arguments.of(true, true),
     55                Arguments.of(true, false),
     56                Arguments.of(false, false),
     57                Arguments.of(false, true)
     58        );
     59    }
     60
    5061    @ParameterizedTest
    51     @ValueSource(booleans = {true, false})
    52     void testUploadOtherErrors(boolean otherEnabled) {
    53         ValidatorPrefHelper.PREF_OTHER_UPLOAD.put(otherEnabled);
     62    @MethodSource
     63    void testUploadOtherErrors(boolean otherUploadEnabled, boolean otherEnabled) {
     64        ValidatorPrefHelper.PREF_OTHER.put(otherEnabled);
     65        ValidatorPrefHelper.PREF_OTHER_UPLOAD.put(otherUploadEnabled);
    5466        final DataSet ds = new DataSet();
    5567        final Way building = TestUtils.newWay("building=yes", new Node(new LatLon(33.2287665, -111.8259225)),
     
    7486                };
    7587        new ValidateUploadHook().checkUpload(new APIDataSet(ds));
    76         assertEquals(!otherEnabled, mocker.getInvocationLog().isEmpty());
     88        assertEquals(!(otherEnabled && otherUploadEnabled), mocker.getInvocationLog().isEmpty());
    7789    }
    7890}
Note: See TracChangeset for help on using the changeset viewer.