Skip to content
Permalink
Browse files

[JENKINS-41124] Confirmed OS-X normalizes to NFC and Linux to NFD

So here is a second test set using NFD names so that if we end up on a magical filesystem that doesn't mess with the name encoding we will cover both variants.

With respect to the issue driving all of this:

- MultiBranch projects already store the name of the branch in unmolested form within the Branch object, so we only need to worry about OrganizationFolder's children.
- There are only two current OrganizationFolder navigators:

    - GitHub which helpfully replaces any non-url safe characters with `-`, so will not be an issue
    - BitBucket which also replaces any non-url safe characters with `-` (but without a tooltip giving advance notice), so will also not be an issue.
  • Loading branch information...
stephenc committed Jan 20, 2017
1 parent b2e6e88 commit ea7eb5d05fb9ad76775f42474be367492a5297dd
@@ -183,6 +183,44 @@ public void evaluate() throws Throwable {
});
}

/**
* Given: a computed folder
* When: upgrading from a version that does not have name mangling to a version that does
* Then: mangling gets applied
*/
@Test
@LocalData // to enable running on e.g. windows, keep the resource path short, so the test name must be short too
public void upgradeNFD() throws Exception {
// The test data was generated using NFD filename encodings... but when unzipping the name can be changed
// to NFC by the filesystem, so we need to check the expected outcome based on the inferred canonical form
// used by the filesystem.
r.addStep(new Statement() {
@Override
public void evaluate() throws Throwable {
TopLevelItem i = r.j.jenkins.getItem("instance");
assertThat("Item loaded from disk", i, instanceOf(ComputedFolderImpl.class));
ComputedFolderImpl instance = (ComputedFolderImpl) i;
checkComputedFolder(instance, 0, ChildNameGeneratorTest.this.inferNormalizerForm());
}
});
r.addStep(new Statement() {
@Override
public void evaluate() throws Throwable {
TopLevelItem i = r.j.jenkins.getItem("instance");
assertThat("Item loaded from disk", i, instanceOf(ComputedFolderImpl.class));
ComputedFolderImpl instance = (ComputedFolderImpl) i;
checkComputedFolder(instance, 0, ChildNameGeneratorTest.this.inferNormalizerForm());
r.j.jenkins.reload();
i = r.j.jenkins.getItem("instance");
assertThat("Item loaded from disk", i, instanceOf(ComputedFolderImpl.class));
instance = (ComputedFolderImpl) i;
checkComputedFolder(instance, 0, ChildNameGeneratorTest.this.inferNormalizerForm());
instance.doReload();
checkComputedFolder(instance, 0, ChildNameGeneratorTest.this.inferNormalizerForm());
}
});
}

private void checkComputedFolder(ComputedFolderImpl instance, int round, Normalizer.Form form) throws IOException {
assertThat("We detected the filesystem normalization form", form, notNullValue());
instance.assertItemNames(round,
Binary file not shown.

0 comments on commit ea7eb5d

Please sign in to comment.
You can’t perform that action at this time.