Skip to content

Project structure: extract examples (quicksort, foreign heap/list, ...) to internal library to allow easy run/test/benchmarking #480

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

Merged
merged 2 commits into from
Sep 13, 2024

Conversation

tbagrel1
Copy link
Member

Using an internal library, in addition to the main library, seems to be supported by both Cabal and stack now, despite a warning from stack saying the opposite.

With this change, the examples test suite becomes the examples internal library, and I introduced test-examples to act as the test suite for shared examples. This allows us, for example, to also cherry pick some examples we want to benchmark, and share the code between the test suite and benchmark suite (which wasn't possible before).

Other changes:

  • Renamed the default benchmark suite from mutable-data to bench, for consistency.
  • Moved the genericTraverse tests from examples to the main test suite

This PR follows and builds upon #479

@tbagrel1 tbagrel1 force-pushed the tbagrel1/extract-examples-internal-lib branch 3 times, most recently from e5fa1f7 to d0ed5c9 Compare September 11, 2024 11:43
@tbagrel1 tbagrel1 force-pushed the tbagrel1/extract-examples-internal-lib branch from d0ed5c9 to f379045 Compare September 13, 2024 08:24
@tbagrel1 tbagrel1 force-pushed the tbagrel1/extract-examples-internal-lib branch from f379045 to 90bd5f1 Compare September 13, 2024 08:43
Copy link
Member

@aspiwack aspiwack left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Up to small point below, merge when you're ready.


test-suite examples
test-suite test-examples
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
test-suite test-examples
test-suite examples

Should work. Because different units are namespaced between their types, so it'll be referred to as something like test:examples (instead of test:test-examples in your case).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesnt seem to work:

library examples
    import: build-opts
    hs-source-dirs: examples
    
[...]

test-suite examples
    import: build-opts
    import: rts-opts-multithread
    type:             exitcode-stdio-1.0
    main-is:          Main.hs
    hs-source-dirs:   test/examples

gives

Configuring linear-base-0.4.0...
There exist several components with the same name: 'examples'. This is a bug in your .cabal file.
CallStack (from HasCallStack):
  error, called at libraries/Cabal/Cabal-syntax/src/Distribution/PackageDescription/Utils.hs:18:15 in Cabal-syntax-3.10.3.0:Distribution.PackageDescription.Utils
Progress 1/2

Error: [S-7282]
       Stack failed to execute the build plan.
       
       While executing the build plan, Stack encountered the error:
       
       [S-7011]
       While building package linear-base-0.4.0 (scroll up to its section to see the error)
       using:
[...]

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad then.

@tbagrel1 tbagrel1 merged commit 95d54d1 into master Sep 13, 2024
11 checks passed
@tbagrel1 tbagrel1 deleted the tbagrel1/extract-examples-internal-lib branch September 13, 2024 13:02
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.

2 participants