Skip to content
This repository was archived by the owner on Dec 17, 2024. It is now read-only.

Commit ff4049b

Browse files
committed
move composer tests and test data out of main repo and into shell-composer-plugin repo
Fixes #1018
1 parent 959780f commit ff4049b

File tree

89 files changed

+158
-4539
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+158
-4539
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,5 @@ app/plugins/.pre-scanned
1212
dump.rdb
1313
openwhisk
1414
.idea
15+
.DS_Store
16+
app.inst

.travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ install:
5353
- cat app/plugins/.pre-scanned | jq .commandToPlugin # ibid
5454
- cat app/plugins/.pre-scanned | jq .overrides # ibid
5555
- echo "install steps completed with success"
56+
# corral the tests that plugins might offer
57+
- echo "Test corral"
58+
- (cd tests && ./bin/corral.sh)
5659

5760
# if for some reason we want to avoid the use of travis jobs:
5861
#script: (cd tests && npm run test)

app/plugins/ui/commands/tab-completion.js

Lines changed: 46 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,34 @@ const completeWith = (partial, match, addSpace=false) => {
3030
return (partialIdx >= 0 ? match.substring(partialIdx + partial.length) : match) + (addSpace ? ' ' : '')
3131
}
3232

33+
/**
34+
* Is the given filepath a directory?
35+
*
36+
*/
37+
const isDirectory = filepath => new Promise((resolve, reject) => {
38+
fs.lstat(filepath, (err, stats) => {
39+
if (err) {
40+
reject(err)
41+
} else {
42+
if (stats.isSymbolicLink()) {
43+
debug('following symlink')
44+
// TODO: consider turning these into the better async calls?
45+
return fs.realpath(filepath, (err, realpath) => {
46+
if (err) {
47+
reject(err)
48+
} else {
49+
return isDirectory(realpath)
50+
.then(resolve)
51+
.catch(reject)
52+
}
53+
})
54+
}
55+
56+
resolve(stats.isDirectory())
57+
}
58+
})
59+
})
60+
3361
/**
3462
* We've found a match. Add this match to the given partial match,
3563
* located in the given dirname'd directory, and update the given
@@ -48,9 +76,10 @@ const complete = (match, prompt, { temporaryContainer, partial=temporaryContaine
4876

4977
if (dirname) {
5078
// see if we need to add a trailing slash
51-
fs.lstat(expandHomeDir(path.join(dirname, match)), (err, stats) => {
52-
if (!err) {
53-
if (stats.isDirectory()) {
79+
const filepath = expandHomeDir(path.join(dirname, match))
80+
isDirectory(filepath)
81+
.then(isDir => {
82+
if (isDir) {
5483
// add a trailing slash if the dirname/match is a directory
5584
debug('complete as directory')
5685
prompt.value = prompt.value + completion + '/'
@@ -59,10 +88,9 @@ const complete = (match, prompt, { temporaryContainer, partial=temporaryContaine
5988
debug('complete as scalar')
6089
prompt.value = prompt.value + completion
6190
}
62-
} else {
91+
}).catch(err => {
6392
console.error(err)
64-
}
65-
})
93+
})
6694

6795
} else {
6896
// otherwise, just add the completion to the prompt
@@ -398,14 +426,18 @@ const suggestLocalFile = (last, block, prompt, temporaryContainer, lastIdx) => {
398426
const { option, optionInner } = addSuggestion(temporaryContainer, dirname, prompt)(match, idx)
399427

400428
// see if the match is a directory, so that we add a trailing slash
401-
fs.lstat(expandHomeDir(path.join(dirname, match)), (err, stats) => {
402-
if (!err && stats.isDirectory()) {
403-
optionInner.innerText = match + '/'
404-
} else {
405-
optionInner.innerText = match
406-
}
407-
option.setAttribute('data-value', optionInner.innerText)
408-
})
429+
const filepath = path.join(dirname, match)
430+
isDirectory(filepath)
431+
.then(isDir => {
432+
if (isDir) {
433+
optionInner.innerText = match + '/'
434+
} else {
435+
optionInner.innerText = match
436+
}
437+
option.setAttribute('data-value', optionInner.innerText)
438+
}).catch(err => {
439+
console.error(err)
440+
})
409441
})
410442
}
411443
}

dist/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"main": "index.js",
66
"scripts": {
77
"test": "echo \"Error: no test specified\" && exit 1",
8-
"postinstall": "if [ `uname` == Darwin ]; then brew install fakeroot dpkg mono; fi"
8+
"postinstall": "if [ `uname` == Darwin ]; then brew list | grep '^mono$'; if [ $? == 1 ]; then brew install mono; fi; brew list | grep '^dpkg$'; if [ $? == 1 ]; then brew install dpkg; fi; brew list | grep '^fakeroot$'; if [ $? == 0 ]; then brew install fakeroot; fi; fi"
99
},
1010
"author": "",
1111
"license": "Apache-2.0",

tests/bin/corral.sh

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
#
2+
# Copyright 2018 IBM Corporation
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
17+
#!/usr/bin/env bash
18+
19+
#
20+
# Find plugin-hosted tests
21+
#
22+
23+
# are we setting up links or tearing them down (a.k.a. clean)?
24+
if [ "$1" == "clean" ]; then
25+
CLEAN=true
26+
fi
27+
28+
# make sure we are independent of the working directory
29+
SCRIPTDIR=$(cd $(dirname "$0") && pwd)
30+
ROOTDIR="$SCRIPTDIR/../.."
31+
cd "$SCRIPTDIR/.."
32+
33+
# scan for tests
34+
TESTS=`find "$ROOTDIR/app/plugins/modules" -maxdepth 2 -name tests`
35+
36+
# set up (or tear down) links
37+
for test in $TESTS; do
38+
echo "Scanning $test"
39+
40+
if [ -d "$test/data" ]; then
41+
echo
42+
echo " - found test input data"
43+
44+
for data in "$test"/data/*; do
45+
base=`basename $data`
46+
if [ -n "$CLEAN" ]; then
47+
echo " * unlinking data $base"
48+
(cd data && rm -f $base)
49+
else
50+
echo " * linking data $base"
51+
(cd data && ln -s "$data" .)
52+
fi
53+
done
54+
fi
55+
56+
if [ -d "$test/lib" ]; then
57+
echo
58+
echo " - found test library files"
59+
60+
for lib in "$test"/lib/*; do
61+
base=`basename $lib`
62+
if [ -n "$CLEAN" ]; then
63+
echo " * unlinking lib $base"
64+
(cd lib && rm -f $base)
65+
else
66+
echo " * linking lib $base"
67+
(cd lib && ln -s "$lib" .)
68+
fi
69+
done
70+
fi
71+
72+
if [ -d "$test/tests/passes" ]; then
73+
echo
74+
echo " - found tests"
75+
76+
for pass in "$test"/tests/passes/*; do
77+
base=`basename $pass`
78+
if [ -n "$CLEAN" ]; then
79+
echo " * unlinking pass $base"
80+
(cd tests/passes && rm -f $base)
81+
else
82+
echo " * linking pass $base"
83+
(cd tests/passes && ln -s "$pass" .)
84+
fi
85+
done
86+
fi
87+
done

tests/bin/runLocal.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616

1717
#!/usr/bin/env bash
1818

19+
SCRIPTDIR=$(cd $(dirname "$0") && pwd)
20+
export TEST_ROOT="$SCRIPTDIR/.."
21+
1922
# the | tee should fail if runTest fails
2023
set -o pipefail
2124

tests/data/composer-source-expect-errors/addSubscription.js

Lines changed: 0 additions & 43 deletions
This file was deleted.

tests/data/composer-source-expect-errors/error1.js

Lines changed: 0 additions & 29 deletions
This file was deleted.

tests/data/composer-source-expect-errors/if-bad.js

Lines changed: 0 additions & 4 deletions
This file was deleted.

tests/data/composer-source-expect-errors/nofsm.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

tests/data/composer-source-expect-errors/t2s.js

Lines changed: 0 additions & 18 deletions
This file was deleted.

tests/data/composer-source/author-map.json

Lines changed: 0 additions & 3 deletions
This file was deleted.

tests/data/composer-source/comments.js

Lines changed: 0 additions & 7 deletions
This file was deleted.

tests/data/composer-source/composer1.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

tests/data/composer-source/composer1b.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

tests/data/composer-source/composer1c.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

tests/data/composer-source/composer1d.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

tests/data/composer-source/composer1e.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

tests/data/composer-source/composer2.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

tests/data/composer-source/composer3.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

tests/data/composer-source/composer4.js

Lines changed: 0 additions & 2 deletions
This file was deleted.

tests/data/composer-source/composer5.js

Lines changed: 0 additions & 30 deletions
This file was deleted.

0 commit comments

Comments
 (0)