Skip to content

Commit 8a26031

Browse files
eamsdenangerman
authored andcommitted
Add test for callStackToNix
1 parent 73933ab commit 8a26031

File tree

9 files changed

+165
-0
lines changed

9 files changed

+165
-0
lines changed

test/callStackToNix/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.stack-work/
2+
stack-simple.cabal
3+
*~

test/callStackToNix/Setup.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import Distribution.Simple
2+
main = defaultMain

test/callStackToNix/app/Main.hs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module Main where
2+
3+
import Lib
4+
5+
main :: IO ()
6+
main = someFunc

test/callStackToNix/default.nix

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{ stdenv, mkStackPkgSet, callStackToNix }:
2+
3+
with stdenv.lib;
4+
5+
let
6+
pkgSet = mkStackPkgSet {
7+
stack-pkgs = callStackToNix { src = ./.; };
8+
pkg-def-extras = [];
9+
modules = [];
10+
};
11+
12+
packages = pkgSet.config.hsPkgs;
13+
14+
in
15+
stdenv.mkDerivation {
16+
name = "callStackToNix-test";
17+
18+
buildCommand = ''
19+
exe="${packages.stack-simple.components.exes.stack-simple-exe}/bin/stack-simple-exe"
20+
21+
printf "checking whether executable runs... " >& 2
22+
$exe
23+
24+
touch $out
25+
'';
26+
27+
meta.platforms = platforms.all;
28+
29+
passthru = {
30+
# Attributes used for debugging with nix repl
31+
inherit pkgSet packages;
32+
};
33+
}

test/callStackToNix/package.yaml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: stack-simple
2+
version: 0.1.0.0
3+
github: "githubuser/stack-simple"
4+
license: BSD3
5+
author: "Author name here"
6+
maintainer: "[email protected]"
7+
copyright: "2019 Author name here"
8+
9+
extra-source-files:
10+
- README.md
11+
- ChangeLog.md
12+
13+
# Metadata used when publishing your package
14+
# synopsis: Short description of your package
15+
# category: Web
16+
17+
# To avoid duplicated efforts in documentation and dealing with the
18+
# complications of embedding Haddock markup inside cabal files, it is
19+
# common to point users to the README.md file.
20+
description: Please see the README on GitHub at <https://github.com/githubuser/stack-simple#readme>
21+
22+
dependencies:
23+
- base >= 4.7 && < 5
24+
25+
library:
26+
source-dirs: src
27+
28+
executables:
29+
stack-simple-exe:
30+
main: Main.hs
31+
source-dirs: app
32+
ghc-options:
33+
- -threaded
34+
- -rtsopts
35+
- -with-rtsopts=-N
36+
dependencies:
37+
- stack-simple
38+
39+
tests:
40+
stack-simple-test:
41+
main: Spec.hs
42+
source-dirs: test
43+
ghc-options:
44+
- -threaded
45+
- -rtsopts
46+
- -with-rtsopts=-N
47+
dependencies:
48+
- stack-simple

test/callStackToNix/src/Lib.hs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module Lib
2+
( someFunc
3+
) where
4+
5+
someFunc :: IO ()
6+
someFunc = putStrLn "someFunc"

test/callStackToNix/stack.yaml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# This file was automatically generated by 'stack init'
2+
#
3+
# Some commonly used options have been documented as comments in this file.
4+
# For advanced use and comprehensive documentation of the format, please see:
5+
# https://docs.haskellstack.org/en/stable/yaml_configuration/
6+
7+
# Resolver to choose a 'specific' stackage snapshot or a compiler version.
8+
# A snapshot resolver dictates the compiler version and the set of packages
9+
# to be used for project dependencies. For example:
10+
#
11+
# resolver: lts-3.5
12+
# resolver: nightly-2015-09-21
13+
# resolver: ghc-7.10.2
14+
#
15+
# The location of a snapshot can be provided as a file or url. Stack assumes
16+
# a snapshot provided as a file might change, whereas a url resource does not.
17+
#
18+
# resolver: ./custom-snapshot.yaml
19+
# resolver: https://example.com/snapshots/2018-01-01.yaml
20+
resolver: lts-13.6
21+
22+
# User packages to be built.
23+
# Various formats can be used as shown in the example below.
24+
#
25+
# packages:
26+
# - some-directory
27+
# - https://example.com/foo/bar/baz-0.0.2.tar.gz
28+
# - location:
29+
# git: https://github.com/commercialhaskell/stack.git
30+
# commit: e7b331f14bcffb8367cd58fbfc8b40ec7642100a
31+
# - location: https://github.com/commercialhaskell/stack/commit/e7b331f14bcffb8367cd58fbfc8b40ec7642100a
32+
# subdirs:
33+
# - auto-update
34+
# - wai
35+
packages:
36+
- .
37+
# Dependency packages to be pulled from upstream that are not in the resolver
38+
# using the same syntax as the packages field.
39+
# (e.g., acme-missiles-0.3)
40+
# extra-deps: []
41+
42+
# Override default flag values for local packages and extra-deps
43+
# flags: {}
44+
45+
# Extra package databases containing global packages
46+
# extra-package-dbs: []
47+
48+
# Control whether we use the GHC we find on the path
49+
# system-ghc: true
50+
#
51+
# Require a specific version of stack, using version ranges
52+
# require-stack-version: -any # Default
53+
# require-stack-version: ">=1.9"
54+
#
55+
# Override the architecture used by stack, especially useful on Windows
56+
# arch: i386
57+
# arch: x86_64
58+
#
59+
# Extra directories used by stack for building
60+
# extra-include-dirs: [/path/to/dir]
61+
# extra-lib-dirs: [/path/to/dir]
62+
#
63+
# Allow a newer minor version of GHC than the snapshot specifies
64+
# compiler-check: newer-minor

test/callStackToNix/test/Spec.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
main :: IO ()
2+
main = putStrLn "Test suite not yet implemented"

test/default.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ in {
1515
with-packages = haskell.callPackage ./with-packages { inherit util; };
1616
builder-haddock = haskell.callPackage ./builder-haddock {};
1717
stack-simple = haskell.callPackage ./stack-simple {};
18+
callStackToNix = haskell.callPackage ./callStackToNix {};
1819

1920
# Run unit tests with: nix-instantiate --eval --strict -A unit
2021
# An empty list means success.

0 commit comments

Comments
 (0)