Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Only buildable tests #7829

Draft
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

gelisam
Copy link
Collaborator

@gelisam gelisam commented Nov 21, 2021

As requested, I am trying to implement an --only-buildable-tests flag whose behaviour matches the default behaviour when neither --enable-tests nor --disable-tests is specified.

This PR is a WIP, as I am still at the beginning of my investigation. So far, I have only added a test which exercises the current behaviour, and I have slightly tweaked how --enable-tests and --disable-tests are parsed (which slightly affects the --help output). Still, my impression is that cabal is a complex and fragile beast, so I would like to make sure that this small change hasn't already broken something. I am thus following the recommendation and opening a WIP PR to get the tests to run.


Please include the following checklist in your PR:

Please also shortly describe how you tested your change. Bonus points for added tests!

I plan to add an explicit --only-buildable-tests flag, and then to add a
test for it. I will do so by adding a case to this test, which currently
tests the two other flags, --enable-tests and --disable-tests, as well
as the default behaviour.
boolOpt only supports --enable-tests and --disable-tests, and I want to
add --only-buildable-tests, so I need to switch to multiOption. I have
not added the third option yet, I want to begin by making sure I haven't
broken anything yet.
@gelisam
Copy link
Collaborator Author

gelisam commented Nov 21, 2021

As I had feared, this seemingly no-op change did manage to break several tests.

First, UnitTests.Distribution.Client.Configure has a few broken tests which say that True cannot be parsed, presumably because a boolOpt has an obvious way to parse boolean values from config files but a multiOption needs more effort. I'm thinking of using EnableAll, DisableAll, and OnlyBuildable, with True and False being synonyms for the first two, for backwards compatibility.

@gelisam
Copy link
Collaborator Author

gelisam commented Nov 21, 2021

Second, UnitTests.Distribution.Client.ProjectConfig's ProjectConfig printing/parsing round trip test fails (as do its other related tests) because Flag False round trips to NoFlag. Seems related, but why is the parsing succeeding with NoFlag this time instead of failing with a parse error? Maybe unparseable fields are ignored, and so we are left with the default value NoFlag?

@Mikolaj
Copy link
Member

Mikolaj commented Nov 22, 2021

Edit: all this is wrong and stems from my confusion about the current behaviour, due to me having tests: False in cabal.project.local. Please kindly move along down the discussion where @gelisam explains how this really works.

.

.

Let me clarify for people viewing this PR, the idea is to make --enable-tests the default, but then we need a flag that corresponds to the current behaviour (--only-buildable-tests; edit: or to a completely new behaviour, to be clarified futher), so that the rare cases failing with --enable-tests can be handled by --only-buildable-tests [edit: this part was wrong: and tests: True in cabal.project*]. Did I get that right?

No idea about the failing tests. Feel free to ignore and/or redo them until we get reviewers that know what's going on.

Edit2: and perhaps --only-buildable-tests should be the new default, depending what the clarified semantics of that turns out to be.

@gelisam
Copy link
Collaborator Author

gelisam commented Nov 22, 2021

the idea is to make --enable-tests the default, but then we need a flag that corresponds to the current behaviour (--only-buildable-tests), so that the rare cases failing with --enable-tests can be handled by --only-buildable-tests

I was not planning to change the default, but sure, that sounds like a good default!

by --only-buildable-tests and tests: True in cabal.project*.

Currently, --enable-tests is the same as tests: True, --disable-tests is the same as tests: False, and not specifying either flag is the same as not specifying a tests setting. I was thus planning to continue this 1-to-1 equivalence, by adding an --only-buildable-tests which would be equivalent to specifying tests: OnlyBuildable.

I don't quite understand the semantics of what you are proposing instead. Would there be an only-buildable-tests: True setting as well, so that the current behavior can be obtained either by specifying both --enable-tests and --only-buildable-tests, or both tests: True and only-buildable-tests: True, or an equivalent combination? What would the tests: False; only-buildable-tests: True combination mean?

@gelisam
Copy link
Collaborator Author

gelisam commented Nov 22, 2021

No idea about the failing tests. Feel free to ignore and/or redo them until we get reviewers that know what's going on.

I'm not blocked, just thinking out loud. I'm working on fixing the tests.

@Mikolaj
Copy link
Member

Mikolaj commented Nov 22, 2021

Currently, --enable-tests is the same as tests: True, --disable-tests is the same as tests: False, and not specifying either flag is the same as not specifying a tests setting. I was thus planning to continue this 1-to-1 equivalence, by adding an --only-buildable-tests which would be equivalent to specifying tests: OnlyBuildable.

Oh, sure, 1-1 is actually better. I didn't know this can be that simple. Please ignore my overcomplicated version.

BTW, it would be great to add tests of cabal invocations that succeed with --only-buildable-tests and then run the same tests with each of the old flags and see them fail, just to demonstrate that the new flag is not useless.

@gelisam
Copy link
Collaborator Author

gelisam commented Nov 22, 2021

BTW, it would be great to add tests of cabal invocations that succeed with --only-buildable-tests and then run the same tests with each of the old flags and see them fail, just to demonstrate that the new flag is not useless.

Isn't that what the test I've already added already does?

@Mikolaj
Copy link
Member

Mikolaj commented Nov 22, 2021

I think my confusion stems from this comment: #5079 (comment)

I think the third option that @phadej asks for is not just simply the current default behaviour (which is to solve for no tests at all) but it's a behaviour that would be best to have as the default for cabal test in the future, namely to solve for as much tests as possible, but don't insist (and sometimes fail) to build all (and --enable-tests does). Do I get this right this time?

@gelisam
Copy link
Collaborator Author

gelisam commented Nov 22, 2021

the third option that @phadej asks for is not just simply the current default behaviour (which is to solve for no tests at all)

Okay, that really is the crux of the confusion then. I do think that the third option is the same as the current default behavior, and I do think that the current default behavior is to try to find a solution which includes tests, and if that can't be done, to look for a solution which does not include the tests. In fact, that's what my test demonstrates: with no arguments, cabal test successfully solves for, builds, and runs buildable-test, and it does not run nor build unbuildable-test, because it cannot find a build plan which includes it.

Meanwhile, cabal --enable-tests fails because we are asking to run all the tests but a plan which includes both tests cannot be found. And cabal --disable-tests also fails, because the build plan includes zero tests, and because cabal test chooses to error out when it is suspiciously asked to run zero tests.

@Mikolaj
Copy link
Member

Mikolaj commented Nov 22, 2021

I'm afraid @andreasabel and other people in that ticket report otherwise: #5079 (comment)

Perhaps that's because you report what Cabal's Setup interface does, while we mean cabal v2-test? They do a different thing, IIRC.

@Mikolaj
Copy link
Member

Mikolaj commented Nov 22, 2021

Hmm, but your test indeed behaves as you claim, which is completely contrary to my experience.

Edit: ok, I take my claims back: I was just runing with "tests: False" in my cabal.project.

@Mikolaj
Copy link
Member

Mikolaj commented Nov 22, 2021

I now think, probably all people surprised by the cabal test behaviour had tests: False specified somewhere. Indeed, if we can change the default in cabal.project and wherever else (also in .cabal/config?) to tests: OnlyBuildable or whatever it's called, that can be the best of both worlds.

Edit: Would that new flag, when used in cabal build solve for tests, but not build them? I think people, having only choice of True or False, choose False to avoid cabal build taking much longer by building and linking tests, and then they have problems when they run cabal test. If tests: OnlyBuildable did not build tests with cabal build, but solved, built and ran tests with cabal test that would be great,

Edit: and then I think this new flag is the ideal default in all places (instead of False and True; I have no idea if any tool, e.g., cabal init or cabal update puts it anywhere; we'd need to check).

@gelisam
Copy link
Collaborator Author

gelisam commented Nov 22, 2021

Would that new flag, when used in cabal build solve for tests, but not build them?

Yes. My understanding is that "the new flag" (that is, the current default behavior) causes the solver to pick a plan which may include some tests and exclude others. Which of the included targets are built and/or ran depends on the command:

  • cabal build defaults to cabal build all, which means "all libs and all executables", so cabal build does not build the tests.
    Edit: this is incorrect, cabal build defaults to building the libs and executables for the current directory, not for all the .cabal files in the current project.
  • cabal build *:test:* builds all the tests, but it does not run them. Libraries and executables are not built either unless they are dependencies of those tests.
    Edit: the correct syntax is cabal build all:tests.
  • cabal test runs all the included tests, and thus also builds them first.

@Mikolaj
Copy link
Member

Mikolaj commented Nov 22, 2021

This is perfection. I didn't even know this is possible.

Edit: I checked and the default .cabal/config does not set tests to either True or False. So we still need to check that cabal init doesn't do that and that our tutorials don't recommend either True or False. Then, over time, people would remove tests: False from their private project files, and the complaints about cabal test failing without --enable-tests should die out.

Edit: Oh, and the hint that is displayed when cabal test failes should suggest tests: OnlyBuildable instead of the current tests: True. Generally, we'll need to do git grep -i "tests:".

Edit2: heh, even the main project files in the cabal repo have tests: False.

@gelisam
Copy link
Collaborator Author

gelisam commented Nov 23, 2021

Oh, and the hint that is displayed when cabal test fails should suggest tests: OnlyBuildable instead of the current tests: True.

Are you sure? If people set tests: OnlyBuildable and their test is not buildable, the build plan will not include the non-buildable test. When they run cabal test, there will be zero tests to run, and so they will still get that hint. The hint will be misleading, because they already have tests: OnlyBuildable. In that case though, cabal test --enable-tests will not succeed either, because the test is not buildable.

Thinking about this further, I suspect that even in the case in which people do not explicitly set tests: False, it might still be possible to get the situation in which cabal test fails but cabal test --enable-tests succeeds. I think Cabal's algorithm is more complex than depth-first search, in which case maybe Cabal can end up picking a build plan which does not include a test even though there exists one. Perhaps it's more like breadth-first search, and a build plan A which does not include the tests happen to be encountered earlier than a plan B which does include them, and so cabal test fails because plan A does not include the tests, while cabal test --enable-tests succeeds because plan A is not available and so Cabal is forced to continue searching until it finds plan B.

Generally, we'll need to do git grep -i "tests:".

I don't follow this bit. Surely cabal should not assume that it is ran from inside a git repo? And why are we grepping for tests:? cabal knows whether tests is set or not.

@Mikolaj
Copy link
Member

Mikolaj commented Nov 23, 2021

Oh, and the hint that is displayed when cabal test fails should suggest tests: OnlyBuildable instead of the current tests: True.

Are you sure? If people set tests: OnlyBuildable and their test is not buildable, the build plan will not include the non-buildable test. When they run cabal test, there will be zero tests to run, and so they will still get that hint. The hint will be misleading, because they already have tests: OnlyBuildable. In that case though, cabal test --enable-tests will not succeed either, because the test is not buildable.

And cabal test --enable-tests is equivalent to tests: True? If that's the case, then the currently present hint, advising to add tests: True already has this problem, so we are not making things worse, only better (people using the new hint won't have their tests built by cabal build and so won't be tempted to set tests: False).

Thinking about this further, I suspect that even in the case in which people do not explicitly set tests: False, it might still be possible to get the situation in which cabal test fails but cabal test --enable-tests succeeds. I think Cabal's algorithm is more complex than depth-first search, in which case maybe Cabal can end up picking a build plan which does not include a test even though there exists one. Perhaps it's more like breadth-first search, and a build plan A which does not include the tests happen to be encountered earlier than a plan B which does include them, and so cabal test fails because plan A does not include the tests, while cabal test --enable-tests succeeds because plan A is not available and so Cabal is forced to continue searching until it finds plan B.

Oh, that's a shame. If that's true, indeed we can't modify the hint.

Generally, we'll need to do git grep -i "tests:".

I don't follow this bit. Surely cabal should not assume that it is ran from inside a git repo? And why are we grepping for tests:? cabal knows whether tests is set or not.

I mean, 'we' as developers changing that code, not 'we' as 'cabal when it's running'. I was speaking in the context of tests: True either advised or automatically added, so this grep would let us (the developers) see this in our repo and correct.

@gelisam
Copy link
Collaborator Author

gelisam commented Nov 23, 2021

Should we maybe schedule a call? I feel like we're really struggling to communicate in this thread.

And cabal test --enable-tests is equivalent to tests: True?

Yes.

then the currently present hint, advising to add tests: True already has this problem

Depends what you mean by "this problem"! In the case in which a test is not buildable, the current hint does not have the problem that it is misleading, because setting tests: True does allow the user to make forward progress. Without a tests entry, their tests are mysteriously excluded from the build plan and they cannot even try to build it. With tests: True, the user now sees the source of the error: cabal test says it cannot find a build plan.

The current hint does have the problem that its suggestion is insufficient to completely solve the problem, as running cabal test still fails after setting tests: True, it merely fails with a different error message. Perhaps the hint should instead say "set tests: True and fix the version bounds so that a build plan which includes the tests can be found"?

@Mikolaj
Copy link
Member

Mikolaj commented Nov 23, 2021

Should we maybe schedule a call? I feel like we're really struggling to communicate in this thread.

With pleasure. However, this is more a sequential string of my misunderstandings than a block that can be dealt with in one go. And each past case is clarified as far as I'm concerned.

The current hint does have the problem that its suggestion is insufficient to completely solve the problem, as running cabal test still fails after setting tests: True, it merely fails with a different error message. Perhaps the hint should instead say "set tests: True and fix the version bounds so that a build plan which includes the tests can be found"?

Yes, agreed, this also makes it more likely the user will looks closer at the error message with tests: True instead of assuming it's as unhelpful as the previous message without. It wouldn't also hurt to prefix with "To debug this problem, set ..." to make sure tests: True is not considered a permanent solution (and, after a period of suffering from longer builds, switched to equally wrong tests: False).

Edit: and renaming True to something else will also help to prevent the reflexive tests: False that subsequently makes people frustrated that cabal test doesn't work.

@gelisam
Copy link
Collaborator Author

gelisam commented Nov 23, 2021

All right, back to thinking out loud about the failing tests.

There seems to be two related problems. The first problem is that the setting packageConfigTests = Flag True is now pretty-printed as "tests: enable-tests" instead of "tests: True". The parser expects enable-tests, and thus barfs on True.

The second problem is that the setting packageConfigTests = Flag False is now pretty-printed as "", presumably because something thinks False is the default, but "" gets parsed to NoFlag, not Flag False, thus causing the round-trip to fail.

...and the synonyms second. The first listed option is the one used in
the "--help" text.
@gelisam
Copy link
Collaborator Author

gelisam commented Nov 25, 2021

I explored an alley that turned out to be a dead end.

It is possible to give multiple synonyms for a command-line flag. I am already using this feature to allow --enable-test as a synonym for --enable-tests. I thus tried to add --True as a silly synonym for --enable-tests, so that tests: enable-tests, tests: enable-test, and tests: True can all be accepted in the configuration file. Unfortunately, that doesn't work, as the first entry in the synonym list is treated specially. First, it is the entry which is used in the --help output, so I should definitely put enable-tests first. Second, it is the only entry which is allowed in configuration files. So in order to allow tests: True, I'd have to list True first, which would make --True appear in the --help output instead of --enable-tests, which would be silly.

That is, the "tests" and "benchmark" settings.

I still want to recognize "tests: True", but the setting is no longer a
boolean, so "tests: EnableAll" is the new preferred way to specify that
we want to enable all the tests.
@gelisam
Copy link
Collaborator Author

gelisam commented Nov 27, 2021

I wrote a custom parser for the tests and benchmarks settings, so I can accept both tests: True and tests: EnableAll. Unfortunately, the other problem remains: False is still being pretty-printed as "", which in turns gets parsed to NoFlag instead of Flag False.

@gelisam
Copy link
Collaborator Author

gelisam commented Nov 27, 2021

Very strange, it's the parse error on True which remains, while the roundtrip error on False has disappeared! I expected the opposite, since I only fixed the parser.

@gelisam
Copy link
Collaborator Author

gelisam commented Nov 27, 2021

Ah, I know why the roundtrip error on False disappeared! I didn't just write a customized parser, I also wrote a customized pretty-printer. The bug was in the pretty-printer: it was pretty-printing Flag False to "" instead of to "tests: False". The old and new parsers both parse "" to NoFlag, and that's the correct behavior.

@gelisam
Copy link
Collaborator Author

gelisam commented Nov 28, 2021

And the reason why the parse error on True still happens is because I've only tweaked the parser used by parseLegacyProjectConfig, but I haven't yet tweaked the parser used by parseConfig. That's because I didn't think there was also a non-legacy version! I was misled by the following comment:

-- | We already have parsers\/pretty-printers for almost all the fields in the
-- project config file, but they're in terms of the types used for the command
-- line flags for Setup.hs or cabal commands. We don't want to redefine them
-- all, at least not yet so for the moment we use the parsers at the old types
-- and use conversion functions.
--
-- Ultimately if\/when this project-based approach becomes the default then we
-- can redefine the parsers directly for the new types.

That comment is simply saying that the parser for tests: True is derived from the parser for --enable-tests. The comment is apologetic, but to avoid duplication, I think that's a good idea.

What misled me is that the comment is right above the LegacyProjectConfig datatype definition, so I thought the comment was explaining why LegacyProjectConfig was needed. I thought it said that LegacyProjectConfig has parsers but ProjectConfig doesn't, which is why we still use LegacyProjectConfig. This is not the case: parseLegacyProjectConfig and parseConfig both derive their parsers from the same list of command-line options, and then perform a different set of tweaks on top of that (which is why I now need to make my tweak a second time).

Given this, would it make sense to move that comment somewhere else, perhaps closer to parseConfig? Then parseLegacyProjectConfig could have a shorter comment saying it uses the same reuse strategy as parseConfig, but has its own distinct set of tweaks.

@Mikolaj
Copy link
Member

Mikolaj commented Nov 29, 2021

Definitely, please amend and extend the comments as needed to prevent the misunderstanding it caused you.

I was confused by the placement of a comment, which seemed to explain
why we need 'LegacyProjectConfig' but was in fact explaining how the
parsers and pretty-printers for the 'ProjectConfig' configuration file
was derived from the descriptions of several command-line options.

I was also confused because I didn't realize that there were multiple
configuration files, each with their own set of overrides for the fields
derived from those command-line options.

I am thus attempting to improve the comments by explaining which
configuration file each type is for, explaining the trick of deriving
fields from options and then overriding some of the fields, and
cross-linking between the two places where that trick is used, to remind
contributors to edit both places if applicable.
That is, the "tests" and "benchmark" settings.

I previously added a custom parser for the 'cabal.project.local' file,
this commit also adds an identical parser for the '~/.cabal/config'
file.
@gelisam
Copy link
Collaborator Author

gelisam commented Dec 1, 2021

All right, I have tweaked the comments (please let me know if you agree it is an improvement!) and I have added the missing parser. I hope the tests are passing this time!

the previous commit message said I added a custom parser for both
"tests" and "benchmarks", but that was a lie.
@gelisam
Copy link
Collaborator Author

gelisam commented Dec 2, 2021

They do pass, hurray! Now I can move on to actual feature: adding an --only-buildable-tests flag.

Now that I am familiar with the way in which flags and options work, I know that the easiest way to implement this would be to parse --only-buildable-tests as NoFlag. However, it would probably be clearer and more useful if I instead defined a custom sum type, data EnableStanza = OnlyBuildable | EnableAll | DisableAll, right?

Since this flag selects the default behaviour, we can simply parse it to
'NoFlag', right?

Unfortunately, this doesn't quite work: if 'tests: EnableAll' is
specified in '~/.cabal/config' or 'cabal.project.config', specifying
'--only-buildable-tests' on the command-line will not override the
setting.
@gelisam
Copy link
Collaborator Author

gelisam commented Dec 2, 2021

I keep calling them "stanza", but it should be "component type". If a package provides a library and two tests, that's three stanzas (or three components): the library, the first test, and the second test. But it's only two component types: libraries and tests. Each of the tests and benchmarks setting is about a particular component type, not about a particular stanza/component.

@gelisam
Copy link
Collaborator Author

gelisam commented Dec 2, 2021

Darn, "OnlyBuildable" might also be an incorrect name! I found this comment which gives a different definition for "buildable" in Cabal:

-- A component is __buildable__ if, after resolving flags and
-- conditionals, there is no @buildable: False@ property in it.
-- This is a /static/ property that arises from the
-- Cabal file and the package description flattening; once we have
-- a 'PackageDescription' buildability is known.

Whereas what we mean is whether a build plan which includes that component type can be found. "OnlyPlannable"? "IfPossible"?

@gelisam
Copy link
Collaborator Author

gelisam commented Dec 2, 2021

This other comment explains that --enable-tests is also poorly-named, because it actually requests the test, it does not enable them. Now that I know there is a distinction between the internal nomenclature and the user-facing nomenclature, maybe OnlyBuildable isn't too bad?

-- The flag name (@--enable-tests@) is a
-- little bit of a misnomer, because
-- just passing this flag won't
-- "enable", in our internal
-- nomenclature; it's just a request; a
-- @buildable: False@ might make it
-- not possible to enable.

@Mikolaj
Copy link
Member

Mikolaj commented Dec 3, 2021

Actually, OnlyBuildable did manage to confuse me at some point, due to the buildable field you can have in .cabal components. I'm as bad at naming as any nerd, but I like "IfPossible", except that it looks a bit like a starting keyword of a conditionsl. Perhaps "WhenPossible", "WheneverPossible", "WhenPlanPossible", "WhenPlanExists"?

@gelisam
Copy link
Collaborator Author

gelisam commented Dec 3, 2021

Thanks for the suggestions! How about --enable-tests-when-possible and tests: EnableWhenPossible?

@Mikolaj
Copy link
Member

Mikolaj commented Dec 3, 2021

Not bad. What would be the names for the other modes?

@gelisam
Copy link
Collaborator Author

gelisam commented Dec 3, 2021

  • --enable-tests / tests: EnableAll or tests: True for backwards compatibility
  • --disable-tests / tests: DisableAll or tests: False for backwards compatibility

@Mikolaj
Copy link
Member

Mikolaj commented Dec 3, 2021

I see, so EnableWhenPossible for each test, enables it, when possible, while EnableAll force-enables all tests. We could spend a few more days on that, but I think this is good enough, hints broadly enough and prevents too simple assumptions. Documentation will tell the whole story. which is too large to be contained in the names alone.

...to "--enable-tests-when-possible". No version of cabal-install in
which the "--only-buildable-tests" name exists, I'm still in the process
of implementing that feature and I simply changed my mind as to what it
should be called.
configTests and configBenchmarks now have three possible values instead
of the previous two ('True' and 'False'), to reflect the fact that not
specifying a value had a third behaviour:
* DisableAll (same as the previous 'False')
* EnableAll (same as the previous 'True')
* EnableWhenPossible (same as previous 'unspecified')

The goal is to make it possible to force the default behaviour even if
'tests: True' or 'tests: False' is specified in a configuration file,
e.g. by passing --enable-tests-when-possible on the command-line.

Unfortunately, this does not yet work. In this commit, I tried to make
as few changes to the current implementation as possible, by converting
'EnableAll' to 'True' and the other two values to 'False' whenever a
function expects a boolean. As a consequence, passing
--enable-tests-when-possible currently behaves like passing
--disable-tests.
the two branches are "not optional" and "optional", not "not optional"
and "not optional".
@gelisam
Copy link
Collaborator Author

gelisam commented Dec 5, 2021

@phadej , do you happen to remember what this uncommented TODO was about? You introduced it in 84d2a5e.

-- it is not an optional stanza, so a testsuite or benchmark
Just stanza ->
case (optStanzaLookup stanza (elabStanzasRequested elab), -- TODO

Also, while we're looking at this code, that comment should say "it is an optional stanza, so a testsuite or benchmark", not "it is not an optional stanza, so a testsuite or benchmark", correct?

Before introducing EnableWhenPossible, the conversion from Flag Bool to
Maybe Bool was rather simple:

  NoFlag -> Nothing
  Flag True -> Just True
  Flag False -> Just False

After introducing EnableWhenPossible, we now have one extra case:

  NoFlag -> Nothing
  Flag EnableAll -> Just True
  Flag DisableAll -> Just False
  Flag EnableWhenPossible -> ?

We previously mapped it to Just False, but that caused
--enable-tests-when-possible to behave like --disable-tests. It needs to
be mapped to Nothing instead.
@gelisam
Copy link
Collaborator Author

gelisam commented Dec 17, 2021

Since this mysterious TODO is on a case expression which picks an error message, perhaps it is related to this other TODO, which suggests replacing the Bool we're pattern-matching on with a 3-valued sum-type in order to affect the error message? Note that his 3-valued sum-type is not the same as the EnableComponentType 3-valued sum-type I'm adding in this PR.

-- TODO: The 'Bool' here should be refined into an ADT with three
-- cases: NotRequested, ExplicitlyRequested and
-- ImplicitlyRequested. A stanza is explicitly requested if
-- the user asked, for this *specific* package, that the stanza
-- be enabled; it's implicitly requested if the user asked for
-- all global packages to have this stanza enabled. The
-- difference between an explicit and implicit request is
-- error reporting behavior: if a user asks for tests to be
-- enabled for a specific package that doesn't have any tests,
-- we should warn them about it, but we shouldn't complain
-- that a user enabled tests globally, and some local packages
-- just happen not to have any tests. (But perhaps we should
-- warn if ALL local packages don't have any tests.)

@Mikolaj
Copy link
Member

Mikolaj commented Dec 17, 2021

Also, while we're looking at this code, that comment should say "it is an optional stanza, so a testsuite or benchmark", not "it is not an optional stanza, so a testsuite or benchmark", correct?

Since there is no response, feel free to amend the comment and TODOs.

it was not clear what that TODO mark asked us to do. I found a second,
clearer TODO which asks us to do something with the line where this
first TODO is, so I am guessing that this was the reason for the first
TODO, so I am expanding the first TODO to point to the second.
@gelisam
Copy link
Collaborator Author

gelisam commented Dec 17, 2021

feel free to amend the comment and TODOs

done! They now look like this:

-- it is an optional stanza, so a testsuite or benchmark.
--
-- TODO: once 'elabStanzasRequested' has been upgraded to an
-- ADT with three cases (see TODO note for 'elabStanzasRequested'),
-- use those to pick a better failure cause here.
Just stanza ->
case (optStanzaLookup stanza (elabStanzasRequested elab),
optStanzaSetMember stanza (elabStanzasAvailable elab)) of

@mergify mergify bot added the merge delay passed Applied (usually by Mergify) when PR approved and received no updates for 2 days label Sep 1, 2022
@ulysses4ever ulysses4ever removed the merge delay passed Applied (usually by Mergify) when PR approved and received no updates for 2 days label Sep 3, 2022
@andreasabel
Copy link
Member

Ah, too bad this PR has stalled. Any chance to pick it up again, @gelisam ? Would be great to have this feature!

@gelisam
Copy link
Collaborator Author

gelisam commented Feb 18, 2023

Sure, thanks for reminding me about this!

@gelisam
Copy link
Collaborator Author

gelisam commented May 26, 2023

I unfortunately haven't been able to find the time for this, does anybody else want to take over?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants