Skip to content
This repository was archived by the owner on Jun 14, 2023. It is now read-only.

Commit 1eea618

Browse files
committed
Add test for init command with a specified stack file path
1 parent 7964ae3 commit 1eea618

File tree

6 files changed

+102
-0
lines changed

6 files changed

+102
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: init-specific
2+
version: 0.0.0
3+
synopsis: A test project for jenga
4+
5+
description: The simplest possible combination of a cabal file and a
6+
stack.yaml file. The stack file specifies the stack
7+
resolver version and nothing more.
8+
9+
license: MIT
10+
license-file: LICENSE
11+
author: Erik de Castro Lopo
12+
maintainer: [email protected]
13+
category: Test
14+
build-type: Simple
15+
cabal-version: >= 1.10
16+
17+
library
18+
ghc-options: -Wall -fwarn-tabs
19+
default-language: Haskell2010
20+
hs-source-dirs: src
21+
22+
exposed-modules: Test.Jenga.Init.Simple
23+
24+
build-depends: base
25+
, binary
26+
, bytestring
27+
, containers
28+
, directory
29+
, exceptions
30+
, extra
31+
, filepath
32+
, time
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
resolver: lts-11.13
2+
3+
extra-deps: []
4+
5+
packages:
6+
- '.'
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This is not a valid stack.yaml file and should be ignored.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# mafia-lock-file-version: 0
2+
base == 4.10.1.0
3+
binary == 0.8.5.1
4+
bytestring == 0.10.8.2
5+
containers == 0.5.10.2
6+
directory == 1.3.0.2
7+
exceptions == 0.8.3
8+
extra == 1.6.8
9+
filepath == 1.4.1.2
10+
time == 1.8.0.2
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"submodule-dir": "lib",
3+
"mafia-lock": true,
4+
"submodules": [],
5+
"drop-deps": []
6+
}

test/cli/init-specific/run

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/bin/sh -eu
2+
3+
# Create a repo using a known stack-specific.yaml file.
4+
# Run `jenga init` to initialize the submodule ('wide-word`).
5+
# Check that the local '.jenga' file is as expected.
6+
# Check that the mafia lock file is as expected.
7+
# Also make sure that cabal files in the 'dist-newstyle' and '.cabal-sandbox'
8+
# are ignored.
9+
10+
. $(dirname $0)/../core/runner
11+
12+
testname="init-specific"
13+
14+
banner "${testname}"
15+
#----------
16+
17+
INPUT_DIR=$(dirname $0)/data
18+
OUTPUT_DIR=${TEST}
19+
EXPECTED_DIR=$(dirname $0)/expected
20+
21+
mkdir -p ${OUTPUT_DIR}
22+
23+
cp -f ${INPUT_DIR}/* ${OUTPUT_DIR}/
24+
25+
# Add some invalid cabal files to make sure they are ignored.
26+
mkdir ${OUTPUT_DIR}/dist-newstyle ${OUTPUT_DIR}/.cabal-sandbox/
27+
echo "Invalid cabal file" > ${OUTPUT_DIR}/dist-newstyle/invalid.cabal
28+
echo "Invalid cabal file" > ${OUTPUT_DIR}/.cabal-sandbox/invalid.cabal
29+
30+
(cd ${OUTPUT_DIR} && \
31+
git init && \
32+
git add stack-specific.yaml ${testname}.cabal && \
33+
git commit -m "Initial commit" -- . && \
34+
${JENGA} init --stack-file stack-specific.yaml)
35+
36+
assert_file_exists ${OUTPUT_DIR}/${testname}.lock-8.2.2
37+
assert_file_exists ${OUTPUT_DIR}/.jenga
38+
39+
error=0
40+
compare_files ${OUTPUT_DIR}/${testname}.lock-8.2.2 ${EXPECTED_DIR}/${testname}.lock-8.2.2
41+
compare_files ${OUTPUT_DIR}/.jenga ${EXPECTED_DIR}/jenga.yaml
42+
43+
if test "${error}" = "0"; then
44+
pass_test
45+
else
46+
fail_test
47+
fi

0 commit comments

Comments
 (0)