ipm icon indicating copy to clipboard operation
ipm copied to clipboard

introduce consistency on folder naming from SourceRoot and UnitTest directory

Open evshvarov opened this issue 2 years ago • 4 comments
trafficstars

Currently we name source root for the Objectscript source code without "/" E.g. <SourcesRoot>src</SourcesRoot>

But the directory for unit-tests should be indicated with "/", .e.g.

Could we support both "/tests" and "tests" notation for folder naming for unittests?

evshvarov avatar May 03 '23 11:05 evshvarov

From a resource naming perspective, there's a lot of meaning (and dependencies in code) where a name starting with "/" indicates something on the filesystem and a name that doesn't indicates something in the database (e.g., a class/package/routine/%Studio.AbstractDocument). I believe this distinction is important and worth maintaining. SourcesRoot is a different context so the inconsistency does not bother me too much.

isc-tleavitt avatar Mar 15 '24 15:03 isc-tleavitt

@isc-tleavitt - I think this needs more consistency. Technically unittests and code resources are the same classes and packages. But the way we ask developers to describe unittests resources is just different. E.g. see the following module XML:

<?xml version="1.0" encoding="UTF-8"?>
<Export generator="Cache" version="25">
  <Document name="csvgen.ZPM">
    <Module>
      <Name>csvgen</Name>
      <Version>1.5.1</Version>
      <Description>Module to generate import and export csv data using InterSystems ObjectScript</Description>
      <Packaging>module</Packaging>
      <SourcesRoot>src</SourcesRoot>
      <Resource Name="community.PKG"/>
      <UnitTest Name="/tests" Package="community.csvgen.UnitTests" Phase="test"/>
    </Module>

  </Document>
</Export>

For the source code we have SourcesRoot path where we can expect resources: <SourcesRoot>src</SourcesRoot> and then Resource tag with Name element for the package: <Resource Name="community.PKG"/>

For the unit tests the path starts with "/" which is different to SourceRoot notation where leading "/" is not needed. I'd suggest we introduce <UnitTestsRoot> tag to point to the folder with unit tests source code, e.g.:

<UnitTestsRoot>tests</UnitTestsRoot>

And <TestResource> tag to list unittest code resources. E.g in this case:

<TestResource> Name="community.csvgen.UnitTests" </TestResource>

evshvarov avatar Mar 16 '24 13:03 evshvarov

So the final module.xml will be in this case:

<?xml version="1.0" encoding="UTF-8"?>
<Export generator="Cache" version="25">
  <Document name="csvgen.ZPM">
    <Module>
      <Name>csvgen</Name>
      <Version>1.5.1</Version>
      <Description>Module to generate import and export csv data using InterSystems ObjectScript</Description>
      <Packaging>module</Packaging>
      <SourcesRoot>src</SourcesRoot>
      <Resource Name="community.PKG"/>
      <UnitTestsRoot>tests</UnitTestsRoot>
      <TestResource Name="community.csvgen.UnitTests" Phase="test"/>
    </Module>

  </Document>
</Export>

evshvarov avatar Mar 16 '24 13:03 evshvarov

@evshvarov that's fair - reopening.

isc-tleavitt avatar Mar 18 '24 15:03 isc-tleavitt