intersystems / ipm

InterSystems ObjectScript Package Manager
MIT License
27 stars 19 forks source link

introduce consistency on folder naming from SourceRoot and UnitTest directory #385

Open evshvarov opened 1 year ago

evshvarov commented 1 year ago

Currently we name source root for the Objectscript source code without "/" E.g.

src

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?

isc-tleavitt commented 5 months ago

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.

evshvarov commented 5 months ago

@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:

src

and then Resource tag with Name element for the package:

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

<UnitTestsRoot>tests</UnitTestsRoot>

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

<TestResource> Name="community.csvgen.UnitTests" </TestResource>
evshvarov commented 5 months ago

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>
isc-tleavitt commented 5 months ago

@evshvarov that's fair - reopening.