Acknowledged

Bug: Barrel with several annotations cannot have tests

Have barrel which has two files:

// source/FooConversionWeight.mc 
module Foo {

  (:weight)
  module Conversion {
    module Weight {
      function toLbs(kg) as Double {
        return kg.toDouble() * 2.2046226218488d;
      }
    }
  }
}

// source/FooConversionDistance.mc
module Foo {

  (:dist)
  module Conversion {

    (:dist)
    module Distance {
        function toMiles(dist) {
          return dist.toDouble() * 0.6213711922d;
        }
    }
  }
}

Your barrel includes tests for these functions:

// TestConversionDistance.mc
using Toybox.Test as t;
using Toybox.Lang;
using Foo.Conversion.Distance as dist;

module Foo {

  (:test)
  function testDistance(logger) {

    t.assertMessage(dist.toMiles(1) instanceof Lang.Double, "We converted into a double");
    
    return true;
  }
}

// TestConversionWeight.mc
using Toybox.Test as t;
using Toybox.Lang;
using Foo.Conversion.Weight as w;

module Foo {

  (:test)
  function testWeight(logger) {

    t.assertMessage(w.toLbs(1) instanceof Lang.Double, "We converted into a double");
    
    return true;
  }
}

Your barrel manifest file exports these annotations.

Your consuming project uses this barrel, like so:

Foo = barrels/Foo.barrel
base.Foo.annotations = weight;dist
base.barrelPath = $(base.barrelPath);$(Foo)

Everything works fine and dandy when you run the testsuite.

Now remove one of the annotations from base.Foo.annotations, eg weight and run the testsuite:

Unknown module Foo.Conversion.Weight in using or import clause

The documentation of barrels say that in order to limit what you import you can only import certain annotations of a barrel. However, as soon as you do this the barrel becomes unusable. The testsuite cannot make the distinction that the module that is being used isn't/cannot be imported.

  • We looked into this, and this is by design because when the annotation is removed from the app's jungle, it excludes the corresponding module. To avoid the error, you can do something like this:

    module Foo {
        (:weight)
        module TestWeight {
            using Foo.Conversion.Weight as w;
            (:test)
            function testWeight() {}
        }
    }