agrafix / Spock

Another Haskell web framework for rapid development
https://www.spock.li
678 stars 56 forks source link

Reroute: Test failure in SafeRoutingSpec #135

Closed tekul closed 1 year ago

tekul commented 6 years ago

I'm installing reroute-0.4.1.0 as a dependency as part of a nix environment and installation fails with the following test error:

  test/Web/Routing/SafeRoutingSpec.hs:84: 
  1) SafeRouting Spec should handle multiple possible matches correctly
       expected: [IntVar 5,StrVar "5"]
        but got: [StrVar "5",IntVar 5]

It looks like it's probably some list ordering issue with the test, rather than an actual bug, but I haven't investigated further.

agrafix commented 6 years ago

interesting ... probably adding a "sort" in the test should fix the issue.

thoferon commented 6 years ago

I have the same issue when building some project with cabal+nix. Apparently, you had already fixed the tests about 6 months ago (https://github.com/agrafix/Spock/commit/eac4cc3202f8bcb87ec317ca17d7ef96f50907ca) but it hasn't made its way to Hackage yet.

In the meantime, someone might be interested in the following workaround.

{ nixpkgs ? import <nixpkgs> {}, compiler ? "default" }:

let

  inherit (nixpkgs) pkgs;

  haskellPackages = if compiler == "default"
                       then pkgs.haskellPackages
                       else pkgs.haskell.packages.${compiler};

  reroute = haskellPackages.callPackage
    ({ mkDerivation, base, criterion, deepseq, graph-core, hashable
     , hspec, http-api-data, hvect, mtl, random, regex-compat, text
     , unordered-containers, vector, stdenv
     }:
     mkDerivation {
       pname = "reroute";
       version = "0.4.1.0";
       sha256 = "02159ifmv1i5y2dkh9927rw5b0kssxcjiw37d0z0nqa0086kza1l";

       doCheck = false; # <--- Don't run the tests

       libraryHaskellDepends = [
         base deepseq hashable http-api-data hvect mtl text
         unordered-containers
       ];
       testHaskellDepends = [
         base hspec hvect mtl text unordered-containers vector
       ];
       benchmarkHaskellDepends = [
         base criterion deepseq graph-core hashable http-api-data hvect mtl
         random regex-compat text unordered-containers vector
       ];
       homepage = "http://github.com/agrafix/Spock";
       description = "abstract implementation of typed and untyped web routing";
       license = stdenv.lib.licenses.mit;
     }) {};

  f = { mkDerivation, base, stdenv }: # <--- Remove reroute here
      mkDerivation {
        pname = "my-package";
        version = "0.1.0.0";
        src = ./.;
        libraryHaskellDepends = [ base reroute ];
        license = stdenv.lib.licenses.bsd3;
      };

  drv = haskellPackages.callPackage f {};

in

  if pkgs.lib.inNixShell then drv.env else drv
tekul commented 6 years ago

@thoferon Can't you just override haskellPackages and call the dontCheck function on the existing package, like in this example. I think that's probably simpler.