-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_all_with_truffle.sh
executable file
·65 lines (60 loc) · 1.37 KB
/
run_all_with_truffle.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env bash
# Setup the truffle project
rm -Rf truffle
pushd .
mkdir truffle
cd truffle
truffle init
popd
# Copy the contracts to the truffle
ALL_CONTRACTS=$(find contracts -name "*.sol" | grep -v Library)
CONTRACTS_WITH_TEST=$(grep -l 'truffleMain' $ALL_CONTRACTS)
cp $CONTRACTS_WITH_TEST truffle/contracts/
# Add to migrations
DEPLOY=truffle/migrations/2_deploy_contracts.js
(
for c in $CONTRACTS_WITH_TEST
do
c_basename=`basename $c`
c_name=${c_basename%.*}
echo "var $c_name = artifacts.require('./$c_basename');"
done
echo
echo "module.exports = function(deployer) {"
for c in $CONTRACTS_WITH_TEST
do
c_basename=`basename $c`
c_name=${c_basename%.*}
echo " deployer.deploy($c_name);"
done
echo "};"
) > $DEPLOY
# Add to tests
TEST=truffle/test/All.js
(
for c in $CONTRACTS_WITH_TEST
do
c_basename=`basename $c`
c_name=${c_basename%.*}
echo "var $c_name = artifacts.require('$c_name');"
done
echo
echo "contract('All', function(accounts) {"
echo " var contract"
echo " var user = accounts[0]"
echo
for c in $CONTRACTS_WITH_TEST
do
c_basename=`basename $c`
c_name=${c_basename%.*}
echo " it('$c_name', function() {"
echo " return $c_name.deployed().then(function(instance) {"
echo " return instance.truffleMain({ from: user, gas: 500000});"
echo " });"
echo " });"
done
echo "});"
) > $TEST
# Now actually test
cd truffle
truffle test