mirror of https://github.com/deajan/osync
Compare commits
767 Commits
c55b39cff0
...
63cbe3786e
Author | SHA1 | Date |
---|---|---|
Orsiris de Jong | 63cbe3786e | 1 year ago |
Orsiris de Jong | 98a4d6bb0c | 1 year ago |
Orsiris de Jong | e47c1d7f58 | 1 year ago |
Orsiris de Jong | cef25b646f | 1 year ago |
Orsiris de Jong | 4054f3ca75 | 1 year ago |
Orsiris de Jong | ea1b3b379e | 1 year ago |
Orsiris de Jong | 988009a438 | 1 year ago |
Orsiris de Jong | b2f221cb86 | 1 year ago |
Orsiris de Jong | c4349bc945 | 1 year ago |
Orsiris de Jong | 99f107fcb0 | 1 year ago |
Orsiris de Jong | 776c07386d | 1 year ago |
Orsiris de Jong | edfc292486 | 1 year ago |
Orsiris de Jong | 9ade468ed8 | 1 year ago |
Orsiris de Jong | d9e22b06e5 | 1 year ago |
Orsiris de Jong | d0af0804a0 | 1 year ago |
Orsiris de Jong | 9b9c1105eb | 1 year ago |
Orsiris de Jong | 9b862ae49d | 1 year ago |
Orsiris de Jong | 57ef919364 | 1 year ago |
Orsiris de Jong | 833c16ca43 | 1 year ago |
Orsiris de Jong | 83a0f5c328 | 1 year ago |
Orsiris de Jong | 5a7455173c | 1 year ago |
Orsiris de Jong | edd35d42aa | 1 year ago |
Orsiris de Jong | 50f975d2df | 1 year ago |
Orsiris de Jong | 43e1aaaaa1 | 1 year ago |
Orsiris de Jong | b15e8e8f88 | 1 year ago |
Orsiris de Jong | 91950446f0 | 1 year ago |
Orsiris de Jong | 0ef4af40dc | 1 year ago |
Orsiris de Jong | 6b6f723094 | 1 year ago |
Orsiris de Jong | d100841bd9 | 1 year ago |
Orsiris de Jong | 52a42bc1d7 | 1 year ago |
Orsiris de Jong | 30d66003ef | 1 year ago |
Orsiris de Jong | b95e75aa0b | 1 year ago |
Orsiris de Jong | 8ef2262421 | 1 year ago |
root | fa7f6d1088 | 1 year ago |
Orsiris de Jong | 5f4e7af910 | 1 year ago |
Orsiris de Jong | a9da549e4f | 1 year ago |
Orsiris de Jong | 4bf065f94e | 1 year ago |
Orsiris de Jong | 5beb9220d1 | 1 year ago |
Orsiris de Jong | 53193aceb6 | 1 year ago |
Orsiris de Jong | 4d08791d04 | 1 year ago |
Orsiris de Jong | 01769189b7 | 1 year ago |
Orsiris de Jong | 9dd69349ad | 1 year ago |
Orsiris de Jong | ef0cd58d49 | 1 year ago |
Orsiris de Jong | d8915512ea | 1 year ago |
Orsiris de Jong | 9fa4c45b6c | 1 year ago |
J. Poessl | 22e269902b | 1 year ago |
Orsiris de Jong | edaeb9a400 | 2 years ago |
Orsiris de Jong | f646fffc79 | 2 years ago |
Orsiris de Jong | ce4b435eb2 | 2 years ago |
Orsiris de Jong | e395e8ca65 | 2 years ago |
Orsiris de Jong | 60ceccfff1 | 2 years ago |
Orsiris de Jong | cf78875ab5 | 2 years ago |
Orsiris de Jong | 059f95d4a8 | 2 years ago |
Orsiris de Jong | 9edeb39d45 | 2 years ago |
Orsiris de Jong | 55c4cffcf0 | 2 years ago |
Orsiris de Jong | 59bd176e48 | 2 years ago |
Orsiris de Jong | 7da01328b2 | 2 years ago |
Orsiris de Jong | 36db883ab0 | 2 years ago |
Orsiris de Jong | 632db7d9a2 | 2 years ago |
Orsiris de Jong | 999aeed303 | 2 years ago |
Orsiris de Jong | a83f76c639 | 2 years ago |
Orsiris de Jong | 663b5be3be | 2 years ago |
Orsiris de Jong | 898fcbb8c1 | 2 years ago |
Orsiris de Jong | ecc4c1d396 | 2 years ago |
Orsiris de Jong | 89f8533c27 | 2 years ago |
Orsiris de Jong | 7168aa9d02 | 2 years ago |
Orsiris de Jong | 9245030a9d | 2 years ago |
Orsiris de Jong | a1f8773953 | 2 years ago |
Orsiris de Jong | 35a71ad517 | 2 years ago |
Orsiris de Jong | e01d8c410b | 2 years ago |
Orsiris de Jong | 4e44020619 | 2 years ago |
Orsiris de Jong | f2761d6a42 | 2 years ago |
Hemant Zope | f48ff41072 | 2 years ago |
Hemant Zope | 08759b895c | 2 years ago |
deajan | 508cd4bf50 | 3 years ago |
deajan | 87dd5d07ea | 3 years ago |
deajan | 134acff3a9 | 3 years ago |
Orsiris de Jong | c091996231 | 3 years ago |
Orsiris de Jong | a7e1b4505b | 3 years ago |
Orsiris de Jong | 803d25ac8b | 3 years ago |
Orsiris de Jong | a36fd05069 | 3 years ago |
Orsiris de Jong | 96c26e2791 | 3 years ago |
Orsiris de Jong | f74108ed4a | 3 years ago |
deajan | 27866f1db5 | 4 years ago |
deajan | 904105904e | 4 years ago |
deajan | c2efdb2063 | 4 years ago |
deajan | edcfe337c3 | 4 years ago |
Orsiris de Jong | 56c8fa868a | 4 years ago |
deajan | 3c1eb0989e | 4 years ago |
deajan | 2bc8e899d7 | 4 years ago |
deajan | 9a8b028c96 | 4 years ago |
deajan | e5922f04a5 | 4 years ago |
Orsiris de Jong | 11e19108f5 | 4 years ago |
Enrico Da Ros | 4076423d98 | 4 years ago |
Enrico Da Ros | 536f8ce6f0 | 4 years ago |
Enrico Da Ros | 88c74dda70 | 4 years ago |
Enrico Da Ros | 2ebd22c441 | 4 years ago |
Enrico Da Ros | ca822566d4 | 4 years ago |
Enrico Da Ros | 009a4aabe0 | 4 years ago |
Enrico Da Ros | cc21cc6acc | 4 years ago |
Enrico Da Ros | 81437b5824 | 4 years ago |
Enrico Da Ros | 45304c608c | 4 years ago |
Orsiris de Jong | 8451024ae2 | 4 years ago |
deajan | 5ea103b36b | 4 years ago |
deajan | f2be25f83d | 4 years ago |
deajan | 5852d76cd3 | 4 years ago |
deajan | 67dc58f3b5 | 4 years ago |
deajan | b589c32ce7 | 4 years ago |
deajan | 8e4e745420 | 4 years ago |
deajan | f9694d6478 | 4 years ago |
deajan | ea0ca4e4c2 | 4 years ago |
deajan | 3c0f0b542d | 4 years ago |
deajan | 179bf6281e | 4 years ago |
deajan | f5403bd13a | 4 years ago |
deajan | 5870003c73 | 4 years ago |
deajan | 7ed547786f | 4 years ago |
deajan | 747e9c710e | 4 years ago |
deajan | 7a7653957e | 4 years ago |
deajan | ad7d022dcf | 4 years ago |
deajan | e6088c88de | 4 years ago |
deajan | 347f9a9ae8 | 4 years ago |
Orsiris de Jong | 7577f220dc | 4 years ago |
Zhang Zhishan | acf388bc7b | 4 years ago |
deajan | 5881c71212 | 4 years ago |
deajan | 60f2005209 | 4 years ago |
Orsiris de Jong | 7688317bd1 | 4 years ago |
deajan | e997493fb5 | 4 years ago |
deajan | be3fc2e848 | 4 years ago |
deajan | 844e08f92f | 4 years ago |
deajan | 38190c6139 | 4 years ago |
deajan | 45a8a7a589 | 4 years ago |
deajan | 3a9d00ff4f | 4 years ago |
deajan | 7bc80b9574 | 4 years ago |
deajan | a912a7d7c3 | 4 years ago |
deajan | 1c7d21c485 | 4 years ago |
root | 51a4c8bcce | 5 years ago |
root | fbce80bc0a | 5 years ago |
root | 6edce242b0 | 5 years ago |
root | 8788582f63 | 5 years ago |
Daniel Bingham | cc4ce385ee | 5 years ago |
deajan | 98c1b97fb0 | 5 years ago |
deajan | 17e2bf6dce | 5 years ago |
deajan | c2fef97c84 | 5 years ago |
deajan | eaeb218508 | 5 years ago |
deajan | a9cb30ffb4 | 5 years ago |
deajan | 08ab938477 | 5 years ago |
deajan | 5e71ed0854 | 5 years ago |
deajan | f5356ea702 | 5 years ago |
deajan | 10adfe6128 | 5 years ago |
deajan | 572a055901 | 5 years ago |
deajan | 45915611f6 | 5 years ago |
deajan | e4970830ac | 5 years ago |
deajan | b6181e15d9 | 5 years ago |
deajan | b8cfce2eb8 | 5 years ago |
deajan | d8bdf2d721 | 5 years ago |
deajan | e4d52aec2f | 5 years ago |
deajan | a4b03b12e2 | 5 years ago |
deajan | bf86cc5f6f | 5 years ago |
deajan | 39a8a309f5 | 5 years ago |
deajan | 97fb53f6de | 5 years ago |
deajan | 314505eb4a | 5 years ago |
deajan | fb57fb9d74 | 5 years ago |
deajan | 689928eac1 | 5 years ago |
deajan | 42c7493ef0 | 5 years ago |
Orsiris de Jong | 6139fa002b | 5 years ago |
Orsiris de Jong | a48f4a85e6 | 5 years ago |
deajan | cbff578ec5 | 5 years ago |
deajan | dc901282dc | 5 years ago |
deajan | 08372e74ba | 5 years ago |
deajan | 7d8978dc88 | 5 years ago |
deajan | 925adbd488 | 5 years ago |
deajan | e0b2f0435e | 5 years ago |
deajan | cb7dbbe2af | 5 years ago |
deajan | 3d94544337 | 5 years ago |
deajan | 8197ea3ddb | 5 years ago |
deajan | 78323cc06a | 5 years ago |
deajan | ba830fe7d0 | 5 years ago |
deajan | 87dd470344 | 5 years ago |
deajan | 2c45d58659 | 5 years ago |
deajan | 4d4728b90c | 5 years ago |
deajan | 22538907b3 | 5 years ago |
deajan | f3365ed5ff | 5 years ago |
deajan | 145814f231 | 5 years ago |
deajan | 21bd1657ec | 5 years ago |
deajan | 6be95a3cff | 5 years ago |
deajan | a7526c8a87 | 5 years ago |
deajan | 8b757bf083 | 5 years ago |
deajan | be1281ffa3 | 5 years ago |
deajan | bdc9e42046 | 5 years ago |
Orsiris de Jong | d66ea211d5 | 5 years ago |
deajan | da5140d3f0 | 5 years ago |
deajan | d37872c730 | 5 years ago |
deajan | 997a7904ed | 5 years ago |
deajan | 712c3179ee | 5 years ago |
deajan | 0d28d0c482 | 5 years ago |
deajan | f22cff5a49 | 5 years ago |
deajan | 7fb8eb7004 | 5 years ago |
deajan | afdc5334f4 | 5 years ago |
deajan | c02a7af424 | 5 years ago |
deajan | 17a97d129b | 5 years ago |
deajan | 183ca45b63 | 5 years ago |
deajan | 31986d0d19 | 5 years ago |
deajan | bf3b846026 | 5 years ago |
deajan | 7d137ed0c5 | 5 years ago |
deajan | 723501526c | 5 years ago |
deajan | 2f4384d911 | 5 years ago |
deajan | 8f2b22a117 | 5 years ago |
deajan | 5f6f7482dd | 5 years ago |
deajan | f0ea6df5ea | 5 years ago |
deajan | 4df4c594b7 | 5 years ago |
deajan | 08910b3895 | 5 years ago |
deajan | 21c59cfd27 | 5 years ago |
deajan | 151cfb8d39 | 5 years ago |
deajan | 3b545648ac | 5 years ago |
deajan | 0ae3a0c629 | 5 years ago |
deajan | 9c7ef090f1 | 5 years ago |
deajan | b124f7dfaf | 5 years ago |
deajan | f87b529195 | 5 years ago |
deajan | 3cddb9b97e | 5 years ago |
deajan | 80f3b2f0bc | 5 years ago |
deajan | 31b8ce4c52 | 5 years ago |
deajan | f81291c0eb | 5 years ago |
deajan | 59ec9e42c1 | 5 years ago |
deajan | 9cfa13c59a | 5 years ago |
deajan | ca78d76bb2 | 5 years ago |
deajan | b0b91a4db0 | 5 years ago |
deajan | 8d9e95c6cd | 5 years ago |
deajan | 154318be0f | 5 years ago |
deajan | ddb820d2fa | 5 years ago |
deajan | dce4092085 | 5 years ago |
deajan | 219067be26 | 5 years ago |
Orsiris de Jong | 8f85d20a68 | 5 years ago |
Orsiris de Jong | 492064f8e2 | 5 years ago |
bmorgenthaler | 32ee9f8071 | 5 years ago |
deajan | 33971c359c | 5 years ago |
deajan | d9d5aaf1e8 | 5 years ago |
Orsiris de Jong | bd25ef4b72 | 5 years ago |
deajan | 2b17326630 | 5 years ago |
deajan | 228a4d1f51 | 5 years ago |
deajan | 679b4bc29e | 5 years ago |
deajan | f1b558d646 | 5 years ago |
deajan | c8bb8c214f | 5 years ago |
deajan | c801d6b418 | 5 years ago |
deajan | 0b539e6153 | 5 years ago |
deajan | 8256bbef88 | 5 years ago |
deajan | b3a7572c0e | 5 years ago |
deajan | 9976b3a6e5 | 5 years ago |
deajan | bcd79e06aa | 5 years ago |
deajan | 6459a9dd4c | 5 years ago |
deajan | 9b481467f6 | 5 years ago |
deajan | 72f2e43071 | 5 years ago |
deajan | a6e4c4a0ee | 5 years ago |
deajan | b4892b9fdc | 5 years ago |
deajan | 63f6194305 | 5 years ago |
deajan | 3dae261b9b | 5 years ago |
deajan | c6876924c7 | 5 years ago |
Orsiris de Jong | 0c343662f4 | 5 years ago |
Orsiris de Jong | f4130119ef | 5 years ago |
deajan | 971ea2b358 | 5 years ago |
deajan | 2ce8007b9d | 5 years ago |
Orsiris de Jong | 39da290577 | 5 years ago |
Orsiris de Jong | cdeae14fd7 | 5 years ago |
deajan | 3cd2f16bc3 | 5 years ago |
deajan | 9435c48f20 | 5 years ago |
deajan | 4a1001a40f | 5 years ago |
Orsiris de Jong | f0811b3f56 | 5 years ago |
deajan | f95155c310 | 5 years ago |
deajan | 1b8c07332f | 5 years ago |
deajan | d17ece7e2c | 5 years ago |
deajan | e1a081a7f1 | 5 years ago |
deajan | 590e299821 | 5 years ago |
deajan | f8fbbaef57 | 5 years ago |
deajan | 7fffa454e9 | 5 years ago |
deajan | 22af510375 | 5 years ago |
deajan | 61729d1245 | 5 years ago |
deajan | c089ccc63b | 5 years ago |
deajan | 3edd80949f | 5 years ago |
deajan | 9bd2b7eeaf | 5 years ago |
deajan | 9142f873f4 | 5 years ago |
deajan | dc25cba3c8 | 5 years ago |
deajan | f781f35ea1 | 5 years ago |
deajan | c07897b7cb | 5 years ago |
deajan | 301e0d69e1 | 5 years ago |
deajan | aca0be5a9b | 5 years ago |
deajan | 5638565f6a | 5 years ago |
deajan | c10a175c90 | 5 years ago |
deajan | 968c732d94 | 5 years ago |
deajan | b290d4e35e | 5 years ago |
deajan | de383c9c0f | 5 years ago |
deajan | 0c1f4403fb | 5 years ago |
deajan | 555d8e6d23 | 5 years ago |
deajan | 02d0024df9 | 5 years ago |
deajan | 3accf5f254 | 5 years ago |
deajan | bd8fc2f043 | 5 years ago |
deajan | 40c44368ec | 5 years ago |
deajan | 7331612a11 | 5 years ago |
deajan | e12d30d9c5 | 5 years ago |
deajan | c18977bcef | 5 years ago |
deajan | 3d6ec17f27 | 5 years ago |
deajan | a0e5e791cd | 5 years ago |
deajan | 44d8635042 | 5 years ago |
deajan | 71f857f9c8 | 5 years ago |
deajan | de99f0efdf | 5 years ago |
deajan | 0d501209fa | 5 years ago |
deajan | efeb665818 | 5 years ago |
deajan | 7e945197c2 | 5 years ago |
deajan | a52068dec0 | 5 years ago |
deajan | 7b57980e57 | 5 years ago |
deajan | c96bdfe5ce | 5 years ago |
deajan | 8018871168 | 5 years ago |
deajan | 826ebe1c2c | 5 years ago |
deajan | 4b90ac3a27 | 5 years ago |
deajan | 0e7f969588 | 5 years ago |
deajan | 01c469b019 | 5 years ago |
deajan | aa92531b99 | 5 years ago |
deajan | 4542f62fce | 5 years ago |
deajan | 020f674932 | 5 years ago |
deajan | 22fe557c54 | 5 years ago |
deajan | 1339e6463a | 5 years ago |
deajan | 99a7c932f7 | 5 years ago |
deajan | 932ecd93fd | 5 years ago |
deajan | 201aadd33d | 5 years ago |
deajan | 5eecb719d3 | 5 years ago |
deajan | 76d80b17f6 | 5 years ago |
deajan | 094d1538bb | 5 years ago |
deajan | 30411c72c7 | 5 years ago |
deajan | 26b661396a | 5 years ago |
deajan | e64ec1232e | 5 years ago |
deajan | c2f0b41076 | 5 years ago |
deajan | e8470218f6 | 5 years ago |
deajan | 3a9c427855 | 5 years ago |
Orsiris de Jong | 63a434cc55 | 5 years ago |
Ingo Weinhold | 56c0197b6b | 6 years ago |
deajan | 5b0c40f3f0 | 6 years ago |
deajan | 61a9aa6a91 | 6 years ago |
deajan | 8a57b568e9 | 6 years ago |
deajan | 5e42a088d0 | 6 years ago |
deajan | 0f5bed992f | 6 years ago |
deajan | 51dded275b | 6 years ago |
deajan | 61f6593cbe | 6 years ago |
deajan | 8fe0afae56 | 6 years ago |
deajan | 5477ed96fe | 6 years ago |
deajan | c15f9ea4a2 | 6 years ago |
deajan | 39feb76d2e | 6 years ago |
deajan | cc2d283f23 | 6 years ago |
Orsiris de Jong | 8e8ed101bb | 6 years ago |
deajan | d9b587fd4a | 6 years ago |
deajan | 027422b014 | 6 years ago |
deajan | e44bdee73e | 6 years ago |
deajan | 22bd6181f1 | 6 years ago |
deajan | e850f8f792 | 6 years ago |
deajan | 2da2109229 | 6 years ago |
deajan | 52c059fc29 | 6 years ago |
deajan | f1cf7eb8e2 | 6 years ago |
deajan | f3bbaceb73 | 6 years ago |
deajan | 88491d0fee | 6 years ago |
deajan | 1c9db7136f | 6 years ago |
deajan | 71942082f8 | 6 years ago |
deajan | 6e56e2b63e | 6 years ago |
deajan | 3931b7b771 | 6 years ago |
deajan | 9e64753569 | 6 years ago |
deajan | 98201cf615 | 6 years ago |
deajan | 6ac45eea02 | 6 years ago |
deajan | 17fb0c6bf5 | 6 years ago |
deajan | cae3bb73f7 | 6 years ago |
Orsiris de Jong | 5a5e60d651 | 6 years ago |
deajan | fad217447d | 6 years ago |
deajan | 5857d8200b | 6 years ago |
deajan | a466e94b9c | 6 years ago |
deajan | 08af105dd9 | 6 years ago |
deajan | 3314f947b0 | 6 years ago |
deajan | 27d6b80fad | 6 years ago |
deajan | 34724352f7 | 6 years ago |
deajan | 27f6d2a948 | 6 years ago |
deajan | b8f18ac860 | 6 years ago |
deajan | 01e4ec9ef1 | 6 years ago |
deajan | fb1fd00f0e | 6 years ago |
deajan | 569048c19b | 6 years ago |
deajan | efd8dca58e | 6 years ago |
deajan | 92dbd6b2fc | 6 years ago |
deajan | 7e7388a9eb | 6 years ago |
deajan | 109f0a0887 | 6 years ago |
deajan | 54a665fe7e | 6 years ago |
deajan | 255be72c43 | 6 years ago |
deajan | 04f11fcab8 | 6 years ago |
deajan | 39e5bb92f0 | 6 years ago |
deajan | 0f0ba9b001 | 6 years ago |
deajan | 330495b1e8 | 6 years ago |
deajan | 203400000f | 6 years ago |
deajan | 85ac20080b | 6 years ago |
deajan | a28c20d9bd | 6 years ago |
deajan | c9bc7f4b6c | 6 years ago |
deajan | 17cf11eb0b | 6 years ago |
deajan | 39053f59e3 | 6 years ago |
deajan | 295c74ca58 | 6 years ago |
deajan | 1896ec793e | 6 years ago |
deajan | 5c6132dd2c | 6 years ago |
deajan | 438c85b777 | 6 years ago |
deajan | bbc960d566 | 6 years ago |
deajan | c963d71ecd | 6 years ago |
deajan | 1b8f2ea7fc | 6 years ago |
deajan | 4c999ec229 | 6 years ago |
deajan | a2e3e96827 | 6 years ago |
deajan | 4be8429b96 | 6 years ago |
deajan | 0e103cd98b | 6 years ago |
deajan | 83cfabed6f | 6 years ago |
deajan | dfe09f2fa3 | 6 years ago |
deajan | ff26961e82 | 6 years ago |
deajan | ca63bfabe0 | 6 years ago |
deajan | 2aa36b626a | 6 years ago |
deajan | f0336c0dec | 6 years ago |
deajan | 3dc8478ba7 | 6 years ago |
deajan | 633e6397d0 | 6 years ago |
deajan | babeea9d9a | 6 years ago |
deajan | 9cb6cc57af | 6 years ago |
deajan | 7eb4ee68ae | 6 years ago |
deajan | 660e856986 | 6 years ago |
deajan | ac31de2388 | 6 years ago |
deajan | ae64a967f6 | 6 years ago |
deajan | 2ca8803b3a | 6 years ago |
deajan | ad9d978fc2 | 6 years ago |
deajan | 7570794632 | 6 years ago |
deajan | 4651ff0e06 | 6 years ago |
deajan | 0e2189c441 | 6 years ago |
deajan | 1ab6042a62 | 6 years ago |
deajan | a5f5b3a800 | 6 years ago |
deajan | b95474a8e6 | 6 years ago |
deajan | e3855c4256 | 6 years ago |
deajan | 51f6dcbd71 | 6 years ago |
deajan | 3d68a135a4 | 6 years ago |
deajan | 9e17e114f7 | 6 years ago |
deajan | 94a71620a1 | 6 years ago |
deajan | bad7767809 | 6 years ago |
deajan | fa5cf2de57 | 6 years ago |
deajan | 9eb29c3454 | 6 years ago |
deajan | 4129dfff37 | 6 years ago |
deajan | c452bd45e6 | 6 years ago |
deajan | 6b0bab0984 | 6 years ago |
deajan | 89d63d83b8 | 6 years ago |
deajan | e0f177f5c2 | 6 years ago |
deajan | 6bd5862702 | 6 years ago |
deajan | eb8c780d84 | 6 years ago |
deajan | 58e5c654d3 | 6 years ago |
deajan | e411c81f3d | 6 years ago |
deajan | 57647b8960 | 6 years ago |
deajan | 5b395b3c04 | 6 years ago |
deajan | 4bd4bbc247 | 6 years ago |
deajan | 4de784d90f | 6 years ago |
deajan | 6c1b7a541b | 6 years ago |
deajan | 6e7b99debb | 6 years ago |
deajan | 996e6251e1 | 6 years ago |
deajan | a265ca4eef | 6 years ago |
deajan | 306d5ff1ad | 6 years ago |
deajan | 74271d220c | 6 years ago |
deajan | 8a350333a8 | 6 years ago |
deajan | e9daf2b2bf | 6 years ago |
deajan | d58071c898 | 6 years ago |
deajan | b07ee4a645 | 6 years ago |
deajan | 6c65f9098f | 6 years ago |
deajan | 9537b92bf6 | 6 years ago |
deajan | 2c857a1e83 | 6 years ago |
Orsiris de Jong | b0cdb17328 | 6 years ago |
Orsiris de Jong | 5c0c494526 | 6 years ago |
deajan | 6f2e1af3d7 | 6 years ago |
deajan | 0b7b6808d5 | 6 years ago |
deajan | 7eab6df734 | 6 years ago |
deajan | 32c2ab17e4 | 6 years ago |
deajan | bc6ebdb80e | 6 years ago |
deajan | 0d6f7e0ca0 | 6 years ago |
deajan | 49948dd637 | 6 years ago |
deajan | f35d5841c2 | 6 years ago |
deajan | 81148db1fa | 6 years ago |
deajan | 250ac48ed6 | 6 years ago |
deajan | 65d4c3c3ff | 6 years ago |
deajan | bbfa4c9d3b | 6 years ago |
deajan | 25070032c4 | 6 years ago |
deajan | 4f76bb4ad2 | 6 years ago |
deajan | 465a3b9b80 | 6 years ago |
deajan | a9434e605b | 6 years ago |
deajan | 06004ac05d | 6 years ago |
deajan | b2463d2e08 | 6 years ago |
deajan | 13286c2720 | 6 years ago |
deajan | a734dadfde | 6 years ago |
deajan | c694580ae5 | 6 years ago |
deajan | 4f3e6a11d2 | 6 years ago |
deajan | f028f3b6d2 | 6 years ago |
deajan | 2e6e17962c | 6 years ago |
deajan | 52cf42a53c | 6 years ago |
deajan | 5bc77dfe76 | 6 years ago |
deajan | 1869b1e82f | 6 years ago |
deajan | 3532b50c38 | 6 years ago |
deajan | d0b40257fa | 6 years ago |
deajan | 59b7562a3e | 6 years ago |
deajan | c99a1293c7 | 6 years ago |
deajan | eb609f7faa | 6 years ago |
deajan | 7e678b6480 | 6 years ago |
deajan | b4cd0834cd | 6 years ago |
deajan | 55534e0669 | 6 years ago |
deajan | 2eba91a58f | 6 years ago |
deajan | 01864e4980 | 6 years ago |
deajan | 87cdc8eb98 | 6 years ago |
deajan | 740d5277cc | 6 years ago |
deajan | a230d32042 | 6 years ago |
deajan | dde31090fe | 6 years ago |
deajan | c07fa8b267 | 6 years ago |
deajan | 88597d6a7a | 6 years ago |
deajan | 6bce2e1755 | 6 years ago |
deajan | fe808ca909 | 6 years ago |
deajan | 90a09c422b | 6 years ago |
deajan | 47bb01b0dc | 6 years ago |
deajan | 2b51f06f21 | 6 years ago |
deajan | f50048180a | 6 years ago |
deajan | 5945988e96 | 6 years ago |
deajan | 07775d7390 | 6 years ago |
deajan | c80bec2fe2 | 6 years ago |
deajan | af7542d8f5 | 6 years ago |
deajan | b44c0c13ad | 6 years ago |
deajan | d727bc353c | 6 years ago |
deajan | 3af0bc7a11 | 6 years ago |
deajan | f1e40d54e4 | 6 years ago |
deajan | 76f9f31e6d | 6 years ago |
deajan | 50496070f6 | 6 years ago |
deajan | 68d8556585 | 6 years ago |
deajan | 1eec242cb0 | 6 years ago |
deajan | 4cf697cd28 | 6 years ago |
deajan | 23a9f357fe | 6 years ago |
Orsiris de Jong | 7c11240034 | 6 years ago |
deajan | 6222fd6872 | 6 years ago |
deajan | c80871cb63 | 6 years ago |
deajan | cabd90c570 | 6 years ago |
deajan | 3f46c69c6d | 6 years ago |
deajan | 24599c3057 | 6 years ago |
deajan | fa64c49244 | 6 years ago |
deajan | cf609998aa | 6 years ago |
deajan | 82e60bdffe | 6 years ago |
deajan | 83321db4ea | 6 years ago |
deajan | 76ed396602 | 6 years ago |
deajan | f3215c0474 | 6 years ago |
deajan | 7cb987a32b | 6 years ago |
deajan | f79acad239 | 6 years ago |
deajan | 548c766920 | 6 years ago |
deajan | 9b3af0596e | 6 years ago |
deajan | b45e50584f | 6 years ago |
deajan | 1ea4584027 | 6 years ago |
deajan | 61f7ebe156 | 6 years ago |
deajan | 41144f5705 | 6 years ago |
deajan | 5438941c88 | 6 years ago |
deajan | 888309f420 | 6 years ago |
deajan | 704d3d20a7 | 6 years ago |
deajan | 503e325e14 | 6 years ago |
deajan | 182e3921d5 | 6 years ago |
deajan | e094e04038 | 6 years ago |
deajan | a2a6d843b9 | 6 years ago |
deajan | 7ddd13f122 | 6 years ago |
deajan | f0f3cd64b1 | 6 years ago |
deajan | 9cac01d9fd | 6 years ago |
deajan | c04e0fa21a | 6 years ago |
deajan | 9e869e2bc4 | 6 years ago |
deajan | 948a2b2f87 | 6 years ago |
deajan | c3b468d932 | 6 years ago |
deajan | 2f5e21caea | 6 years ago |
deajan | 0a8811cfb9 | 6 years ago |
deajan | 4d322f7e6b | 6 years ago |
deajan | 9b4914c49e | 6 years ago |
deajan | 21bc4e1ee7 | 6 years ago |
deajan | 3d6eaef447 | 6 years ago |
deajan | 381313dc41 | 6 years ago |
deajan | a64da2ba3d | 6 years ago |
Orsiris de Jong | f6db6fb9e3 | 6 years ago |
deajan | b3cccc373a | 6 years ago |
deajan | 42ed3b156a | 6 years ago |
deajan | de57e37217 | 6 years ago |
deajan | bf54ce8693 | 6 years ago |
deajan | 7621f3ec25 | 6 years ago |
deajan | ad22361ee5 | 6 years ago |
deajan | 494fcda098 | 6 years ago |
deajan | bd2e5a16c6 | 6 years ago |
deajan | 844cf56307 | 6 years ago |
deajan | 8dfe59220a | 6 years ago |
deajan | a60ece6950 | 6 years ago |
deajan | c39544d79c | 6 years ago |
deajan | 0ccc737631 | 6 years ago |
deajan | d9f749e28a | 6 years ago |
deajan | 1ed49b7d41 | 6 years ago |
deajan | 166a37865e | 6 years ago |
deajan | dc31bfb42d | 6 years ago |
deajan | 01e359ae3c | 6 years ago |
deajan | 4d9eb8830b | 6 years ago |
Orsiris de Jong | beed970e49 | 6 years ago |
deajan | 1314a3381b | 6 years ago |
Jookia | a0d7ec544d | 6 years ago |
Koz Ross | 44d2df4906 | 6 years ago |
Koz Ross | 601c8ace14 | 6 years ago |
Koz Ross | 33b7b89a36 | 6 years ago |
deajan | 6d37e161c8 | 7 years ago |
deajan | f627daf25a | 7 years ago |
deajan | ee8016ef9a | 7 years ago |
deajan | 1b33068422 | 7 years ago |
Orsiris de Jong | 1917c33cd1 | 7 years ago |
Orsiris de Jong | c2960e3315 | 7 years ago |
Hugo Rivera | 3c1c606de4 | 7 years ago |
Hugo Rivera | 4725370d8e | 7 years ago |
deajan | 041de62c36 | 7 years ago |
deajan | e8436e46bd | 7 years ago |
deajan | 36daadd7aa | 7 years ago |
deajan | dee5b4037c | 7 years ago |
deajan | d0bd873def | 7 years ago |
deajan | d13b76087f | 7 years ago |
deajan | 46a990c4d8 | 7 years ago |
deajan | bfa9d72c8d | 7 years ago |
deajan | a7d0c6f515 | 7 years ago |
deajan | d8b30d7711 | 7 years ago |
deajan | 190e46c785 | 7 years ago |
deajan | da381175ed | 7 years ago |
deajan | 034c1693e9 | 7 years ago |
deajan | 686a28cf08 | 7 years ago |
deajan | 57cf91e4c6 | 7 years ago |
Shadowigor | b2b5714469 | 7 years ago |
Orsiris de Jong | 477eb9ea84 | 7 years ago |
Ivor Xinzi Zhou | 0bda80355b | 7 years ago |
deajan | df9a90896a | 7 years ago |
deajan | 328a07e406 | 7 years ago |
deajan | ebf8b106d5 | 7 years ago |
deajan | 276fc8c082 | 7 years ago |
deajan | 9a0dba00e4 | 7 years ago |
deajan | 9b8fe3774e | 7 years ago |
deajan | 73d592ad34 | 7 years ago |
deajan | cbd7607836 | 7 years ago |
deajan | 8fb3ea2532 | 7 years ago |
deajan | 1b079ebee5 | 7 years ago |
deajan | 755edb0654 | 7 years ago |
Orsiris de Jong | 3ef4160cc8 | 7 years ago |
Rohitt Vashishtha | de45d000e0 | 7 years ago |
deajan | c78d6bc4ce | 7 years ago |
deajan | 7e26863daf | 7 years ago |
deajan | 69b2283719 | 7 years ago |
deajan | 7d22be8375 | 7 years ago |
deajan | 0a1dc91fad | 7 years ago |
deajan | c05499c5f2 | 7 years ago |
deajan | a65bec4410 | 7 years ago |
deajan | a5618c80d8 | 7 years ago |
deajan | 6d217c1e15 | 7 years ago |
deajan | fdc0b1b242 | 7 years ago |
deajan | 9833ce9032 | 7 years ago |
deajan | 71a0437de6 | 7 years ago |
Orsiris de Jong | ff38685105 | 7 years ago |
acuthbert | b195abf59f | 7 years ago |
deajan | 0b665be787 | 7 years ago |
deajan | 972b8481f1 | 7 years ago |
deajan | 86930737b0 | 7 years ago |
deajan | 86ff4dc5e9 | 7 years ago |
deajan | f26b1118a1 | 7 years ago |
deajan | 168fc7b2f5 | 7 years ago |
deajan | 7cbbdb960a | 7 years ago |
deajan | 09c664fe4b | 7 years ago |
deajan | a80b65860a | 7 years ago |
deajan | 1375ab425b | 7 years ago |
deajan | 29dc7a3e9e | 7 years ago |
deajan | 2038a2ecb9 | 7 years ago |
deajan | e07cb136c4 | 7 years ago |
deajan | 5bcc7c75ea | 7 years ago |
deajan | 8d9a6be16a | 7 years ago |
deajan | 06becc5181 | 7 years ago |
deajan | 1dc9408044 | 7 years ago |
deajan | 9676ccccad | 7 years ago |
deajan | 45e4419a0f | 7 years ago |
Orsiris de Jong | c9772b0fc3 | 7 years ago |
deajan | 9b9631fe2c | 7 years ago |
deajan | 5c36e803d8 | 7 years ago |
deajan | fbb36b51b7 | 7 years ago |
deajan | 9220cecebc | 7 years ago |
deajan | a7f9a28c93 | 7 years ago |
deajan | 1f6fe47c2c | 7 years ago |
deajan | d926a26cf1 | 7 years ago |
deajan | 4678ab7e71 | 7 years ago |
deajan | 261521d047 | 7 years ago |
deajan | 10ebfaae16 | 7 years ago |
deajan | e096413eb0 | 7 years ago |
deajan | 30c6b3ec46 | 7 years ago |
Orsiris de Jong | 3667ccfb6f | 7 years ago |
deajan | 543cfc1159 | 7 years ago |
deajan | 679e140084 | 7 years ago |
deajan | e73e395ed8 | 7 years ago |
deajan | 7c44b7342b | 7 years ago |
deajan | 3e9a380b6b | 7 years ago |
deajan | cbea41be56 | 7 years ago |
deajan | 85cd7bd75e | 7 years ago |
deajan | 2f20edf823 | 7 years ago |
deajan | 84a108dd41 | 7 years ago |
deajan | d0d7be40c3 | 7 years ago |
deajan | 7a24cf49cd | 7 years ago |
deajan | be3b3d39b6 | 7 years ago |
deajan | 11408d2de0 | 7 years ago |
deajan | 7260d43416 | 7 years ago |
deajan | 1d7cb5be53 | 7 years ago |
deajan | b4f1bd37ea | 7 years ago |
deajan | 2b786abc6a | 7 years ago |
deajan | bd6b1a60e8 | 7 years ago |
deajan | 967ce33977 | 7 years ago |
deajan | 37ca73a6f9 | 7 years ago |
deajan | 9e1c3c2a65 | 7 years ago |
deajan | 862a6fd235 | 7 years ago |
deajan | 83fd33bf78 | 7 years ago |
deajan | 99b606fef8 | 7 years ago |
deajan | b0307fd555 | 7 years ago |
deajan | eb73d49c69 | 7 years ago |
deajan | d91230e22f | 7 years ago |
deajan | 825e051e3b | 7 years ago |
deajan | a7ceea1dac | 7 years ago |
Orsiris de Jong | 3ff8a123e1 | 7 years ago |
Orsiris de Jong | 6a4b3701d0 | 7 years ago |
deajan | 45cb042fa0 | 7 years ago |
deajan | 5c60e7a9a2 | 7 years ago |
deajan | a99a96e871 | 7 years ago |
deajan | f98a9a0748 | 7 years ago |
deajan | b541a7c98e | 7 years ago |
Orsiris de Jong | d587e49e67 | 7 years ago |
Orsiris de Jong | a32314c720 | 7 years ago |
Orsiris de Jong | 63834b5714 | 7 years ago |
deajan | 520c20659f | 7 years ago |
deajan | f962f86f30 | 7 years ago |
deajan | 908c9af888 | 7 years ago |
deajan | 0b442e2bcf | 7 years ago |
deajan | a32b5f8321 | 7 years ago |
deajan | 2c1e688d8e | 7 years ago |
deajan | 8f946cb476 | 7 years ago |
deajan | 78dc39b86f | 7 years ago |
deajan | f8df6b8eab | 7 years ago |
deajan | 2b163d385b | 7 years ago |
deajan | 3174981b9a | 7 years ago |
deajan | ab40ea64e2 | 7 years ago |
deajan | ee8b213894 | 7 years ago |
deajan | 11bd517982 | 7 years ago |
deajan | 1400390f57 | 7 years ago |
deajan | c2b24688ef | 7 years ago |
deajan | 300108641a | 7 years ago |
deajan | 011a316f94 | 7 years ago |
deajan | fe210877dc | 7 years ago |
Orsiris de Jong | a740d9b63b | 7 years ago |
deajan | 623408bf31 | 7 years ago |
deajan | 5677335c24 | 7 years ago |
deajan | 722e366ade | 7 years ago |
deajan | 762fd236a0 | 7 years ago |
deajan | 1a85d5ded9 | 7 years ago |
deajan | 8d99a74710 | 8 years ago |
deajan | d8ad5f746b | 8 years ago |
deajan | d1bb2fe68e | 8 years ago |
deajan | 402adba191 | 8 years ago |
deajan | bc3b6b3a5d | 8 years ago |
deajan | 96a3995545 | 8 years ago |
deajan | 49bdd17202 | 8 years ago |
deajan | 2934951495 | 8 years ago |
deajan | ec857e8e01 | 8 years ago |
deajan | 12685b3154 | 8 years ago |
deajan | e10a120e74 | 8 years ago |
deajan | 128051cd8f | 8 years ago |
deajan | b618970ea1 | 8 years ago |
deajan | 56b9efd686 | 8 years ago |
deajan | bbff9d55d6 | 8 years ago |
deajan | ac0f7b3866 | 8 years ago |
deajan | abd0ff640c | 8 years ago |
deajan | 9f89d4fdff | 8 years ago |
deajan | f15e9bf8af | 8 years ago |
deajan | d530cbbe44 | 8 years ago |
deajan | 9cfd6c4eb4 | 8 years ago |
deajan | eb5ca2c39d | 8 years ago |
deajan | feb2034b53 | 8 years ago |
@ -0,0 +1,33 @@
|
|||||||
|
---
|
||||||
|
name: Bug report
|
||||||
|
about: Create a report to help us improve
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**Describe the bug**
|
||||||
|
A clear and concise description of what the bug is.
|
||||||
|
|
||||||
|
**To Reproduce**
|
||||||
|
Steps to reproduce the behavior:
|
||||||
|
1. Setup osync with the following config file / the following parameters (please provide either anonymized)
|
||||||
|
2. Run osync with following parameters
|
||||||
|
3. Result
|
||||||
|
|
||||||
|
**Expected behavior**
|
||||||
|
A clear and concise description of what you expected to happen.
|
||||||
|
|
||||||
|
** Deviated behavior**
|
||||||
|
How does the actual result deviate from the expected behavior.
|
||||||
|
|
||||||
|
**Logs**
|
||||||
|
Please send logs of what happens.
|
||||||
|
Also, you might run osync with _DEBUG=yes environement variable to have more verbose debug logs.
|
||||||
|
|
||||||
|
**Environment (please complete the following information):**
|
||||||
|
- Full osync version (including build)
|
||||||
|
- OS: [e.g. iOS]
|
||||||
|
- Bitness [e.g. x64 or x86]
|
||||||
|
- Shell (busybox or else)
|
||||||
|
|
||||||
|
**Additional context**
|
||||||
|
Add any other context about the problem here.
|
@ -0,0 +1,25 @@
|
|||||||
|
name: linux-tests
|
||||||
|
|
||||||
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
os: [ubuntu-latest]
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
sudo apt-get install inotify-tools acl
|
||||||
|
- name: Execute tests and generate coverage report
|
||||||
|
run: |
|
||||||
|
export RUNNING_ON_GITHUB_ACTIONS=true
|
||||||
|
export SSH_PORT=22
|
||||||
|
echo "Running on github actions: ${RUNNING_ON_GITHUB_ACTIONS}"
|
||||||
|
echo "Running on ssh port ${SSH_PORT}"
|
||||||
|
sudo -E bash ./dev/tests/run_tests.sh
|
||||||
|
- name: Upload Coverage to Codecov
|
||||||
|
uses: codecov/codecov-action@v1
|
@ -0,0 +1,28 @@
|
|||||||
|
name: macosx-tests
|
||||||
|
|
||||||
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
os: [macos-latest]
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Install Bash 4
|
||||||
|
run: |
|
||||||
|
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
|
||||||
|
brew update
|
||||||
|
|
||||||
|
brew install bash
|
||||||
|
brew install fswatch
|
||||||
|
echo "/usr/local/bin" >> $GITHUB_PATH
|
||||||
|
- name: Execute tests and generate coverage report
|
||||||
|
run: |
|
||||||
|
export RUNNING_ON_GITHUB_ACTIONS=true
|
||||||
|
export SSH_PORT=22
|
||||||
|
sudo -E bash ./dev/tests/run_tests.sh
|
||||||
|
- name: Upload Coverage to Codecov
|
||||||
|
uses: codecov/codecov-action@v1
|
@ -0,0 +1,29 @@
|
|||||||
|
name: windows-tests
|
||||||
|
|
||||||
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
os: [windows-latest]
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: Vampire/setup-wsl@v1
|
||||||
|
with:
|
||||||
|
additional-packages:
|
||||||
|
dos2unix
|
||||||
|
rsync
|
||||||
|
openssh-server
|
||||||
|
- name: Execute tests and generate coverage report
|
||||||
|
shell: wsl-bash {0}
|
||||||
|
run: |
|
||||||
|
export RUNNING_ON_GITHUB_ACTIONS=true
|
||||||
|
export SSH_PORT=22
|
||||||
|
find ./ -type f ! -path "./.git/*" -print0 | xargs -0 -n 1 -P 4 dos2unix
|
||||||
|
service ssh start
|
||||||
|
./dev/tests/run_tests.sh
|
||||||
|
- name: Upload Coverage to Codecov
|
||||||
|
uses: codecov/codecov-action@v1
|
@ -0,0 +1,6 @@
|
|||||||
|
## KNOWN ISSUES
|
||||||
|
|
||||||
|
- Cannot finish sync if one replica contains a directory and the other replica contains a file named the same way (Unix doesn't allow this)
|
||||||
|
- Daemon mode monitors changes in the whole replica directories, without honoring exclusion lists
|
||||||
|
- Soft deletion does not honor exclusion lists (ie soft deleted files will be cleaned regardless of any exlude pattern because they are in the deleted folder)
|
||||||
|
- Colors don't work in mac shell
|
@ -1,6 +0,0 @@
|
|||||||
KNOWN ISSUES
|
|
||||||
------------
|
|
||||||
|
|
||||||
- Cannot finish sync if one replica contains a directory and the other replica contains a file named the same way (Unix doesn't allow this)
|
|
||||||
- Soft deletion does not honor exclusion lists (ie soft deleted files will be cleaned regardless of any exlude pattern because they are in the deleted folder)
|
|
||||||
- Colors don't work in mac shell
|
|
@ -1,4 +1,4 @@
|
|||||||
Copyright (c) 2013-2016, Orsiris de Jong. ozy@netpower.fr
|
Copyright (c) 2013-2023, Orsiris de Jong. ozy@netpower.fr
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
@ -0,0 +1,4 @@
|
|||||||
|
When submitting a pull request, please modify the files in dev directory rather than those generated on-the-fly.
|
||||||
|
|
||||||
|
You may find all code contained in osync.sh in n_osync.sh and ofunctions.sh
|
||||||
|
You may run your modified code by using `merge.sh osync` in order to generate ../osync.sh
|
@ -0,0 +1,17 @@
|
|||||||
|
## Releases require the following
|
||||||
|
|
||||||
|
- Documentation must be up to date
|
||||||
|
- grep -Eri "TODO|WIP" osync/* must be run in order to find potential release blockers, including in unit tests and config files
|
||||||
|
Run program and then use declare -p to find any leaked variables that should not exist outside of the program
|
||||||
|
- packaging files must be updated (RHEL / Arch)
|
||||||
|
- Before every release, shellcheck must be run
|
||||||
|
- ./shellcheck.sh -e SC2034 -e SC2068 ofunctions.sh
|
||||||
|
- ./shellcheck.sh n_osync.sh
|
||||||
|
- ./shellcheck.sh ../install.sh
|
||||||
|
- ./shellcheck.sh ../osync-batch.sh
|
||||||
|
- ./shellcheck.sh ../ssh_filter.sh
|
||||||
|
- Unexpansion of main and subprograms must be done
|
||||||
|
- Arch repo must be updated
|
||||||
|
- Source must be put to download on www.netpower.fr/osync
|
||||||
|
- Tests must be run against all supported operating systems via run_tests.sh
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,46 @@
|
|||||||
|
# Contributor Covenant Code of Conduct
|
||||||
|
|
||||||
|
## Our Pledge
|
||||||
|
|
||||||
|
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
||||||
|
|
||||||
|
## Our Standards
|
||||||
|
|
||||||
|
Examples of behavior that contributes to creating a positive environment include:
|
||||||
|
|
||||||
|
* Using welcoming and inclusive language
|
||||||
|
* Being respectful of differing viewpoints and experiences
|
||||||
|
* Gracefully accepting constructive criticism
|
||||||
|
* Focusing on what is best for the community
|
||||||
|
* Showing empathy towards other community members
|
||||||
|
|
||||||
|
Examples of unacceptable behavior by participants include:
|
||||||
|
|
||||||
|
* The use of sexualized language or imagery and unwelcome sexual attention or advances
|
||||||
|
* Trolling, insulting/derogatory comments, and personal or political attacks
|
||||||
|
* Public or private harassment
|
||||||
|
* Publishing others' private information, such as a physical or electronic address, without explicit permission
|
||||||
|
* Other conduct which could reasonably be considered inappropriate in a professional setting
|
||||||
|
|
||||||
|
## Our Responsibilities
|
||||||
|
|
||||||
|
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
|
||||||
|
|
||||||
|
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
|
||||||
|
|
||||||
|
## Scope
|
||||||
|
|
||||||
|
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
|
||||||
|
|
||||||
|
## Enforcement
|
||||||
|
|
||||||
|
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at kate.ward@forestent.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
|
||||||
|
|
||||||
|
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
|
||||||
|
|
||||||
|
## Attribution
|
||||||
|
|
||||||
|
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
|
||||||
|
|
||||||
|
[homepage]: http://contributor-covenant.org
|
||||||
|
[version]: http://contributor-covenant.org/version/1/4/
|
@ -0,0 +1,147 @@
|
|||||||
|
Coding Standards
|
||||||
|
================
|
||||||
|
|
||||||
|
shFlags is more than just a simple 20 line shell script. It is a pretty
|
||||||
|
significant library of shell code that at first glance is not that easy to
|
||||||
|
understand. To improve code readability and usability, some guidelines have been
|
||||||
|
set down to make the code more understandable for anyone who wants to read or
|
||||||
|
modify it.
|
||||||
|
|
||||||
|
Function declaration
|
||||||
|
--------------------
|
||||||
|
|
||||||
|
Declare functions using the following form:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
doSomething() {
|
||||||
|
echo 'done!'
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
One-line functions are allowed if they can fit within the 80 char line limit.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
doSomething() { echo 'done!'; }
|
||||||
|
```
|
||||||
|
|
||||||
|
Function documentation
|
||||||
|
----------------------
|
||||||
|
|
||||||
|
Each function should be preceded by a header that provides the following:
|
||||||
|
|
||||||
|
1. A one-sentence summary of what the function does.
|
||||||
|
|
||||||
|
1. (optional) A longer description of what the function does, and perhaps some
|
||||||
|
special information that helps convey its usage better.
|
||||||
|
|
||||||
|
1. Args: a one-line summary of each argument of the form:
|
||||||
|
|
||||||
|
`name: type: description`
|
||||||
|
|
||||||
|
1. Output: a one-line summary of the output provided. Only output to STDOUT
|
||||||
|
must be documented, unless the output to STDERR is of significance (i.e. not
|
||||||
|
just an error message). The output should be of the form:
|
||||||
|
|
||||||
|
`type: description`
|
||||||
|
|
||||||
|
1. Returns: a one-line summary of the value returned. Returns in shell are
|
||||||
|
always integers, but if the output is a true/false for success (i.e. a
|
||||||
|
boolean), it should be noted. The output should be of the form:
|
||||||
|
|
||||||
|
`type: description`
|
||||||
|
|
||||||
|
Here is a sample header:
|
||||||
|
|
||||||
|
```
|
||||||
|
# Return valid getopt options using currently defined list of long options.
|
||||||
|
#
|
||||||
|
# This function builds a proper getopt option string for short (and long)
|
||||||
|
# options, using the current list of long options for reference.
|
||||||
|
#
|
||||||
|
# Args:
|
||||||
|
# _flags_optStr: integer: option string type (__FLAGS_OPTSTR_*)
|
||||||
|
# Output:
|
||||||
|
# string: generated option string for getopt
|
||||||
|
# Returns:
|
||||||
|
# boolean: success of operation (always returns True)
|
||||||
|
```
|
||||||
|
|
||||||
|
Variable and function names
|
||||||
|
---------------------------
|
||||||
|
|
||||||
|
All shFlags specific constants, variables, and functions will be prefixed
|
||||||
|
appropriately with 'flags'. This is to distinguish usage in the shFlags code
|
||||||
|
from users own scripts so that the shell name space remains predictable to
|
||||||
|
users. The exceptions here are the standard `assertEquals`, etc. functions.
|
||||||
|
|
||||||
|
All non built-in constants and variables will be surrounded with squiggle
|
||||||
|
brackets, e.g. `${flags_someVariable}` to improve code readability.
|
||||||
|
|
||||||
|
Due to some shells not supporting local variables in functions, care in the
|
||||||
|
naming and use of variables, both public and private, is very important.
|
||||||
|
Accidental overriding of the variables can occur easily if care is not taken as
|
||||||
|
all variables are technically global variables in some shells.
|
||||||
|
|
||||||
|
Type | Sample
|
||||||
|
---- | ------
|
||||||
|
global public constant | `FLAGS_TRUE`
|
||||||
|
global private constant | `__FLAGS_SHELL_FLAGS`
|
||||||
|
global public variable | `flags_variable`
|
||||||
|
global private variable | `__flags_variable`
|
||||||
|
global macro | `_FLAGS_SOME_MACRO_`
|
||||||
|
public function | `flags_function`
|
||||||
|
public function, local variable | ``flags_variable_`
|
||||||
|
private function | `_flags_function`
|
||||||
|
private function, local variable | `_flags_variable_`
|
||||||
|
|
||||||
|
Where it makes sense to improve readability, variables can have the first
|
||||||
|
letter of the second and later words capitalized. For example, the local
|
||||||
|
variable name for the help string length is `flags_helpStrLen_`.
|
||||||
|
|
||||||
|
There are three special-case global public variables used. They are used due to
|
||||||
|
overcome the limitations of shell scoping or to prevent forking. The three
|
||||||
|
variables are:
|
||||||
|
|
||||||
|
- `flags_error`
|
||||||
|
- `flags_output`
|
||||||
|
- `flags_return`
|
||||||
|
|
||||||
|
Local variable cleanup
|
||||||
|
----------------------
|
||||||
|
|
||||||
|
As many shells do not support local variables, no support for cleanup of
|
||||||
|
variables is present either. As such, all variables local to a function must be
|
||||||
|
cleared up with the `unset` built-in command at the end of each function.
|
||||||
|
|
||||||
|
Indentation
|
||||||
|
-----------
|
||||||
|
|
||||||
|
Code block indentation is two (2) spaces, and tabs may not be used.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
if [ -z 'some string' ]; then
|
||||||
|
someFunction
|
||||||
|
fi
|
||||||
|
```
|
||||||
|
|
||||||
|
Lines of code should be no longer than 80 characters unless absolutely
|
||||||
|
necessary. When lines are wrapped using the backslash character '\', subsequent
|
||||||
|
lines should be indented with four (4) spaces so as to differentiate from the
|
||||||
|
standard spacing of two characters, and tabs may not be used.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
for x in some set of very long set of arguments that make for a very long \
|
||||||
|
that extends much too long for one line
|
||||||
|
do
|
||||||
|
echo ${x}
|
||||||
|
done
|
||||||
|
```
|
||||||
|
|
||||||
|
When a conditional expression is written using the built-in [ command, and that
|
||||||
|
line must be wrapped, place the control || or && operators on the same line as
|
||||||
|
the expression where possible, with the list to be executed on its own line.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
[ -n 'some really long expression' -a -n 'some other long expr' ] && \
|
||||||
|
echo 'that was actually true!'
|
||||||
|
```
|
@ -0,0 +1,201 @@
|
|||||||
|
Apache License
|
||||||
|
Version 2.0, January 2004
|
||||||
|
http://www.apache.org/licenses/
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||||
|
|
||||||
|
1. Definitions.
|
||||||
|
|
||||||
|
"License" shall mean the terms and conditions for use, reproduction,
|
||||||
|
and distribution as defined by Sections 1 through 9 of this document.
|
||||||
|
|
||||||
|
"Licensor" shall mean the copyright owner or entity authorized by
|
||||||
|
the copyright owner that is granting the License.
|
||||||
|
|
||||||
|
"Legal Entity" shall mean the union of the acting entity and all
|
||||||
|
other entities that control, are controlled by, or are under common
|
||||||
|
control with that entity. For the purposes of this definition,
|
||||||
|
"control" means (i) the power, direct or indirect, to cause the
|
||||||
|
direction or management of such entity, whether by contract or
|
||||||
|
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||||
|
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||||
|
|
||||||
|
"You" (or "Your") shall mean an individual or Legal Entity
|
||||||
|
exercising permissions granted by this License.
|
||||||
|
|
||||||
|
"Source" form shall mean the preferred form for making modifications,
|
||||||
|
including but not limited to software source code, documentation
|
||||||
|
source, and configuration files.
|
||||||
|
|
||||||
|
"Object" form shall mean any form resulting from mechanical
|
||||||
|
transformation or translation of a Source form, including but
|
||||||
|
not limited to compiled object code, generated documentation,
|
||||||
|
and conversions to other media types.
|
||||||
|
|
||||||
|
"Work" shall mean the work of authorship, whether in Source or
|
||||||
|
Object form, made available under the License, as indicated by a
|
||||||
|
copyright notice that is included in or attached to the work
|
||||||
|
(an example is provided in the Appendix below).
|
||||||
|
|
||||||
|
"Derivative Works" shall mean any work, whether in Source or Object
|
||||||
|
form, that is based on (or derived from) the Work and for which the
|
||||||
|
editorial revisions, annotations, elaborations, or other modifications
|
||||||
|
represent, as a whole, an original work of authorship. For the purposes
|
||||||
|
of this License, Derivative Works shall not include works that remain
|
||||||
|
separable from, or merely link (or bind by name) to the interfaces of,
|
||||||
|
the Work and Derivative Works thereof.
|
||||||
|
|
||||||
|
"Contribution" shall mean any work of authorship, including
|
||||||
|
the original version of the Work and any modifications or additions
|
||||||
|
to that Work or Derivative Works thereof, that is intentionally
|
||||||
|
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||||
|
or by an individual or Legal Entity authorized to submit on behalf of
|
||||||
|
the copyright owner. For the purposes of this definition, "submitted"
|
||||||
|
means any form of electronic, verbal, or written communication sent
|
||||||
|
to the Licensor or its representatives, including but not limited to
|
||||||
|
communication on electronic mailing lists, source code control systems,
|
||||||
|
and issue tracking systems that are managed by, or on behalf of, the
|
||||||
|
Licensor for the purpose of discussing and improving the Work, but
|
||||||
|
excluding communication that is conspicuously marked or otherwise
|
||||||
|
designated in writing by the copyright owner as "Not a Contribution."
|
||||||
|
|
||||||
|
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||||
|
on behalf of whom a Contribution has been received by Licensor and
|
||||||
|
subsequently incorporated within the Work.
|
||||||
|
|
||||||
|
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
copyright license to reproduce, prepare Derivative Works of,
|
||||||
|
publicly display, publicly perform, sublicense, and distribute the
|
||||||
|
Work and such Derivative Works in Source or Object form.
|
||||||
|
|
||||||
|
3. Grant of Patent License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
(except as stated in this section) patent license to make, have made,
|
||||||
|
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||||
|
where such license applies only to those patent claims licensable
|
||||||
|
by such Contributor that are necessarily infringed by their
|
||||||
|
Contribution(s) alone or by combination of their Contribution(s)
|
||||||
|
with the Work to which such Contribution(s) was submitted. If You
|
||||||
|
institute patent litigation against any entity (including a
|
||||||
|
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||||
|
or a Contribution incorporated within the Work constitutes direct
|
||||||
|
or contributory patent infringement, then any patent licenses
|
||||||
|
granted to You under this License for that Work shall terminate
|
||||||
|
as of the date such litigation is filed.
|
||||||
|
|
||||||
|
4. Redistribution. You may reproduce and distribute copies of the
|
||||||
|
Work or Derivative Works thereof in any medium, with or without
|
||||||
|
modifications, and in Source or Object form, provided that You
|
||||||
|
meet the following conditions:
|
||||||
|
|
||||||
|
(a) You must give any other recipients of the Work or
|
||||||
|
Derivative Works a copy of this License; and
|
||||||
|
|
||||||
|
(b) You must cause any modified files to carry prominent notices
|
||||||
|
stating that You changed the files; and
|
||||||
|
|
||||||
|
(c) You must retain, in the Source form of any Derivative Works
|
||||||
|
that You distribute, all copyright, patent, trademark, and
|
||||||
|
attribution notices from the Source form of the Work,
|
||||||
|
excluding those notices that do not pertain to any part of
|
||||||
|
the Derivative Works; and
|
||||||
|
|
||||||
|
(d) If the Work includes a "NOTICE" text file as part of its
|
||||||
|
distribution, then any Derivative Works that You distribute must
|
||||||
|
include a readable copy of the attribution notices contained
|
||||||
|
within such NOTICE file, excluding those notices that do not
|
||||||
|
pertain to any part of the Derivative Works, in at least one
|
||||||
|
of the following places: within a NOTICE text file distributed
|
||||||
|
as part of the Derivative Works; within the Source form or
|
||||||
|
documentation, if provided along with the Derivative Works; or,
|
||||||
|
within a display generated by the Derivative Works, if and
|
||||||
|
wherever such third-party notices normally appear. The contents
|
||||||
|
of the NOTICE file are for informational purposes only and
|
||||||
|
do not modify the License. You may add Your own attribution
|
||||||
|
notices within Derivative Works that You distribute, alongside
|
||||||
|
or as an addendum to the NOTICE text from the Work, provided
|
||||||
|
that such additional attribution notices cannot be construed
|
||||||
|
as modifying the License.
|
||||||
|
|
||||||
|
You may add Your own copyright statement to Your modifications and
|
||||||
|
may provide additional or different license terms and conditions
|
||||||
|
for use, reproduction, or distribution of Your modifications, or
|
||||||
|
for any such Derivative Works as a whole, provided Your use,
|
||||||
|
reproduction, and distribution of the Work otherwise complies with
|
||||||
|
the conditions stated in this License.
|
||||||
|
|
||||||
|
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||||
|
any Contribution intentionally submitted for inclusion in the Work
|
||||||
|
by You to the Licensor shall be under the terms and conditions of
|
||||||
|
this License, without any additional terms or conditions.
|
||||||
|
Notwithstanding the above, nothing herein shall supersede or modify
|
||||||
|
the terms of any separate license agreement you may have executed
|
||||||
|
with Licensor regarding such Contributions.
|
||||||
|
|
||||||
|
6. Trademarks. This License does not grant permission to use the trade
|
||||||
|
names, trademarks, service marks, or product names of the Licensor,
|
||||||
|
except as required for reasonable and customary use in describing the
|
||||||
|
origin of the Work and reproducing the content of the NOTICE file.
|
||||||
|
|
||||||
|
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||||
|
agreed to in writing, Licensor provides the Work (and each
|
||||||
|
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||||
|
implied, including, without limitation, any warranties or conditions
|
||||||
|
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||||
|
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||||
|
appropriateness of using or redistributing the Work and assume any
|
||||||
|
risks associated with Your exercise of permissions under this License.
|
||||||
|
|
||||||
|
8. Limitation of Liability. In no event and under no legal theory,
|
||||||
|
whether in tort (including negligence), contract, or otherwise,
|
||||||
|
unless required by applicable law (such as deliberate and grossly
|
||||||
|
negligent acts) or agreed to in writing, shall any Contributor be
|
||||||
|
liable to You for damages, including any direct, indirect, special,
|
||||||
|
incidental, or consequential damages of any character arising as a
|
||||||
|
result of this License or out of the use or inability to use the
|
||||||
|
Work (including but not limited to damages for loss of goodwill,
|
||||||
|
work stoppage, computer failure or malfunction, or any and all
|
||||||
|
other commercial damages or losses), even if such Contributor
|
||||||
|
has been advised of the possibility of such damages.
|
||||||
|
|
||||||
|
9. Accepting Warranty or Additional Liability. While redistributing
|
||||||
|
the Work or Derivative Works thereof, You may choose to offer,
|
||||||
|
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||||
|
or other liability obligations and/or rights consistent with this
|
||||||
|
License. However, in accepting such obligations, You may act only
|
||||||
|
on Your own behalf and on Your sole responsibility, not on behalf
|
||||||
|
of any other Contributor, and only if You agree to indemnify,
|
||||||
|
defend, and hold each Contributor harmless for any liability
|
||||||
|
incurred by, or claims asserted against, such Contributor by reason
|
||||||
|
of your accepting any such warranty or additional liability.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
APPENDIX: How to apply the Apache License to your work.
|
||||||
|
|
||||||
|
To apply the Apache License to your work, attach the following
|
||||||
|
boilerplate notice, with the fields enclosed by brackets "{}"
|
||||||
|
replaced with your own identifying information. (Don't include
|
||||||
|
the brackets!) The text should be enclosed in the appropriate
|
||||||
|
comment syntax for the file format. We also recommend that a
|
||||||
|
file or class name and description of purpose be included on the
|
||||||
|
same "printed page" as the copyright notice for easier
|
||||||
|
identification within third-party archives.
|
||||||
|
|
||||||
|
Copyright {yyyy} {name of copyright owner}
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
@ -0,0 +1,643 @@
|
|||||||
|
# shUnit2
|
||||||
|
|
||||||
|
shUnit2 is a [xUnit](http://en.wikipedia.org/wiki/XUnit) unit test framework for
|
||||||
|
Bourne based shell scripts, and it is designed to work in a similar manner to
|
||||||
|
[JUnit](http://www.junit.org), [PyUnit](http://pyunit.sourceforge.net), etc.. If
|
||||||
|
you have ever had the desire to write a unit test for a shell script, shUnit2
|
||||||
|
can do the job.
|
||||||
|
|
||||||
|
[![Travis CI](https://api.travis-ci.com/kward/shunit2.svg)](https://app.travis-ci.com/github/kward/shunit2)
|
||||||
|
|
||||||
|
## Table of Contents
|
||||||
|
|
||||||
|
* [Introduction](#introduction)
|
||||||
|
* [Credits / Contributors](#credits-contributors)
|
||||||
|
* [Feedback](#feedback)
|
||||||
|
* [Quickstart](#quickstart)
|
||||||
|
* [Function Reference](#function-reference)
|
||||||
|
* [General Info](#general-info)
|
||||||
|
* [Asserts](#asserts)
|
||||||
|
* [Failures](#failures)
|
||||||
|
* [Setup/Teardown](#setup-teardown)
|
||||||
|
* [Skipping](#skipping)
|
||||||
|
* [Suites](#suites)
|
||||||
|
* [Advanced Usage](#advanced-usage)
|
||||||
|
* [Some constants you can use](#some-constants-you-can-use)
|
||||||
|
* [Error Handling](#error-handling)
|
||||||
|
* [Including Line Numbers in Asserts (Macros)](#including-line-numbers-in-asserts-macros)
|
||||||
|
* [Test Skipping](#test-skipping)
|
||||||
|
* [Running specific tests from the command line](#cmd-line-args)
|
||||||
|
* [Appendix](#appendix)
|
||||||
|
* [Getting help](#getting-help)
|
||||||
|
* [Zsh](#zsh)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## <a name="introduction"></a> Introduction
|
||||||
|
|
||||||
|
shUnit2 was originally developed to provide a consistent testing solution for
|
||||||
|
[log4sh][log4sh], a shell based logging framework similar to
|
||||||
|
[log4j](http://logging.apache.org). During the development of that product, a
|
||||||
|
repeated problem of having things work just fine under one shell (`/bin/bash` on
|
||||||
|
Linux to be specific), and then not working under another shell (`/bin/sh` on
|
||||||
|
Solaris) kept coming up. Although several simple tests were run, they were not
|
||||||
|
adequate and did not catch some corner cases. The decision was finally made to
|
||||||
|
write a proper unit test framework after multiple brown-bag releases were made.
|
||||||
|
_Research was done to look for an existing product that met the testing
|
||||||
|
requirements, but no adequate product was found._
|
||||||
|
|
||||||
|
### Tested software
|
||||||
|
|
||||||
|
**Tested Operating Systems** (varies over time)
|
||||||
|
|
||||||
|
OS | Support | Verified
|
||||||
|
----------------------------------- | --------- | --------
|
||||||
|
Ubuntu Linux (14.04.05 LTS) | Travis CI | continuous
|
||||||
|
macOS High Sierra (10.13.3) | Travis CI | continuous
|
||||||
|
FreeBSD | user | unknown
|
||||||
|
Solaris 8, 9, 10 (inc. OpenSolaris) | user | unknown
|
||||||
|
Cygwin | user | unknown
|
||||||
|
|
||||||
|
**Tested Shells**
|
||||||
|
|
||||||
|
* Bourne Shell (__sh__)
|
||||||
|
* BASH - GNU Bourne Again SHell (__bash__)
|
||||||
|
* DASH - Debian Almquist Shell (__dash__)
|
||||||
|
* Korn Shell - AT&T version of the Korn shell (__ksh__)
|
||||||
|
* mksh - MirBSD Korn Shell (__mksh__)
|
||||||
|
* zsh - Zsh (__zsh__) (since 2.1.2) _please see the Zsh shell errata for more information_
|
||||||
|
|
||||||
|
See the appropriate Release Notes for this release
|
||||||
|
(`doc/RELEASE_NOTES-X.X.X.txt`) for the list of actual versions tested.
|
||||||
|
|
||||||
|
### <a name="credits-contributors"></a> Credits / Contributors
|
||||||
|
|
||||||
|
A list of contributors to shUnit2 can be found in `doc/contributors.md`. Many
|
||||||
|
thanks go out to all those who have contributed to make this a better tool.
|
||||||
|
|
||||||
|
shUnit2 is the original product of many hours of work by Kate Ward, the primary
|
||||||
|
author of the code. For related software, check out https://github.com/kward.
|
||||||
|
|
||||||
|
### <a name="feedback"></a> Feedback
|
||||||
|
|
||||||
|
Feedback is most certainly welcome for this document. Send your questions,
|
||||||
|
comments, and criticisms via the
|
||||||
|
[shunit2-users](https://groups.google.com/a/forestent.com/forum/#!forum/shunit2-users/new)
|
||||||
|
forum (created 2018-12-09), or file an issue via
|
||||||
|
https://github.com/kward/shunit2/issues.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## <a name="quickstart"></a> Quickstart
|
||||||
|
|
||||||
|
This section will give a very quick start to running unit tests with shUnit2.
|
||||||
|
More information is located in later sections.
|
||||||
|
|
||||||
|
Here is a quick sample script to show how easy it is to write a unit test in
|
||||||
|
shell. _Note: the script as it stands expects that you are running it from the
|
||||||
|
"examples" directory._
|
||||||
|
|
||||||
|
```sh
|
||||||
|
#! /bin/sh
|
||||||
|
# file: examples/equality_test.sh
|
||||||
|
|
||||||
|
testEquality() {
|
||||||
|
assertEquals 1 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# Load shUnit2.
|
||||||
|
. ../shunit2
|
||||||
|
```
|
||||||
|
|
||||||
|
Running the unit test should give results similar to the following.
|
||||||
|
|
||||||
|
```console
|
||||||
|
$ cd examples
|
||||||
|
$ ./equality_test.sh
|
||||||
|
testEquality
|
||||||
|
|
||||||
|
Ran 1 test.
|
||||||
|
|
||||||
|
OK
|
||||||
|
```
|
||||||
|
|
||||||
|
W00t! You've just run your first successful unit test. So, what just happened?
|
||||||
|
Quite a bit really, and it all happened simply by sourcing the `shunit2`
|
||||||
|
library. The basic functionality for the script above goes like this:
|
||||||
|
|
||||||
|
* When shUnit2 is sourced, it will walk through any functions defined whose name
|
||||||
|
starts with the string `test`, and add those to an internal list of tests to
|
||||||
|
execute. Once a list of test functions to be run has been determined, shunit2
|
||||||
|
will go to work.
|
||||||
|
* Before any tests are executed, shUnit2 again looks for a function, this time
|
||||||
|
one named `oneTimeSetUp()`. If it exists, it will be run. This function is
|
||||||
|
normally used to setup the environment for all tests to be run. Things like
|
||||||
|
creating directories for output or setting environment variables are good to
|
||||||
|
place here. Just so you know, you can also declare a corresponding function
|
||||||
|
named `oneTimeTearDown()` function that does the same thing, but once all the
|
||||||
|
tests have been completed. It is good for removing temporary directories, etc.
|
||||||
|
* shUnit2 is now ready to run tests. Before doing so though, it again looks for
|
||||||
|
another function that might be declared, one named `setUp()`. If the function
|
||||||
|
exists, it will be run before each test. It is good for resetting the
|
||||||
|
environment so that each test starts with a clean slate. **At this stage, the
|
||||||
|
first test is finally run.** The success of the test is recorded for a report
|
||||||
|
that will be generated later. After the test is run, shUnit2 looks for a final
|
||||||
|
function that might be declared, one named `tearDown()`. If it exists, it will
|
||||||
|
be run after each test. It is a good place for cleaning up after each test,
|
||||||
|
maybe doing things like removing files that were created, or removing
|
||||||
|
directories. This set of steps, `setUp() > test() > tearDown()`, is repeated
|
||||||
|
for all of the available tests.
|
||||||
|
* Once all the work is done, shUnit2 will generate the nice report you saw
|
||||||
|
above. A summary of all the successes and failures will be given so that you
|
||||||
|
know how well your code is doing.
|
||||||
|
|
||||||
|
We should now try adding a test that fails. Change your unit test to look like
|
||||||
|
this.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
#! /bin/sh
|
||||||
|
# file: examples/party_test.sh
|
||||||
|
|
||||||
|
testEquality() {
|
||||||
|
assertEquals 1 1
|
||||||
|
}
|
||||||
|
|
||||||
|
testPartyLikeItIs1999() {
|
||||||
|
year=`date '+%Y'`
|
||||||
|
assertEquals "It's not 1999 :-(" '1999' "${year}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Load shUnit2.
|
||||||
|
. ../shunit2
|
||||||
|
```
|
||||||
|
|
||||||
|
So, what did you get? I guess it told you that this isn't 1999. Bummer, eh?
|
||||||
|
Hopefully, you noticed a couple of things that were different about the second
|
||||||
|
test. First, we added an optional message that the user will see if the assert
|
||||||
|
fails. Second, we did comparisons of strings instead of integers as in the first
|
||||||
|
test. It doesn't matter whether you are testing for equality of strings or
|
||||||
|
integers. Both work equally well with shUnit2.
|
||||||
|
|
||||||
|
Hopefully, this is enough to get you started with unit testing. If you want a
|
||||||
|
ton more examples, take a look at the tests provided with [log4sh][log4sh] or
|
||||||
|
[shFlags][shflags]. Both provide excellent examples of more advanced usage.
|
||||||
|
shUnit2 was after all written to meet the unit testing need that
|
||||||
|
[log4sh][log4sh] had.
|
||||||
|
|
||||||
|
If you are using distribution packaged shUnit2 which is accessible from
|
||||||
|
`/usr/bin/shunit2` such as Debian, you can load shUnit2 without specifying its
|
||||||
|
path. So the last 2 lines in the above can be replaced by:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
# Load shUnit2.
|
||||||
|
. shunit2
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## <a name="function-reference"></a> Function Reference
|
||||||
|
|
||||||
|
### <a name="general-info"></a> General Info
|
||||||
|
|
||||||
|
Any string values passed should be properly quoted -- they should be
|
||||||
|
surrounded by single-quote (`'`) or double-quote (`"`) characters -- so that the
|
||||||
|
shell will properly parse them.
|
||||||
|
|
||||||
|
### <a name="asserts"></a> Asserts
|
||||||
|
|
||||||
|
assertEquals [message] expected actual
|
||||||
|
|
||||||
|
Asserts that _expected_ and _actual_ are equal to one another. The _expected_
|
||||||
|
and _actual_ values can be either strings or integer values as both will be
|
||||||
|
treated as strings. The _message_ is optional, and must be quoted.
|
||||||
|
|
||||||
|
assertNotEquals [message] unexpected actual
|
||||||
|
|
||||||
|
Asserts that _unexpected_ and _actual_ are not equal to one another. The
|
||||||
|
_unexpected_ and _actual_ values can be either strings or integer values as both
|
||||||
|
will be treated as strings. The _message_ is optional, and must be quoted.
|
||||||
|
|
||||||
|
assertSame [message] expected actual
|
||||||
|
|
||||||
|
This function is functionally equivalent to `assertEquals`.
|
||||||
|
|
||||||
|
assertNotSame [message] unexpected actual
|
||||||
|
|
||||||
|
This function is functionally equivalent to `assertNotEquals`.
|
||||||
|
|
||||||
|
assertContains [message] container content
|
||||||
|
|
||||||
|
Asserts that _container_ contains _content_. The _container_ and _content_
|
||||||
|
values can be either strings or integer values as both will be treated as
|
||||||
|
strings. The _message_ is optional, and must be quoted.
|
||||||
|
|
||||||
|
assertNotContains [message] container content
|
||||||
|
|
||||||
|
Asserts that _container_ does not contain _content_. The _container_ and
|
||||||
|
_content_ values can be either strings or integer values as both will be treated
|
||||||
|
as strings. The _message_ is optional, and must be quoted.
|
||||||
|
|
||||||
|
assertNull [message] value
|
||||||
|
|
||||||
|
Asserts that _value_ is _null_, or in shell terms, a zero-length string. The
|
||||||
|
_value_ must be a string as an integer value does not translate into a zero-
|
||||||
|
length string. The _message_ is optional, and must be quoted.
|
||||||
|
|
||||||
|
assertNotNull [message] value
|
||||||
|
|
||||||
|
Asserts that _value_ is _not null_, or in shell terms, a non-empty string. The
|
||||||
|
_value_ may be a string or an integer as the latter will be parsed as a non-empty
|
||||||
|
string value. The _message_ is optional, and must be quoted.
|
||||||
|
|
||||||
|
assertTrue [message] condition
|
||||||
|
|
||||||
|
Asserts that a given shell test _condition_ is _true_. The condition can be as
|
||||||
|
simple as a shell _true_ value (the value `0` -- equivalent to
|
||||||
|
`${SHUNIT_TRUE}`), or a more sophisticated shell conditional expression. The
|
||||||
|
_message_ is optional, and must be quoted.
|
||||||
|
|
||||||
|
A sophisticated shell conditional expression is equivalent to what the __if__ or
|
||||||
|
__while__ shell built-ins would use (more specifically, what the __test__
|
||||||
|
command would use). Testing for example whether some value is greater than
|
||||||
|
another value can be done this way.
|
||||||
|
|
||||||
|
assertTrue "[ 34 -gt 23 ]"
|
||||||
|
|
||||||
|
Testing for the ability to read a file can also be done. This particular test
|
||||||
|
will fail.
|
||||||
|
|
||||||
|
assertTrue 'test failed' "[ -r /some/non-existant/file ]"
|
||||||
|
|
||||||
|
As the expressions are standard shell __test__ expressions, it is possible to
|
||||||
|
string multiple expressions together with `-a` and `-o` in the standard fashion.
|
||||||
|
This test will succeed as the entire expression evaluates to _true_.
|
||||||
|
|
||||||
|
assertTrue 'test failed' '[ 1 -eq 1 -a 2 -eq 2 ]'
|
||||||
|
|
||||||
|
<i>One word of warning: be very careful with your quoting as shell is not the
|
||||||
|
most forgiving of bad quoting, and things will fail in strange ways.</i>
|
||||||
|
|
||||||
|
assertFalse [message] condition
|
||||||
|
|
||||||
|
Asserts that a given shell test _condition_ is _false_. The condition can be as
|
||||||
|
simple as a shell _false_ value (the value `1` -- equivalent to
|
||||||
|
`${SHUNIT_FALSE}`), or a more sophisticated shell conditional expression. The
|
||||||
|
_message_ is optional, and must be quoted.
|
||||||
|
|
||||||
|
_For examples of more sophisticated expressions, see `assertTrue`._
|
||||||
|
|
||||||
|
### <a name="failures"></a> Failures
|
||||||
|
|
||||||
|
Just to clarify, failures __do not__ test the various arguments against one
|
||||||
|
another. Failures simply fail, optionally with a message, and that is all they
|
||||||
|
do. If you need to test arguments against one another, use asserts.
|
||||||
|
|
||||||
|
If all failures do is fail, why might one use them? There are times when you may
|
||||||
|
have some very complicated logic that you need to test, and the simple asserts
|
||||||
|
provided are simply not adequate. You can do your own validation of the code,
|
||||||
|
use an `assertTrue ${SHUNIT_TRUE}` if your own tests succeeded, and use a
|
||||||
|
failure to record a failure.
|
||||||
|
|
||||||
|
fail [message]
|
||||||
|
|
||||||
|
Fails the test immediately. The _message_ is optional, and must be quoted.
|
||||||
|
|
||||||
|
failNotEquals [message] unexpected actual
|
||||||
|
|
||||||
|
Fails the test immediately, reporting that the _unexpected_ and _actual_ values
|
||||||
|
are not equal to one another. The _message_ is optional, and must be quoted.
|
||||||
|
|
||||||
|
_Note: no actual comparison of unexpected and actual is done._
|
||||||
|
|
||||||
|
failSame [message] expected actual
|
||||||
|
|
||||||
|
Fails the test immediately, reporting that the _expected_ and _actual_ values
|
||||||
|
are the same. The _message_ is optional, and must be quoted.
|
||||||
|
|
||||||
|
_Note: no actual comparison of expected and actual is done._
|
||||||
|
|
||||||
|
failNotSame [message] expected actual
|
||||||
|
|
||||||
|
Fails the test immediately, reporting that the _expected_ and _actual_ values
|
||||||
|
are not the same. The _message_ is optional, and must be quoted.
|
||||||
|
|
||||||
|
_Note: no actual comparison of expected and actual is done._
|
||||||
|
|
||||||
|
failFound [message] content
|
||||||
|
|
||||||
|
Fails the test immediately, reporting that the _content_ was found. The
|
||||||
|
_message_ is optional, and must be quoted.
|
||||||
|
|
||||||
|
_Note: no actual search of content is done._
|
||||||
|
|
||||||
|
failNotFound [message] content
|
||||||
|
|
||||||
|
Fails the test immediately, reporting that the _content_ was not found. The
|
||||||
|
_message_ is optional, and must be quoted.
|
||||||
|
|
||||||
|
_Note: no actual search of content is done._
|
||||||
|
|
||||||
|
### <a name="setup-teardown"></a> Setup/Teardown
|
||||||
|
|
||||||
|
oneTimeSetUp
|
||||||
|
|
||||||
|
This function can be optionally overridden by the user in their test suite.
|
||||||
|
|
||||||
|
If this function exists, it will be called once before any tests are run. It is
|
||||||
|
useful to prepare a common environment for all tests.
|
||||||
|
|
||||||
|
oneTimeTearDown
|
||||||
|
|
||||||
|
This function can be optionally overridden by the user in their test suite.
|
||||||
|
|
||||||
|
If this function exists, it will be called once after all tests are completed.
|
||||||
|
It is useful to clean up the environment after all tests.
|
||||||
|
|
||||||
|
setUp
|
||||||
|
|
||||||
|
This function can be optionally overridden by the user in their test suite.
|
||||||
|
|
||||||
|
If this function exists, it will be called before each test is run. It is useful
|
||||||
|
to reset the environment before each test.
|
||||||
|
|
||||||
|
tearDown
|
||||||
|
|
||||||
|
This function can be optionally overridden by the user in their test suite.
|
||||||
|
|
||||||
|
If this function exists, it will be called after each test completes. It is
|
||||||
|
useful to clean up the environment after each test.
|
||||||
|
|
||||||
|
### <a name="skipping"></a> Skipping
|
||||||
|
|
||||||
|
startSkipping
|
||||||
|
|
||||||
|
This function forces the remaining _assert_ and _fail_ functions to be
|
||||||
|
"skipped", i.e. they will have no effect. Each function skipped will be recorded
|
||||||
|
so that the total of asserts and fails will not be altered.
|
||||||
|
|
||||||
|
endSkipping
|
||||||
|
|
||||||
|
This function returns calls to the _assert_ and _fail_ functions to their
|
||||||
|
default behavior, i.e. they will be called.
|
||||||
|
|
||||||
|
isSkipping
|
||||||
|
|
||||||
|
This function returns the current state of skipping. It can be compared against
|
||||||
|
`${SHUNIT_TRUE}` or `${SHUNIT_FALSE}` if desired.
|
||||||
|
|
||||||
|
### <a name="suites"></a> Suites
|
||||||
|
|
||||||
|
The default behavior of shUnit2 is that all tests will be found dynamically. If
|
||||||
|
you have a specific set of tests you want to run, or you don't want to use the
|
||||||
|
standard naming scheme of prefixing your tests with `test`, these functions are
|
||||||
|
for you. Most users will never use them though.
|
||||||
|
|
||||||
|
suite
|
||||||
|
|
||||||
|
This function can be optionally overridden by the user in their test suite.
|
||||||
|
|
||||||
|
If this function exists, it will be called when `shunit2` is sourced. If it does
|
||||||
|
not exist, shUnit2 will search the parent script for all functions beginning
|
||||||
|
with the word `test`, and they will be added dynamically to the test suite.
|
||||||
|
|
||||||
|
suite_addTest name
|
||||||
|
|
||||||
|
This function adds a function named _name_ to the list of tests scheduled for
|
||||||
|
execution as part of this test suite. This function should only be called from
|
||||||
|
within the `suite()` function.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## <a name="advanced-usage"></a> Advanced Usage
|
||||||
|
|
||||||
|
### <a name="some-constants-you-can-use"></a> Some constants you can use
|
||||||
|
|
||||||
|
There are several constants provided by shUnit2 as variables that might be of
|
||||||
|
use to you.
|
||||||
|
|
||||||
|
*Predefined*
|
||||||
|
|
||||||
|
| Constant | Value |
|
||||||
|
| --------------- | ----- |
|
||||||
|
| SHUNIT\_TRUE | Standard shell `true` value (the integer value 0). |
|
||||||
|
| SHUNIT\_FALSE | Standard shell `false` value (the integer value 1). |
|
||||||
|
| SHUNIT\_ERROR | The integer value 2. |
|
||||||
|
| SHUNIT\_TMPDIR | Path to temporary directory that will be automatically cleaned up upon exit of shUnit2. |
|
||||||
|
| SHUNIT\_VERSION | The version of shUnit2 you are running. |
|
||||||
|
|
||||||
|
*User defined*
|
||||||
|
|
||||||
|
| Constant | Value |
|
||||||
|
| ----------------- | ----- |
|
||||||
|
| SHUNIT\_CMD\_EXPR | Override which `expr` command is used. By default `expr` is used, except on BSD systems where `gexpr` is used. |
|
||||||
|
| SHUNIT\_COLOR | Enable colorized output. Options are 'auto', 'always', or 'none', with 'auto' being the default. |
|
||||||
|
| SHUNIT\_PARENT | The filename of the shell script containing the tests. This is needed specifically for Zsh support. |
|
||||||
|
| SHUNIT\_TEST\_PREFIX | Define this variable to add a prefix in front of each test name that is output in the test report. |
|
||||||
|
|
||||||
|
### <a name="error-handling"></a> Error handling
|
||||||
|
|
||||||
|
The constants values `SHUNIT_TRUE`, `SHUNIT_FALSE`, and `SHUNIT_ERROR` are
|
||||||
|
returned from nearly every function to indicate the success or failure of the
|
||||||
|
function. Additionally the variable `flags_error` is filled with a detailed
|
||||||
|
error message if any function returns with a `SHUNIT_ERROR` value.
|
||||||
|
|
||||||
|
### <a name="including-line-numbers-in-asserts-macros"></a> Including Line Numbers in Asserts (Macros)
|
||||||
|
|
||||||
|
If you include lots of assert statements in an individual test function, it can
|
||||||
|
become difficult to determine exactly which assert was thrown unless your
|
||||||
|
messages are unique. To help somewhat, line numbers can be included in the
|
||||||
|
assert messages. To enable this, a special shell "macro" must be used rather
|
||||||
|
than the standard assert calls. _Shell doesn't actually have macros; the name is
|
||||||
|
used here as the operation is similar to a standard macro._
|
||||||
|
|
||||||
|
For example, to include line numbers for a `assertEquals()` function call,
|
||||||
|
replace the `assertEquals()` with `${_ASSERT_EQUALS_}`.
|
||||||
|
|
||||||
|
_**Example** -- Asserts with and without line numbers_
|
||||||
|
|
||||||
|
```shell
|
||||||
|
#! /bin/sh
|
||||||
|
# file: examples/lineno_test.sh
|
||||||
|
|
||||||
|
testLineNo() {
|
||||||
|
# This assert will have line numbers included (e.g. "ASSERT:[123] ...").
|
||||||
|
echo "ae: ${_ASSERT_EQUALS_}"
|
||||||
|
${_ASSERT_EQUALS_} 'not equal' 1 2
|
||||||
|
|
||||||
|
# This assert will not have line numbers included (e.g. "ASSERT: ...").
|
||||||
|
assertEquals 'not equal' 1 2
|
||||||
|
}
|
||||||
|
|
||||||
|
# Load shUnit2.
|
||||||
|
. ../shunit2
|
||||||
|
```
|
||||||
|
|
||||||
|
Notes:
|
||||||
|
|
||||||
|
1. Due to how shell parses command-line arguments, _**all strings used with
|
||||||
|
macros should be quoted twice**_. Namely, single-quotes must be converted to single-double-quotes, and vice-versa.<br/>
|
||||||
|
<br/>
|
||||||
|
Normal `assertEquals` call.<br/>
|
||||||
|
`assertEquals 'some message' 'x' ''`<br/>
|
||||||
|
<br/>
|
||||||
|
Macro `_ASSERT_EQUALS_` call. Note the extra quoting around the _message_ and
|
||||||
|
the _null_ value.<br/>
|
||||||
|
`_ASSERT_EQUALS_ '"some message"' 'x' '""'`
|
||||||
|
|
||||||
|
1. Line numbers are not supported in all shells. If a shell does not support
|
||||||
|
them, no errors will be thrown. Supported shells include: __bash__ (>=3.0),
|
||||||
|
__ksh__, __mksh__, and __zsh__.
|
||||||
|
|
||||||
|
### <a name="test-skipping"></a> Test Skipping
|
||||||
|
|
||||||
|
There are times where the test code you have written is just not applicable to
|
||||||
|
the system you are running on. This section describes how to skip these tests
|
||||||
|
but maintain the total test count.
|
||||||
|
|
||||||
|
Probably the easiest example would be shell code that is meant to run under the
|
||||||
|
__bash__ shell, but the unit test is running under the Bourne shell. There are
|
||||||
|
things that just won't work. The following test code demonstrates two sample
|
||||||
|
functions, one that will be run under any shell, and the another that will run
|
||||||
|
only under the __bash__ shell.
|
||||||
|
|
||||||
|
_**Example** -- math include_
|
||||||
|
```sh
|
||||||
|
# file: examples/math.inc.
|
||||||
|
|
||||||
|
add_generic() {
|
||||||
|
num_a=$1
|
||||||
|
num_b=$2
|
||||||
|
|
||||||
|
expr $1 + $2
|
||||||
|
}
|
||||||
|
|
||||||
|
add_bash() {
|
||||||
|
num_a=$1
|
||||||
|
num_b=$2
|
||||||
|
|
||||||
|
echo $(($1 + $2))
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
And here is a corresponding unit test that correctly skips the `add_bash()` function when the unit test is not running under the __bash__ shell.
|
||||||
|
|
||||||
|
_**Example** -- math unit test_
|
||||||
|
```sh
|
||||||
|
#! /bin/sh
|
||||||
|
# file: examples/math_test.sh
|
||||||
|
|
||||||
|
testAdding() {
|
||||||
|
result=`add_generic 1 2`
|
||||||
|
assertEquals \
|
||||||
|
"the result of '${result}' was wrong" \
|
||||||
|
3 "${result}"
|
||||||
|
|
||||||
|
# Disable non-generic tests.
|
||||||
|
[ -z "${BASH_VERSION:-}" ] && startSkipping
|
||||||
|
|
||||||
|
result=`add_bash 1 2`
|
||||||
|
assertEquals \
|
||||||
|
"the result of '${result}' was wrong" \
|
||||||
|
3 "${result}"
|
||||||
|
}
|
||||||
|
|
||||||
|
oneTimeSetUp() {
|
||||||
|
# Load include to test.
|
||||||
|
. ./math.inc
|
||||||
|
}
|
||||||
|
|
||||||
|
# Load and run shUnit2.
|
||||||
|
. ../shunit2
|
||||||
|
```
|
||||||
|
|
||||||
|
Running the above test under the __bash__ shell will result in the following
|
||||||
|
output.
|
||||||
|
|
||||||
|
```console
|
||||||
|
$ /bin/bash math_test.sh
|
||||||
|
testAdding
|
||||||
|
|
||||||
|
Ran 1 test.
|
||||||
|
|
||||||
|
OK
|
||||||
|
```
|
||||||
|
|
||||||
|
But, running the test under any other Unix shell will result in the following
|
||||||
|
output.
|
||||||
|
|
||||||
|
```console
|
||||||
|
$ /bin/ksh math_test.sh
|
||||||
|
testAdding
|
||||||
|
|
||||||
|
Ran 1 test.
|
||||||
|
|
||||||
|
OK (skipped=1)
|
||||||
|
```
|
||||||
|
|
||||||
|
As you can see, the total number of tests has not changed, but the report
|
||||||
|
indicates that some tests were skipped.
|
||||||
|
|
||||||
|
Skipping can be controlled with the following functions: `startSkipping()`,
|
||||||
|
`endSkipping()`, and `isSkipping()`. Once skipping is enabled, it will remain
|
||||||
|
enabled until the end of the current test function call, after which skipping is
|
||||||
|
disabled.
|
||||||
|
|
||||||
|
### <a name="cmd-line-args"></a> Running specific tests from the command line.
|
||||||
|
|
||||||
|
When running a test script, you may override the default set of tests, or the suite-specified set of tests, by providing additional arguments on the command line. Each additional argument after the `--` marker is assumed to be the name of a test function to be run in the order specified. e.g.
|
||||||
|
|
||||||
|
```console
|
||||||
|
test-script.sh -- testOne testTwo otherFunction
|
||||||
|
```
|
||||||
|
|
||||||
|
or
|
||||||
|
|
||||||
|
```console
|
||||||
|
shunit2 test-script.sh testOne testTwo otherFunction
|
||||||
|
```
|
||||||
|
|
||||||
|
In either case, three functions will be run as tests, `testOne`, `testTwo`, and `otherFunction`. Note that the function `otherFunction` would not normally be run by `shunit2` as part of the implicit collection of tests as it's function name does not match the test function name pattern `test*`.
|
||||||
|
|
||||||
|
If a specified test function does not exist, `shunit2` will still attempt to run that function and thereby cause a failure which `shunit2` will catch and mark as a failed test. All other tests will run normally.
|
||||||
|
|
||||||
|
The specification of tests does not affect how `shunit2` looks for and executes the setup and tear down functions, which will still run as expected.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## <a name="appendix"></a> Appendix
|
||||||
|
|
||||||
|
### <a name="getting-help"></a> Getting Help
|
||||||
|
|
||||||
|
For help, please send requests to either the shunit2-users@forestent.com mailing
|
||||||
|
list (archives available on the web at
|
||||||
|
https://groups.google.com/a/forestent.com/forum/#!forum/shunit2-users) or
|
||||||
|
directly to Kate Ward <kate dot ward at forestent dot com>.
|
||||||
|
|
||||||
|
### <a name="zsh"></a> Zsh
|
||||||
|
|
||||||
|
For compatibility with Zsh, there is one requirement that must be met -- the
|
||||||
|
`shwordsplit` option must be set. There are three ways to accomplish this.
|
||||||
|
|
||||||
|
1. In the unit-test script, add the following shell code snippet before sourcing
|
||||||
|
the `shunit2` library.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
setopt shwordsplit
|
||||||
|
```
|
||||||
|
|
||||||
|
2. When invoking __zsh__ from either the command-line or as a script with `#!`,
|
||||||
|
add the `-y` parameter.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
#! /bin/zsh -y
|
||||||
|
```
|
||||||
|
|
||||||
|
3. When invoking __zsh__ from the command-line, add `-o shwordsplit --` as
|
||||||
|
parameters before the script name.
|
||||||
|
|
||||||
|
```console
|
||||||
|
$ zsh -o shwordsplit -- some_script
|
||||||
|
```
|
||||||
|
|
||||||
|
[log4sh]: https://github.com/kward/log4sh
|
||||||
|
[shflags]: https://github.com/kward/shflags
|
@ -0,0 +1,88 @@
|
|||||||
|
#! /bin/sh
|
||||||
|
# vim:et:ft=sh:sts=2:sw=2
|
||||||
|
#
|
||||||
|
# This script runs the provided unit tests and sends the output to the
|
||||||
|
# appropriate file.
|
||||||
|
#
|
||||||
|
# Copyright 2008-2017 Kate Ward. All Rights Reserved.
|
||||||
|
# Released under the Apache 2.0 license.
|
||||||
|
#
|
||||||
|
# Author: kate.ward@forestent.com (Kate Ward)
|
||||||
|
# https://github.com/kward/shunit2
|
||||||
|
#
|
||||||
|
# Source following.
|
||||||
|
# shellcheck disable=SC1090,SC1091
|
||||||
|
# FLAGS variables are dynamically created.
|
||||||
|
# shellcheck disable=SC2154
|
||||||
|
# Disagree with [ p ] && [ q ] vs [ p -a -q ] recommendation.
|
||||||
|
# shellcheck disable=SC2166
|
||||||
|
|
||||||
|
# Treat unset variables as an error.
|
||||||
|
set -u
|
||||||
|
|
||||||
|
die() {
|
||||||
|
[ $# -gt 0 ] && echo "error: $*" >&2
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
BASE_DIR=$(dirname "$0")
|
||||||
|
LIB_DIR="${BASE_DIR}/lib"
|
||||||
|
|
||||||
|
### Load libraries.
|
||||||
|
. "${LIB_DIR}/shflags" || die 'unable to load shflags library'
|
||||||
|
. "${LIB_DIR}/shlib" || die 'unable to load shlib library'
|
||||||
|
. "${LIB_DIR}/versions" || die 'unable to load versions library'
|
||||||
|
|
||||||
|
# Redefining BASE_DIR now that we have the shlib functions. We need BASE_DIR so
|
||||||
|
# that we can properly load things, even in the event that this script is called
|
||||||
|
# from a different directory.
|
||||||
|
BASE_DIR=$(shlib_relToAbsPath "${BASE_DIR}")
|
||||||
|
|
||||||
|
# Define flags.
|
||||||
|
os_name=$(versions_osName |sed 's/ /_/g')
|
||||||
|
os_version=$(versions_osVersion)
|
||||||
|
|
||||||
|
DEFINE_boolean force false 'force overwrite' f
|
||||||
|
DEFINE_string output_dir "${TMPDIR}" 'output dir' d
|
||||||
|
DEFINE_string output_file "${os_name}-${os_version}.txt" 'output file' o
|
||||||
|
DEFINE_string runner 'test_runner' 'unit test runner' r
|
||||||
|
DEFINE_boolean dry_run false "suppress logging to a file" n
|
||||||
|
|
||||||
|
main() {
|
||||||
|
# Determine output filename.
|
||||||
|
# shellcheck disable=SC2154
|
||||||
|
output="${FLAGS_output_dir:+${FLAGS_output_dir}/}${FLAGS_output_file}"
|
||||||
|
output=$(shlib_relToAbsPath "${output}")
|
||||||
|
|
||||||
|
# Checks.
|
||||||
|
if [ "${FLAGS_dry_run}" -eq "${FLAGS_FALSE}" -a -f "${output}" ]; then
|
||||||
|
if [ "${FLAGS_force}" -eq "${FLAGS_TRUE}" ]; then
|
||||||
|
rm -f "${output}"
|
||||||
|
else
|
||||||
|
echo "not overwriting '${output}'" >&2
|
||||||
|
exit "${FLAGS_ERROR}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if [ "${FLAGS_dry_run}" -eq "${FLAGS_FALSE}" ]; then
|
||||||
|
touch "${output}" 2>/dev/null || die "unable to write to '${output}'"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Run tests.
|
||||||
|
(
|
||||||
|
if [ "${FLAGS_dry_run}" -eq "${FLAGS_FALSE}" ]; then
|
||||||
|
"./${FLAGS_runner}" |tee "${output}"
|
||||||
|
else
|
||||||
|
"./${FLAGS_runner}"
|
||||||
|
fi
|
||||||
|
)
|
||||||
|
|
||||||
|
if [ "${FLAGS_dry_run}" -eq "${FLAGS_FALSE}" ]; then
|
||||||
|
echo >&2
|
||||||
|
echo "Output written to '${output}'." >&2
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
FLAGS "$@" || exit $?
|
||||||
|
[ "${FLAGS_help}" -eq "${FLAGS_FALSE}" ] || exit
|
||||||
|
eval set -- "${FLAGS_ARGV}"
|
||||||
|
main "${@:-}"
|
@ -0,0 +1,47 @@
|
|||||||
|
#! /bin/sh
|
||||||
|
#
|
||||||
|
# Initialize the local git hooks this repository.
|
||||||
|
# https://git-scm.com/docs/githooks
|
||||||
|
|
||||||
|
topLevel=$(git rev-parse --show-toplevel)
|
||||||
|
if ! cd "${topLevel}"; then
|
||||||
|
echo "filed to cd into topLevel directory '${topLevel}'"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
hooksDir="${topLevel}/.githooks"
|
||||||
|
if ! hooksPath=$(git config core.hooksPath); then
|
||||||
|
hooksPath="${topLevel}/.git/hooks"
|
||||||
|
fi
|
||||||
|
|
||||||
|
src="${hooksDir}/generic"
|
||||||
|
echo "linking hooks..."
|
||||||
|
for hook in \
|
||||||
|
applypatch-msg \
|
||||||
|
pre-applypatch \
|
||||||
|
post-applypatch \
|
||||||
|
pre-commit \
|
||||||
|
pre-merge-commit \
|
||||||
|
prepare-commit-msg \
|
||||||
|
commit-msg \
|
||||||
|
post-commit \
|
||||||
|
pre-rebase \
|
||||||
|
post-checkout \
|
||||||
|
post-merge \
|
||||||
|
pre-push \
|
||||||
|
pre-receive \
|
||||||
|
update \
|
||||||
|
post-receive \
|
||||||
|
post-update \
|
||||||
|
push-to-checkout \
|
||||||
|
pre-auto-gc \
|
||||||
|
post-rewrite \
|
||||||
|
sendemail-validate \
|
||||||
|
fsmonitor-watchman \
|
||||||
|
p4-pre-submit \
|
||||||
|
post-index-change
|
||||||
|
do
|
||||||
|
echo " ${hook}"
|
||||||
|
dest="${hooksPath}/${hook}"
|
||||||
|
ln -sf "${src}" "${dest}"
|
||||||
|
done
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,39 @@
|
|||||||
|
# vim:et:ft=sh:sts=2:sw=2
|
||||||
|
#
|
||||||
|
# Copyright 2008 Kate Ward. All Rights Reserved.
|
||||||
|
# Released under the LGPL (GNU Lesser General Public License).
|
||||||
|
#
|
||||||
|
# Author: kate.ward@forestent.com (Kate Ward)
|
||||||
|
#
|
||||||
|
# Library of shell functions.
|
||||||
|
|
||||||
|
# Convert a relative path into it's absolute equivalent.
|
||||||
|
#
|
||||||
|
# This function will automatically prepend the current working directory if the
|
||||||
|
# path is not already absolute. It then removes all parent references (../) to
|
||||||
|
# reconstruct the proper absolute path.
|
||||||
|
#
|
||||||
|
# Args:
|
||||||
|
# shlib_path_: string: relative path
|
||||||
|
# Outputs:
|
||||||
|
# string: absolute path
|
||||||
|
shlib_relToAbsPath()
|
||||||
|
{
|
||||||
|
shlib_path_=$1
|
||||||
|
|
||||||
|
# prepend current directory to relative paths
|
||||||
|
echo "${shlib_path_}" |grep '^/' >/dev/null 2>&1 \
|
||||||
|
|| shlib_path_="${PWD}/${shlib_path_}"
|
||||||
|
|
||||||
|
# clean up the path. if all seds supported true regular expressions, then
|
||||||
|
# this is what it would be:
|
||||||
|
shlib_old_=${shlib_path_}
|
||||||
|
while true; do
|
||||||
|
shlib_new_=`echo "${shlib_old_}" |sed 's/[^/]*\/\.\.\/*//;s/\/\.\//\//'`
|
||||||
|
[ "${shlib_old_}" = "${shlib_new_}" ] && break
|
||||||
|
shlib_old_=${shlib_new_}
|
||||||
|
done
|
||||||
|
echo "${shlib_new_}"
|
||||||
|
|
||||||
|
unset shlib_path_ shlib_old_ shlib_new_
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,64 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# vim:et:ft=sh:sts=2:sw=2
|
||||||
|
#
|
||||||
|
# shunit2 unit test for running subset(s) of tests based upon command line args.
|
||||||
|
#
|
||||||
|
# Copyright 2008-2021 Kate Ward. All Rights Reserved.
|
||||||
|
# Released under the Apache 2.0 license.
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# https://github.com/kward/shunit2
|
||||||
|
#
|
||||||
|
# Also shows how non-default tests or a arbitrary subset of tests can be run.
|
||||||
|
#
|
||||||
|
# Disable source following.
|
||||||
|
# shellcheck disable=SC1090,SC1091
|
||||||
|
|
||||||
|
# Load test helpers.
|
||||||
|
. ./shunit2_test_helpers
|
||||||
|
|
||||||
|
CUSTOM_TEST_RAN=''
|
||||||
|
|
||||||
|
# This test does not normally run because it does not begin "test*". Will be
|
||||||
|
# run by setting the arguments to the script to include the name of this test.
|
||||||
|
custom_test() {
|
||||||
|
# Arbitrary assert.
|
||||||
|
assertTrue 0
|
||||||
|
# The true intent is to set this variable, which will be tested below.
|
||||||
|
CUSTOM_TEST_RAN='yup, we ran'
|
||||||
|
}
|
||||||
|
|
||||||
|
# Verify that `customTest()` ran.
|
||||||
|
testCustomTestRan() {
|
||||||
|
assertNotNull "'custom_test()' did not run" "${CUSTOM_TEST_RAN}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Fail if this test runs, which is shouldn't if arguments are set correctly.
|
||||||
|
testShouldFail() {
|
||||||
|
fail 'testShouldFail should not be run if argument parsing works'
|
||||||
|
}
|
||||||
|
|
||||||
|
oneTimeSetUp() {
|
||||||
|
th_oneTimeSetUp
|
||||||
|
}
|
||||||
|
|
||||||
|
# If zero/one argument(s) are provided, this test is being run in it's
|
||||||
|
# entirety, and therefore we want to set the arguments to the script to
|
||||||
|
# (simulate and) test the processing of command-line specified tests. If we
|
||||||
|
# don't, then the "test_will_fail" test will run (by default) and the overall
|
||||||
|
# test will fail.
|
||||||
|
#
|
||||||
|
# However, if two or more arguments are provided, then assume this test script
|
||||||
|
# is being run by hand to experiment with command-line test specification, and
|
||||||
|
# then don't override the user provided arguments.
|
||||||
|
if [ "$#" -le 1 ]; then
|
||||||
|
# We set the arguments in a POSIX way, inasmuch as we can;
|
||||||
|
# helpful tip:
|
||||||
|
# https://unix.stackexchange.com/questions/258512/how-to-remove-a-positional-parameter-from
|
||||||
|
set -- '--' 'custom_test' 'testCustomTestRan'
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Load and run shunit2.
|
||||||
|
# shellcheck disable=SC2034
|
||||||
|
[ -n "${ZSH_VERSION:-}" ] && SHUNIT_PARENT=$0
|
||||||
|
. "${TH_SHUNIT}"
|
@ -0,0 +1,403 @@
|
|||||||
|
#! /bin/sh
|
||||||
|
# vim:et:ft=sh:sts=2:sw=2
|
||||||
|
#
|
||||||
|
# shunit2 unit test for assert functions.
|
||||||
|
#
|
||||||
|
# Copyright 2008-2021 Kate Ward. All Rights Reserved.
|
||||||
|
# Released under the Apache 2.0 license.
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Author: kate.ward@forestent.com (Kate Ward)
|
||||||
|
# https://github.com/kward/shunit2
|
||||||
|
#
|
||||||
|
# In this file, all assert calls under test must be wrapped in () so they do not
|
||||||
|
# influence the metrics of the test itself.
|
||||||
|
#
|
||||||
|
# Disable source following.
|
||||||
|
# shellcheck disable=SC1090,SC1091
|
||||||
|
|
||||||
|
# These variables will be overridden by the test helpers.
|
||||||
|
stdoutF="${TMPDIR:-/tmp}/STDOUT"
|
||||||
|
stderrF="${TMPDIR:-/tmp}/STDERR"
|
||||||
|
|
||||||
|
# Load test helpers.
|
||||||
|
. ./shunit2_test_helpers
|
||||||
|
|
||||||
|
commonEqualsSame() {
|
||||||
|
fn=$1
|
||||||
|
|
||||||
|
# These should succeed.
|
||||||
|
|
||||||
|
desc='equal'
|
||||||
|
if (${fn} 'x' 'x' >"${stdoutF}" 2>"${stderrF}"); then
|
||||||
|
th_assertTrueWithNoOutput "${desc}" $? "${stdoutF}" "${stderrF}"
|
||||||
|
else
|
||||||
|
fail "${desc}: unexpected failure"
|
||||||
|
_showTestOutput
|
||||||
|
fi
|
||||||
|
|
||||||
|
desc='equal_with_message'
|
||||||
|
if (${fn} 'some message' 'x' 'x' >"${stdoutF}" 2>"${stderrF}"); then
|
||||||
|
th_assertTrueWithNoOutput "${desc}" $? "${stdoutF}" "${stderrF}"
|
||||||
|
else
|
||||||
|
fail "${desc}: unexpected failure"
|
||||||
|
_showTestOutput
|
||||||
|
fi
|
||||||
|
|
||||||
|
desc='equal_with_spaces'
|
||||||
|
if (${fn} 'abc def' 'abc def' >"${stdoutF}" 2>"${stderrF}"); then
|
||||||
|
th_assertTrueWithNoOutput "${desc}" $? "${stdoutF}" "${stderrF}"
|
||||||
|
else
|
||||||
|
fail "${desc}: unexpected failure"
|
||||||
|
_showTestOutput
|
||||||
|
fi
|
||||||
|
|
||||||
|
desc='equal_null_values'
|
||||||
|
if (${fn} '' '' >"${stdoutF}" 2>"${stderrF}"); then
|
||||||
|
th_assertTrueWithNoOutput "${desc}" $? "${stdoutF}" "${stderrF}"
|
||||||
|
else
|
||||||
|
fail "${desc}: unexpected failure"
|
||||||
|
_showTestOutput
|
||||||
|
fi
|
||||||
|
|
||||||
|
# These should fail.
|
||||||
|
|
||||||
|
desc='not_equal'
|
||||||
|
if (${fn} 'x' 'y' >"${stdoutF}" 2>"${stderrF}"); then
|
||||||
|
fail "${desc}: expected a failure"
|
||||||
|
_showTestOutput
|
||||||
|
else
|
||||||
|
th_assertFalseWithOutput "${desc}" $? "${stdoutF}" "${stderrF}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
commonNotEqualsSame() {
|
||||||
|
fn=$1
|
||||||
|
|
||||||
|
# These should succeed.
|
||||||
|
|
||||||
|
desc='not_same'
|
||||||
|
if (${fn} 'x' 'y' >"${stdoutF}" 2>"${stderrF}"); then
|
||||||
|
th_assertTrueWithNoOutput "${desc}" $? "${stdoutF}" "${stderrF}"
|
||||||
|
else
|
||||||
|
fail "${desc}: unexpected failure"
|
||||||
|
_showTestOutput
|
||||||
|
fi
|
||||||
|
|
||||||
|
desc='not_same_with_message'
|
||||||
|
if (${fn} 'some message' 'x' 'y' >"${stdoutF}" 2>"${stderrF}"); then
|
||||||
|
th_assertTrueWithNoOutput "${desc}" $? "${stdoutF}" "${stderrF}"
|
||||||
|
else
|
||||||
|
fail "${desc}: unexpected failure"
|
||||||
|
_showTestOutput
|
||||||
|
fi
|
||||||
|
|
||||||
|
# These should fail.
|
||||||
|
|
||||||
|
desc='same'
|
||||||
|
if (${fn} 'x' 'x' >"${stdoutF}" 2>"${stderrF}"); then
|
||||||
|
fail "${desc}: expected a failure"
|
||||||
|
_showTestOutput
|
||||||
|
else
|
||||||
|
th_assertFalseWithOutput "${desc}" $? "${stdoutF}" "${stderrF}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
desc='unequal_null_values'
|
||||||
|
if (${fn} '' '' >"${stdoutF}" 2>"${stderrF}"); then
|
||||||
|
fail "${desc}: expected a failure"
|
||||||
|
_showTestOutput
|
||||||
|
else
|
||||||
|
th_assertFalseWithOutput "${desc}" $? "${stdoutF}" "${stderrF}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
testAssertEquals() { commonEqualsSame 'assertEquals'; }
|
||||||
|
testAssertNotEquals() { commonNotEqualsSame 'assertNotEquals'; }
|
||||||
|
testAssertSame() { commonEqualsSame 'assertSame'; }
|
||||||
|
testAssertNotSame() { commonNotEqualsSame 'assertNotSame'; }
|
||||||
|
|
||||||
|
testAssertContains() {
|
||||||
|
# Content is present.
|
||||||
|
while read -r desc container content; do
|
||||||
|
if (assertContains "${container}" "${content}" >"${stdoutF}" 2>"${stderrF}"); then
|
||||||
|
th_assertTrueWithNoOutput "${desc}" $? "${stdoutF}" "${stderrF}"
|
||||||
|
else
|
||||||
|
fail "${desc}: unexpected failure"
|
||||||
|
_showTestOutput
|
||||||
|
fi
|
||||||
|
done <<EOF
|
||||||
|
abc_at_start abcdef abc
|
||||||
|
bcd_in_middle abcdef bcd
|
||||||
|
def_at_end abcdef def
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# Content missing.
|
||||||
|
while read -r desc container content; do
|
||||||
|
if (assertContains "${container}" "${content}" >"${stdoutF}" 2>"${stderrF}"); then
|
||||||
|
fail "${desc}: unexpected failure"
|
||||||
|
_showTestOutput
|
||||||
|
else
|
||||||
|
th_assertFalseWithOutput "${desc}" $? "${stdoutF}" "${stderrF}"
|
||||||
|
fi
|
||||||
|
done <<EOF
|
||||||
|
xyz_not_present abcdef xyz
|
||||||
|
zab_contains_start abcdef zab
|
||||||
|
efg_contains_end abcdef efg
|
||||||
|
acf_has_parts abcdef acf
|
||||||
|
EOF
|
||||||
|
|
||||||
|
desc="content_starts_with_dash"
|
||||||
|
if (assertContains 'abc -Xabc def' '-Xabc' >"${stdoutF}" 2>"${stderrF}"); then
|
||||||
|
th_assertTrueWithNoOutput "${desc}" $? "${stdoutF}" "${stderrF}"
|
||||||
|
else
|
||||||
|
fail "${desc}: unexpected failure"
|
||||||
|
_showTestOutput
|
||||||
|
fi
|
||||||
|
|
||||||
|
desc="contains_with_message"
|
||||||
|
if (assertContains 'some message' 'abcdef' 'abc' >"${stdoutF}" 2>"${stderrF}"); then
|
||||||
|
th_assertTrueWithNoOutput "${desc}" $? "${stdoutF}" "${stderrF}"
|
||||||
|
else
|
||||||
|
fail "${desc}: unexpected failure"
|
||||||
|
_showTestOutput
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
testAssertNotContains() {
|
||||||
|
# Content not present.
|
||||||
|
while read -r desc container content; do
|
||||||
|
if (assertNotContains "${container}" "${content}" >"${stdoutF}" 2>"${stderrF}"); then
|
||||||
|
th_assertTrueWithNoOutput "${desc}" $? "${stdoutF}" "${stderrF}"
|
||||||
|
else
|
||||||
|
fail "${desc}: unexpected failure"
|
||||||
|
_showTestOutput
|
||||||
|
fi
|
||||||
|
done <<EOF
|
||||||
|
xyz_not_present abcdef xyz
|
||||||
|
zab_contains_start abcdef zab
|
||||||
|
efg_contains_end abcdef efg
|
||||||
|
acf_has_parts abcdef acf
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# Content present.
|
||||||
|
while read -r desc container content; do
|
||||||
|
if (assertNotContains "${container}" "${content}" >"${stdoutF}" 2>"${stderrF}"); then
|
||||||
|
fail "${desc}: expected a failure"
|
||||||
|
_showTestOutput
|
||||||
|
else
|
||||||
|
th_assertFalseWithOutput "${desc}" $? "${stdoutF}" "${stderrF}"
|
||||||
|
fi
|
||||||
|
done <<EOF
|
||||||
|
abc_is_present abcdef abc
|
||||||
|
EOF
|
||||||
|
|
||||||
|
desc='not_contains_with_message'
|
||||||
|
if (assertNotContains 'some message' 'abcdef' 'xyz' >"${stdoutF}" 2>"${stderrF}"); then
|
||||||
|
th_assertTrueWithNoOutput "${desc}" $? "${stdoutF}" "${stderrF}"
|
||||||
|
else
|
||||||
|
fail "${desc}: unexpected failure"
|
||||||
|
_showTestOutput
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
testAssertNull() {
|
||||||
|
while read -r desc value; do
|
||||||
|
if (assertNull "${value}" >"${stdoutF}" 2>"${stderrF}"); then
|
||||||
|
fail "${desc}: unexpected failure"
|
||||||
|
_showTestOutput
|
||||||
|
else
|
||||||
|
th_assertFalseWithOutput "${desc}" $? "${stdoutF}" "${stderrF}"
|
||||||
|
fi
|
||||||
|
done <<'EOF'
|
||||||
|
x_alone x
|
||||||
|
x_double_quote_a x"a
|
||||||
|
x_single_quote_a x'a
|
||||||
|
x_dollar_a x$a
|
||||||
|
x_backtick_a x`a
|
||||||
|
EOF
|
||||||
|
|
||||||
|
desc='null_without_message'
|
||||||
|
if (assertNull '' >"${stdoutF}" 2>"${stderrF}"); then
|
||||||
|
th_assertTrueWithNoOutput "${desc}" $? "${stdoutF}" "${stderrF}"
|
||||||
|
else
|
||||||
|
fail "${desc}: unexpected failure"
|
||||||
|
_showTestOutput
|
||||||
|
fi
|
||||||
|
|
||||||
|
desc='null_with_message'
|
||||||
|
if (assertNull 'some message' '' >"${stdoutF}" 2>"${stderrF}"); then
|
||||||
|
th_assertTrueWithNoOutput "${desc}" $? "${stdoutF}" "${stderrF}"
|
||||||
|
else
|
||||||
|
fail "${desc}: unexpected failure"
|
||||||
|
_showTestOutput
|
||||||
|
fi
|
||||||
|
|
||||||
|
desc='x_is_not_null'
|
||||||
|
if (assertNull 'x' >"${stdoutF}" 2>"${stderrF}"); then
|
||||||
|
fail "${desc}: expected a failure"
|
||||||
|
_showTestOutput
|
||||||
|
else
|
||||||
|
th_assertFalseWithOutput "${desc}" $? "${stdoutF}" "${stderrF}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
testAssertNotNull() {
|
||||||
|
while read -r desc value; do
|
||||||
|
if (assertNotNull "${value}" >"${stdoutF}" 2>"${stderrF}"); then
|
||||||
|
th_assertTrueWithNoOutput "${desc}" $? "${stdoutF}" "${stderrF}"
|
||||||
|
else
|
||||||
|
fail "${desc}: unexpected failure"
|
||||||
|
_showTestOutput
|
||||||
|
fi
|
||||||
|
done <<'EOF'
|
||||||
|
x_alone x
|
||||||
|
x_double_quote_b x"b
|
||||||
|
x_single_quote_b x'b
|
||||||
|
x_dollar_b x$b
|
||||||
|
x_backtick_b x`b
|
||||||
|
EOF
|
||||||
|
|
||||||
|
desc='not_null_with_message'
|
||||||
|
if (assertNotNull 'some message' 'x' >"${stdoutF}" 2>"${stderrF}"); then
|
||||||
|
th_assertTrueWithNoOutput "${desc}" $? "${stdoutF}" "${stderrF}"
|
||||||
|
else
|
||||||
|
fail "${desc}: unexpected failure"
|
||||||
|
_showTestOutput
|
||||||
|
fi
|
||||||
|
|
||||||
|
desc="double_ticks_are_null"
|
||||||
|
if (assertNotNull '' >"${stdoutF}" 2>"${stderrF}"); then
|
||||||
|
fail "${desc}: expected a failure"
|
||||||
|
_showTestOutput
|
||||||
|
else
|
||||||
|
th_assertFalseWithOutput "${desc}" $? "${stdoutF}" "${stderrF}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
testAssertTrue() {
|
||||||
|
# True values.
|
||||||
|
while read -r desc value; do
|
||||||
|
if (assertTrue "${value}" >"${stdoutF}" 2>"${stderrF}"); then
|
||||||
|
th_assertTrueWithNoOutput "${desc}" $? "${stdoutF}" "${stderrF}"
|
||||||
|
else
|
||||||
|
fail "${desc}: unexpected failure"
|
||||||
|
_showTestOutput
|
||||||
|
fi
|
||||||
|
done <<'EOF'
|
||||||
|
zero 0
|
||||||
|
zero_eq_zero [ 0 -eq 0 ]
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# Not true values.
|
||||||
|
while read -r desc value; do
|
||||||
|
if (assertTrue "${value}" >"${stdoutF}" 2>"${stderrF}"); then
|
||||||
|
fail "${desc}: expected a failure"
|
||||||
|
_showTestOutput
|
||||||
|
else
|
||||||
|
th_assertFalseWithOutput "${desc}" $? "${stdoutF}" "${stderrF}"
|
||||||
|
fi
|
||||||
|
done <<EOF
|
||||||
|
one 1
|
||||||
|
zero_eq_1 [ 0 -eq 1 ]
|
||||||
|
null
|
||||||
|
EOF
|
||||||
|
|
||||||
|
desc='true_with_message'
|
||||||
|
if (assertTrue 'some message' 0 >"${stdoutF}" 2>"${stderrF}"); then
|
||||||
|
th_assertTrueWithNoOutput "${desc}" $? "${stdoutF}" "${stderrF}"
|
||||||
|
else
|
||||||
|
fail "${desc}: unexpected failure"
|
||||||
|
_showTestOutput
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
testAssertFalse() {
|
||||||
|
# False values.
|
||||||
|
while read -r desc value; do
|
||||||
|
if (assertFalse "${value}" >"${stdoutF}" 2>"${stderrF}"); then
|
||||||
|
th_assertTrueWithNoOutput "${desc}" $? "${stdoutF}" "${stderrF}"
|
||||||
|
else
|
||||||
|
fail "${desc}: unexpected failure"
|
||||||
|
_showTestOutput
|
||||||
|
fi
|
||||||
|
done <<EOF
|
||||||
|
one 1
|
||||||
|
zero_eq_1 [ 0 -eq 1 ]
|
||||||
|
null
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# Not true values.
|
||||||
|
while read -r desc value; do
|
||||||
|
if (assertFalse "${value}" >"${stdoutF}" 2>"${stderrF}"); then
|
||||||
|
fail "${desc}: expected a failure"
|
||||||
|
_showTestOutput
|
||||||
|
else
|
||||||
|
th_assertFalseWithOutput "${desc}" $? "${stdoutF}" "${stderrF}"
|
||||||
|
fi
|
||||||
|
done <<'EOF'
|
||||||
|
zero 0
|
||||||
|
zero_eq_zero [ 0 -eq 0 ]
|
||||||
|
EOF
|
||||||
|
|
||||||
|
desc='false_with_message'
|
||||||
|
if (assertFalse 'some message' 1 >"${stdoutF}" 2>"${stderrF}"); then
|
||||||
|
th_assertTrueWithNoOutput "${desc}" $? "${stdoutF}" "${stderrF}"
|
||||||
|
else
|
||||||
|
fail "${desc}: unexpected failure"
|
||||||
|
_showTestOutput
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
FUNCTIONS='
|
||||||
|
assertEquals assertNotEquals
|
||||||
|
assertSame assertNotSame
|
||||||
|
assertContains assertNotContains
|
||||||
|
assertNull assertNotNull
|
||||||
|
assertTrue assertFalse
|
||||||
|
'
|
||||||
|
|
||||||
|
testTooFewArguments() {
|
||||||
|
for fn in ${FUNCTIONS}; do
|
||||||
|
# These functions support zero arguments.
|
||||||
|
case "${fn}" in
|
||||||
|
assertNull) continue ;;
|
||||||
|
assertNotNull) continue ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
desc="${fn}"
|
||||||
|
if (${fn} >"${stdoutF}" 2>"${stderrF}"); then
|
||||||
|
fail "${desc}: expected a failure"
|
||||||
|
_showTestOutput
|
||||||
|
else
|
||||||
|
got=$? want=${SHUNIT_ERROR}
|
||||||
|
assertEquals "${desc}: incorrect return code" "${got}" "${want}"
|
||||||
|
th_assertFalseWithError "${desc}" "${got}" "${stdoutF}" "${stderrF}"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
testTooManyArguments() {
|
||||||
|
for fn in ${FUNCTIONS}; do
|
||||||
|
desc="${fn}"
|
||||||
|
if (${fn} arg1 arg2 arg3 arg4 >"${stdoutF}" 2>"${stderrF}"); then
|
||||||
|
fail "${desc}: expected a failure"
|
||||||
|
_showTestOutput
|
||||||
|
else
|
||||||
|
got=$? want=${SHUNIT_ERROR}
|
||||||
|
assertEquals "${desc}: incorrect return code" "${got}" "${want}"
|
||||||
|
th_assertFalseWithError "${desc}" "${got}" "${stdoutF}" "${stderrF}"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
oneTimeSetUp() {
|
||||||
|
th_oneTimeSetUp
|
||||||
|
}
|
||||||
|
|
||||||
|
# showTestOutput for the most recently run test.
|
||||||
|
_showTestOutput() { th_showOutput "${SHUNIT_FALSE}" "${stdoutF}" "${stderrF}"; }
|
||||||
|
|
||||||
|
# Load and run shunit2.
|
||||||
|
# shellcheck disable=SC2034
|
||||||
|
[ -n "${ZSH_VERSION:-}" ] && SHUNIT_PARENT=$0
|
||||||
|
. "${TH_SHUNIT}"
|
@ -0,0 +1,137 @@
|
|||||||
|
#! /bin/sh
|
||||||
|
# vim:et:ft=sh:sts=2:sw=2
|
||||||
|
#
|
||||||
|
# shUnit2 unit test for failure functions. These functions do not test values.
|
||||||
|
#
|
||||||
|
# Copyright 2008-2021 Kate Ward. All Rights Reserved.
|
||||||
|
# Released under the Apache 2.0 license.
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Author: kate.ward@forestent.com (Kate Ward)
|
||||||
|
# https://github.com/kward/shunit2
|
||||||
|
#
|
||||||
|
# Disable source following.
|
||||||
|
# shellcheck disable=SC1090,SC1091
|
||||||
|
|
||||||
|
# These variables will be overridden by the test helpers.
|
||||||
|
stdoutF="${TMPDIR:-/tmp}/STDOUT"
|
||||||
|
stderrF="${TMPDIR:-/tmp}/STDERR"
|
||||||
|
|
||||||
|
# Load test helpers.
|
||||||
|
. ./shunit2_test_helpers
|
||||||
|
|
||||||
|
testFail() {
|
||||||
|
# Test without a message.
|
||||||
|
desc='fail_without_message'
|
||||||
|
if ( fail >"${stdoutF}" 2>"${stderrF}" ); then
|
||||||
|
fail "${desc}: expected a failure"
|
||||||
|
th_showOutput
|
||||||
|
else
|
||||||
|
th_assertFalseWithOutput "${desc}" $? "${stdoutF}" "${stderrF}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Test with a message.
|
||||||
|
desc='fail_with_message'
|
||||||
|
if ( fail 'some message' >"${stdoutF}" 2>"${stderrF}" ); then
|
||||||
|
fail "${desc}: expected a failure"
|
||||||
|
th_showOutput
|
||||||
|
else
|
||||||
|
th_assertFalseWithOutput "${desc}" $? "${stdoutF}" "${stderrF}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# FN_TESTS hold all the functions to be tested.
|
||||||
|
# shellcheck disable=SC2006
|
||||||
|
FN_TESTS=`
|
||||||
|
# fn num_args pattern
|
||||||
|
cat <<EOF
|
||||||
|
fail 1
|
||||||
|
failNotEquals 3 but was:
|
||||||
|
failFound 2 found:
|
||||||
|
failNotFound 2 not found:
|
||||||
|
failSame 3 not same
|
||||||
|
failNotSame 3 but was:
|
||||||
|
EOF
|
||||||
|
`
|
||||||
|
|
||||||
|
testFailsWithArgs() {
|
||||||
|
echo "${FN_TESTS}" |\
|
||||||
|
while read -r fn num_args pattern; do
|
||||||
|
case "${fn}" in
|
||||||
|
fail) continue ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# Test without a message.
|
||||||
|
desc="${fn}_without_message"
|
||||||
|
if ( ${fn} arg1 arg2 >"${stdoutF}" 2>"${stderrF}" ); then
|
||||||
|
fail "${desc}: expected a failure"
|
||||||
|
th_showOutput
|
||||||
|
else
|
||||||
|
th_assertFalseWithOutput "${desc}" $? "${stdoutF}" "${stderrF}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Test with a message.
|
||||||
|
arg1='' arg2=''
|
||||||
|
case ${num_args} in
|
||||||
|
1) ;;
|
||||||
|
2) arg1='arg1' ;;
|
||||||
|
3) arg1='arg1' arg2='arg2' ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
desc="${fn}_with_message"
|
||||||
|
if ( ${fn} 'some message' ${arg1} ${arg2} >"${stdoutF}" 2>"${stderrF}" ); then
|
||||||
|
fail "${desc}: expected a failure"
|
||||||
|
th_showOutput
|
||||||
|
else
|
||||||
|
th_assertFalseWithOutput "${desc}" $? "${stdoutF}" "${stderrF}"
|
||||||
|
if ! grep -- "${pattern}" "${stdoutF}" >/dev/null; then
|
||||||
|
fail "${desc}: incorrect message to STDOUT"
|
||||||
|
th_showOutput
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
testTooFewArguments() {
|
||||||
|
echo "${FN_TESTS}" \
|
||||||
|
|while read -r fn num_args pattern; do
|
||||||
|
# Skip functions that support a single message argument.
|
||||||
|
if [ "${num_args}" -eq 1 ]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
desc="${fn}"
|
||||||
|
if (${fn} >"${stdoutF}" 2>"${stderrF}"); then
|
||||||
|
fail "${desc}: expected a failure"
|
||||||
|
_showTestOutput
|
||||||
|
else
|
||||||
|
got=$? want=${SHUNIT_ERROR}
|
||||||
|
assertEquals "${desc}: incorrect return code" "${got}" "${want}"
|
||||||
|
th_assertFalseWithError "${desc}" "${got}" "${stdoutF}" "${stderrF}"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
testTooManyArguments() {
|
||||||
|
echo "${FN_TESTS}" \
|
||||||
|
|while read -r fn num_args pattern; do
|
||||||
|
desc="${fn}"
|
||||||
|
if (${fn} arg1 arg2 arg3 arg4 >"${stdoutF}" 2>"${stderrF}"); then
|
||||||
|
fail "${desc}: expected a failure"
|
||||||
|
_showTestOutput
|
||||||
|
else
|
||||||
|
got=$? want=${SHUNIT_ERROR}
|
||||||
|
assertEquals "${desc}: incorrect return code" "${got}" "${want}"
|
||||||
|
th_assertFalseWithError "${desc}" "${got}" "${stdoutF}" "${stderrF}"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
oneTimeSetUp() {
|
||||||
|
th_oneTimeSetUp
|
||||||
|
}
|
||||||
|
|
||||||
|
# Load and run shUnit2.
|
||||||
|
# shellcheck disable=SC2034
|
||||||
|
[ -n "${ZSH_VERSION:-}" ] && SHUNIT_PARENT=$0
|
||||||
|
. "${TH_SHUNIT}"
|
@ -0,0 +1,99 @@
|
|||||||
|
#! /bin/sh
|
||||||
|
# vim:et:ft=sh:sts=2:sw=2
|
||||||
|
#
|
||||||
|
# shUnit2 unit tests for general commands.
|
||||||
|
#
|
||||||
|
# Copyright 2008-2021 Kate Ward. All Rights Reserved.
|
||||||
|
# Released under the Apache 2.0 license.
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Author: kate.ward@forestent.com (Kate Ward)
|
||||||
|
# https://github.com/kward/shunit2
|
||||||
|
#
|
||||||
|
# Disable source following.
|
||||||
|
# shellcheck disable=SC1090,SC1091
|
||||||
|
|
||||||
|
# These variables will be overridden by the test helpers.
|
||||||
|
stdoutF="${TMPDIR:-/tmp}/STDOUT"
|
||||||
|
stderrF="${TMPDIR:-/tmp}/STDERR"
|
||||||
|
|
||||||
|
# Load test helpers.
|
||||||
|
. ./shunit2_test_helpers
|
||||||
|
|
||||||
|
testSkipping() {
|
||||||
|
# We shouldn't be skipping to start.
|
||||||
|
if isSkipping; then
|
||||||
|
th_error 'skipping *should not be* enabled'
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
startSkipping
|
||||||
|
was_skipping_started=${SHUNIT_FALSE}
|
||||||
|
if isSkipping; then was_skipping_started=${SHUNIT_TRUE}; fi
|
||||||
|
|
||||||
|
endSkipping
|
||||||
|
was_skipping_ended=${SHUNIT_FALSE}
|
||||||
|
if isSkipping; then was_skipping_ended=${SHUNIT_TRUE}; fi
|
||||||
|
|
||||||
|
assertEquals "skipping wasn't started" "${was_skipping_started}" "${SHUNIT_TRUE}"
|
||||||
|
assertNotEquals "skipping wasn't ended" "${was_skipping_ended}" "${SHUNIT_TRUE}"
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
testStartSkippingWithMessage() {
|
||||||
|
unittestF="${SHUNIT_TMPDIR}/unittest"
|
||||||
|
sed 's/^#//' >"${unittestF}" <<\EOF
|
||||||
|
## Start skipping with a message.
|
||||||
|
#testSkipping() {
|
||||||
|
# startSkipping 'SKIP-a-Dee-Doo-Dah'
|
||||||
|
#}
|
||||||
|
#SHUNIT_COLOR='none'
|
||||||
|
#. ${TH_SHUNIT}
|
||||||
|
EOF
|
||||||
|
# Ignoring errors with `|| :` as we only care about `FAILED` in the output.
|
||||||
|
( exec "${SHELL:-sh}" "${unittestF}" >"${stdoutF}" 2>"${stderrF}" ) || :
|
||||||
|
if ! grep '\[skipping\] SKIP-a-Dee-Doo-Dah' "${stderrF}" >/dev/null; then
|
||||||
|
fail 'skipping message was not generated'
|
||||||
|
fi
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
testStartSkippingWithoutMessage() {
|
||||||
|
unittestF="${SHUNIT_TMPDIR}/unittest"
|
||||||
|
sed 's/^#//' >"${unittestF}" <<\EOF
|
||||||
|
## Start skipping with a message.
|
||||||
|
#testSkipping() {
|
||||||
|
# startSkipping
|
||||||
|
#}
|
||||||
|
#SHUNIT_COLOR='none'
|
||||||
|
#. ${TH_SHUNIT}
|
||||||
|
EOF
|
||||||
|
# Ignoring errors with `|| :` as we only care about `FAILED` in the output.
|
||||||
|
( exec "${SHELL:-sh}" "${unittestF}" >"${stdoutF}" 2>"${stderrF}" ) || :
|
||||||
|
if grep '\[skipping\]' "${stderrF}" >/dev/null; then
|
||||||
|
fail 'skipping message was unexpectedly generated'
|
||||||
|
fi
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
setUp() {
|
||||||
|
for f in "${stdoutF}" "${stderrF}"; do
|
||||||
|
cp /dev/null "${f}"
|
||||||
|
done
|
||||||
|
|
||||||
|
# Reconfigure coloring as some tests override default behavior.
|
||||||
|
_shunit_configureColor "${SHUNIT_COLOR_DEFAULT}"
|
||||||
|
|
||||||
|
# shellcheck disable=SC2034,SC2153
|
||||||
|
SHUNIT_CMD_TPUT=${__SHUNIT_CMD_TPUT}
|
||||||
|
}
|
||||||
|
|
||||||
|
oneTimeSetUp() {
|
||||||
|
SHUNIT_COLOR_DEFAULT="${SHUNIT_COLOR}"
|
||||||
|
th_oneTimeSetUp
|
||||||
|
}
|
||||||
|
|
||||||
|
# Load and run shUnit2.
|
||||||
|
# shellcheck disable=SC2034
|
||||||
|
[ -n "${ZSH_VERSION:-}" ] && SHUNIT_PARENT=$0
|
||||||
|
. "${TH_SHUNIT}"
|
@ -0,0 +1,247 @@
|
|||||||
|
#! /bin/sh
|
||||||
|
# vim:et:ft=sh:sts=2:sw=2
|
||||||
|
#
|
||||||
|
# shunit2 unit test for macros.
|
||||||
|
#
|
||||||
|
# Copyright 2008-2021 Kate Ward. All Rights Reserved.
|
||||||
|
# Released under the Apache 2.0 license.
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Author: kate.ward@forestent.com (Kate Ward)
|
||||||
|
# https://github.com/kward/shunit2
|
||||||
|
#
|
||||||
|
# Disable source following.
|
||||||
|
# shellcheck disable=SC1090,SC1091
|
||||||
|
|
||||||
|
# These variables will be overridden by the test helpers.
|
||||||
|
stdoutF="${TMPDIR:-/tmp}/STDOUT"
|
||||||
|
stderrF="${TMPDIR:-/tmp}/STDERR"
|
||||||
|
|
||||||
|
# Load test helpers.
|
||||||
|
. ./shunit2_test_helpers
|
||||||
|
|
||||||
|
testAssertEquals() {
|
||||||
|
isLinenoWorking || startSkipping
|
||||||
|
|
||||||
|
( ${_ASSERT_EQUALS_} 'x' 'y' >"${stdoutF}" 2>"${stderrF}" )
|
||||||
|
if ! wasAssertGenerated; then
|
||||||
|
fail '_ASSERT_EQUALS_ failed to produce an ASSERT message'
|
||||||
|
showTestOutput
|
||||||
|
fi
|
||||||
|
|
||||||
|
( ${_ASSERT_EQUALS_} '"some msg"' 'x' 'y' >"${stdoutF}" 2>"${stderrF}" )
|
||||||
|
if ! wasAssertGenerated; then
|
||||||
|
fail '_ASSERT_EQUALS_ (with a message) failed to produce an ASSERT message'
|
||||||
|
showTestOutput
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
testAssertNotEquals() {
|
||||||
|
isLinenoWorking || startSkipping
|
||||||
|
|
||||||
|
( ${_ASSERT_NOT_EQUALS_} 'x' 'x' >"${stdoutF}" 2>"${stderrF}" )
|
||||||
|
if ! wasAssertGenerated; then
|
||||||
|
fail '_ASSERT_NOT_EQUALS_ failed to produce an ASSERT message'
|
||||||
|
showTestOutput
|
||||||
|
fi
|
||||||
|
|
||||||
|
( ${_ASSERT_NOT_EQUALS_} '"some msg"' 'x' 'x' >"${stdoutF}" 2>"${stderrF}" )
|
||||||
|
if ! wasAssertGenerated; then
|
||||||
|
fail '_ASSERT_NOT_EQUALS_ (with a message) failed to produce an ASSERT message'
|
||||||
|
showTestOutput
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
testSame() {
|
||||||
|
isLinenoWorking || startSkipping
|
||||||
|
|
||||||
|
( ${_ASSERT_SAME_} 'x' 'y' >"${stdoutF}" 2>"${stderrF}" )
|
||||||
|
if ! wasAssertGenerated; then
|
||||||
|
fail '_ASSERT_SAME_ failed to produce an ASSERT message'
|
||||||
|
showTestOutput
|
||||||
|
fi
|
||||||
|
|
||||||
|
( ${_ASSERT_SAME_} '"some msg"' 'x' 'y' >"${stdoutF}" 2>"${stderrF}" )
|
||||||
|
if ! wasAssertGenerated; then
|
||||||
|
fail '_ASSERT_SAME_ (with a message) failed to produce an ASSERT message'
|
||||||
|
showTestOutput
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
testNotSame() {
|
||||||
|
isLinenoWorking || startSkipping
|
||||||
|
|
||||||
|
( ${_ASSERT_NOT_SAME_} 'x' 'x' >"${stdoutF}" 2>"${stderrF}" )
|
||||||
|
if ! wasAssertGenerated; then
|
||||||
|
fail '_ASSERT_NOT_SAME_ failed to produce an ASSERT message'
|
||||||
|
showTestOutput
|
||||||
|
fi
|
||||||
|
|
||||||
|
( ${_ASSERT_NOT_SAME_} '"some msg"' 'x' 'x' >"${stdoutF}" 2>"${stderrF}" )
|
||||||
|
if ! wasAssertGenerated; then
|
||||||
|
fail '_ASSERT_NOT_SAME_ (with a message) failed to produce an ASSERT message'
|
||||||
|
showTestOutput
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
testNull() {
|
||||||
|
isLinenoWorking || startSkipping
|
||||||
|
|
||||||
|
( ${_ASSERT_NULL_} 'x' >"${stdoutF}" 2>"${stderrF}" )
|
||||||
|
if ! wasAssertGenerated; then
|
||||||
|
fail '_ASSERT_NULL_ failed to produce an ASSERT message'
|
||||||
|
showTestOutput
|
||||||
|
fi
|
||||||
|
|
||||||
|
( ${_ASSERT_NULL_} '"some msg"' 'x' >"${stdoutF}" 2>"${stderrF}" )
|
||||||
|
if ! wasAssertGenerated; then
|
||||||
|
fail '_ASSERT_NULL_ (with a message) failed to produce an ASSERT message'
|
||||||
|
showTestOutput
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
testNotNull() {
|
||||||
|
isLinenoWorking || startSkipping
|
||||||
|
|
||||||
|
( ${_ASSERT_NOT_NULL_} '' >"${stdoutF}" 2>"${stderrF}" )
|
||||||
|
if ! wasAssertGenerated; then
|
||||||
|
fail '_ASSERT_NOT_NULL_ failed to produce an ASSERT message'
|
||||||
|
showTestOutput
|
||||||
|
fi
|
||||||
|
|
||||||
|
( ${_ASSERT_NOT_NULL_} '"some msg"' '""' >"${stdoutF}" 2>"${stderrF}" )
|
||||||
|
if ! wasAssertGenerated; then
|
||||||
|
fail '_ASSERT_NOT_NULL_ (with a message) failed to produce an ASSERT message'
|
||||||
|
showTestOutput
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
testAssertTrue() {
|
||||||
|
isLinenoWorking || startSkipping
|
||||||
|
|
||||||
|
( ${_ASSERT_TRUE_} "${SHUNIT_FALSE}" >"${stdoutF}" 2>"${stderrF}" )
|
||||||
|
if ! wasAssertGenerated; then
|
||||||
|
fail '_ASSERT_TRUE_ failed to produce an ASSERT message'
|
||||||
|
showTestOutput
|
||||||
|
fi
|
||||||
|
|
||||||
|
( ${_ASSERT_TRUE_} '"some msg"' "${SHUNIT_FALSE}" >"${stdoutF}" 2>"${stderrF}" )
|
||||||
|
if ! wasAssertGenerated; then
|
||||||
|
fail '_ASSERT_TRUE_ (with a message) failed to produce an ASSERT message'
|
||||||
|
showTestOutput
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
testAssertFalse() {
|
||||||
|
isLinenoWorking || startSkipping
|
||||||
|
|
||||||
|
( ${_ASSERT_FALSE_} "${SHUNIT_TRUE}" >"${stdoutF}" 2>"${stderrF}" )
|
||||||
|
if ! wasAssertGenerated; then
|
||||||
|
fail '_ASSERT_FALSE_ failed to produce an ASSERT message'
|
||||||
|
showTestOutput
|
||||||
|
fi
|
||||||
|
|
||||||
|
( ${_ASSERT_FALSE_} '"some msg"' "${SHUNIT_TRUE}" >"${stdoutF}" 2>"${stderrF}" )
|
||||||
|
if ! wasAssertGenerated; then
|
||||||
|
fail '_ASSERT_FALSE_ (with a message) failed to produce an ASSERT message'
|
||||||
|
showTestOutput
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
testFail() {
|
||||||
|
isLinenoWorking || startSkipping
|
||||||
|
|
||||||
|
( ${_FAIL_} >"${stdoutF}" 2>"${stderrF}" )
|
||||||
|
if ! wasAssertGenerated; then
|
||||||
|
fail '_FAIL_ failed to produce an ASSERT message'
|
||||||
|
showTestOutput
|
||||||
|
fi
|
||||||
|
|
||||||
|
( ${_FAIL_} '"some msg"' >"${stdoutF}" 2>"${stderrF}" )
|
||||||
|
if ! wasAssertGenerated; then
|
||||||
|
fail '_FAIL_ (with a message) failed to produce an ASSERT message'
|
||||||
|
showTestOutput
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
testFailNotEquals() {
|
||||||
|
isLinenoWorking || startSkipping
|
||||||
|
|
||||||
|
( ${_FAIL_NOT_EQUALS_} 'x' 'y' >"${stdoutF}" 2>"${stderrF}" )
|
||||||
|
if ! wasAssertGenerated; then
|
||||||
|
fail '_FAIL_NOT_EQUALS_ failed to produce an ASSERT message'
|
||||||
|
showTestOutput
|
||||||
|
fi
|
||||||
|
|
||||||
|
( ${_FAIL_NOT_EQUALS_} '"some msg"' 'x' 'y' >"${stdoutF}" 2>"${stderrF}" )
|
||||||
|
if ! wasAssertGenerated; then
|
||||||
|
fail '_FAIL_NOT_EQUALS_ (with a message) failed to produce an ASSERT message'
|
||||||
|
showTestOutput
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
testFailSame() {
|
||||||
|
isLinenoWorking || startSkipping
|
||||||
|
|
||||||
|
( ${_FAIL_SAME_} 'x' 'x' >"${stdoutF}" 2>"${stderrF}" )
|
||||||
|
if ! wasAssertGenerated; then
|
||||||
|
fail '_FAIL_SAME_ failed to produce an ASSERT message'
|
||||||
|
showTestOutput
|
||||||
|
fi
|
||||||
|
|
||||||
|
( ${_FAIL_SAME_} '"some msg"' 'x' 'x' >"${stdoutF}" 2>"${stderrF}" )
|
||||||
|
if ! wasAssertGenerated; then
|
||||||
|
fail '_FAIL_SAME_ (with a message) failed to produce an ASSERT message'
|
||||||
|
showTestOutput
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
testFailNotSame() {
|
||||||
|
isLinenoWorking || startSkipping
|
||||||
|
|
||||||
|
( ${_FAIL_NOT_SAME_} 'x' 'y' >"${stdoutF}" 2>"${stderrF}" )
|
||||||
|
if ! wasAssertGenerated; then
|
||||||
|
fail '_FAIL_NOT_SAME_ failed to produce an ASSERT message'
|
||||||
|
showTestOutput
|
||||||
|
fi
|
||||||
|
|
||||||
|
( ${_FAIL_NOT_SAME_} '"some msg"' 'x' 'y' >"${stdoutF}" 2>"${stderrF}" )
|
||||||
|
if ! wasAssertGenerated; then
|
||||||
|
fail '_FAIL_NOT_SAME_ (with a message) failed to produce an ASSERT message'
|
||||||
|
showTestOutput
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
oneTimeSetUp() {
|
||||||
|
th_oneTimeSetUp
|
||||||
|
|
||||||
|
if ! isLinenoWorking; then
|
||||||
|
# shellcheck disable=SC2016
|
||||||
|
th_warn '${LINENO} is not working for this shell. Tests will be skipped.'
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# isLinenoWorking returns true if the `$LINENO` shell variable works properly.
|
||||||
|
isLinenoWorking() {
|
||||||
|
# shellcheck disable=SC2016
|
||||||
|
ln='eval echo "${LINENO:-}"'
|
||||||
|
case ${ln} in
|
||||||
|
[0-9]*) return "${SHUNIT_TRUE}" ;;
|
||||||
|
-[0-9]*) return "${SHUNIT_FALSE}" ;; # The dash shell produces negative values.
|
||||||
|
esac
|
||||||
|
return "${SHUNIT_FALSE}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# showTestOutput for the most recently run test.
|
||||||
|
showTestOutput() { th_showOutput "${SHUNIT_FALSE}" "${stdoutF}" "${stderrF}"; }
|
||||||
|
|
||||||
|
# wasAssertGenerated returns true if an ASSERT was generated to STDOUT.
|
||||||
|
wasAssertGenerated() { grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null; }
|
||||||
|
|
||||||
|
# Disable output coloring as it breaks the tests.
|
||||||
|
SHUNIT_COLOR='none'; export SHUNIT_COLOR
|
||||||
|
|
||||||
|
# Load and run shUnit2.
|
||||||
|
# shellcheck disable=SC2034
|
||||||
|
[ -n "${ZSH_VERSION:-}" ] && SHUNIT_PARENT="$0"
|
||||||
|
. "${TH_SHUNIT}"
|
@ -0,0 +1,292 @@
|
|||||||
|
#! /bin/sh
|
||||||
|
# vim:et:ft=sh:sts=2:sw=2
|
||||||
|
#
|
||||||
|
# shUnit2 unit tests of miscellaneous things
|
||||||
|
#
|
||||||
|
# Copyright 2008-2021 Kate Ward. All Rights Reserved.
|
||||||
|
# Released under the Apache 2.0 license.
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Author: kate.ward@forestent.com (Kate Ward)
|
||||||
|
# https://github.com/kward/shunit2
|
||||||
|
#
|
||||||
|
# Allow usage of legacy backticked `...` notation instead of $(...).
|
||||||
|
# shellcheck disable=SC2006
|
||||||
|
# Disable source following.
|
||||||
|
# shellcheck disable=SC1090,SC1091
|
||||||
|
|
||||||
|
# These variables will be overridden by the test helpers.
|
||||||
|
stdoutF="${TMPDIR:-/tmp}/STDOUT"
|
||||||
|
stderrF="${TMPDIR:-/tmp}/STDERR"
|
||||||
|
|
||||||
|
# Load test helpers.
|
||||||
|
. ./shunit2_test_helpers
|
||||||
|
|
||||||
|
# Note: the test script is prefixed with '#' chars so that shUnit2 does not
|
||||||
|
# incorrectly interpret the embedded functions as real functions.
|
||||||
|
testUnboundVariable() {
|
||||||
|
unittestF="${SHUNIT_TMPDIR}/unittest"
|
||||||
|
sed 's/^#//' >"${unittestF}" <<EOF
|
||||||
|
## Treat unset variables as an error when performing parameter expansion.
|
||||||
|
#set -u
|
||||||
|
#
|
||||||
|
#boom() { x=\$1; } # This function goes boom if no parameters are passed!
|
||||||
|
#test_boom() {
|
||||||
|
# assertEquals 1 1
|
||||||
|
# boom # No parameter given
|
||||||
|
# assertEquals 0 \$?
|
||||||
|
#}
|
||||||
|
#SHUNIT_COLOR='none'
|
||||||
|
#. ${TH_SHUNIT}
|
||||||
|
EOF
|
||||||
|
if ( exec "${SHELL:-sh}" "${unittestF}" >"${stdoutF}" 2>"${stderrF}" ); then
|
||||||
|
fail 'expected a non-zero exit value'
|
||||||
|
fi
|
||||||
|
if ! grep '^ASSERT:unknown failure' "${stdoutF}" >/dev/null; then
|
||||||
|
fail 'assert message was not generated'
|
||||||
|
fi
|
||||||
|
if ! grep '^Ran [0-9]* test' "${stdoutF}" >/dev/null; then
|
||||||
|
fail 'test count message was not generated'
|
||||||
|
fi
|
||||||
|
if ! grep '^FAILED' "${stdoutF}" >/dev/null; then
|
||||||
|
fail 'failure message was not generated'
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# assertEquals repeats message argument.
|
||||||
|
# https://github.com/kward/shunit2/issues/7
|
||||||
|
testIssue7() {
|
||||||
|
# Disable coloring so 'ASSERT:' lines can be matched correctly.
|
||||||
|
_shunit_configureColor 'none'
|
||||||
|
|
||||||
|
# Ignoring errors with `|| :` as we only care about the message in this test.
|
||||||
|
( assertEquals 'Some message.' 1 2 >"${stdoutF}" 2>"${stderrF}" ) || :
|
||||||
|
diff "${stdoutF}" - >/dev/null <<EOF
|
||||||
|
ASSERT:Some message. expected:<1> but was:<2>
|
||||||
|
EOF
|
||||||
|
rtrn=$?
|
||||||
|
assertEquals "${SHUNIT_TRUE}" "${rtrn}"
|
||||||
|
[ "${rtrn}" -eq "${SHUNIT_TRUE}" ] || cat "${stderrF}" >&2
|
||||||
|
}
|
||||||
|
|
||||||
|
# Support prefixes on test output.
|
||||||
|
# https://github.com/kward/shunit2/issues/29
|
||||||
|
testIssue29() {
|
||||||
|
unittestF="${SHUNIT_TMPDIR}/unittest"
|
||||||
|
sed 's/^#//' >"${unittestF}" <<EOF
|
||||||
|
## Support test prefixes.
|
||||||
|
#test_assert() { assertTrue ${SHUNIT_TRUE}; }
|
||||||
|
#SHUNIT_COLOR='none'
|
||||||
|
#SHUNIT_TEST_PREFIX='--- '
|
||||||
|
#. ${TH_SHUNIT}
|
||||||
|
EOF
|
||||||
|
( exec "${SHELL:-sh}" "${unittestF}" >"${stdoutF}" 2>"${stderrF}" )
|
||||||
|
grep '^--- test_assert' "${stdoutF}" >/dev/null
|
||||||
|
rtrn=$?
|
||||||
|
assertEquals "${SHUNIT_TRUE}" "${rtrn}"
|
||||||
|
[ "${rtrn}" -eq "${SHUNIT_TRUE}" ] || cat "${stdoutF}" >&2
|
||||||
|
}
|
||||||
|
|
||||||
|
# Test that certain external commands sometimes "stubbed" by users are escaped.
|
||||||
|
testIssue54() {
|
||||||
|
for c in mkdir rm cat chmod sed; do
|
||||||
|
if grep "^[^#]*${c} " "${TH_SHUNIT}" | grep -qv "command ${c}"; then
|
||||||
|
fail "external call to ${c} not protected somewhere"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
# shellcheck disable=2016
|
||||||
|
if grep '^[^#]*[^ ] *\[' "${TH_SHUNIT}" | grep -qv '${__SHUNIT_BUILTIN} \['; then
|
||||||
|
fail 'call to [ not protected somewhere'
|
||||||
|
fi
|
||||||
|
# shellcheck disable=2016
|
||||||
|
if grep '^[^#]* *\.' "${TH_SHUNIT}" | grep -qv '${__SHUNIT_BUILTIN} \.'; then
|
||||||
|
fail 'call to . not protected somewhere'
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# shUnit2 should not exit with 0 when it has syntax errors.
|
||||||
|
# https://github.com/kward/shunit2/issues/69
|
||||||
|
testIssue69() {
|
||||||
|
unittestF="${SHUNIT_TMPDIR}/unittest"
|
||||||
|
|
||||||
|
# Note: assertNull not tested as zero arguments == null, which is valid.
|
||||||
|
for t in Equals NotEquals NotNull Same NotSame True False; do
|
||||||
|
assert="assert${t}"
|
||||||
|
sed 's/^#//' >"${unittestF}" <<EOF
|
||||||
|
## Asserts with invalid argument counts should be counted as failures.
|
||||||
|
#test_assert() { ${assert}; }
|
||||||
|
#SHUNIT_COLOR='none'
|
||||||
|
#. ${TH_SHUNIT}
|
||||||
|
EOF
|
||||||
|
# Ignoring errors with `|| :` as we only care about `FAILED` in the output.
|
||||||
|
( exec "${SHELL:-sh}" "${unittestF}" >"${stdoutF}" 2>"${stderrF}" ) || :
|
||||||
|
grep '^FAILED' "${stdoutF}" >/dev/null
|
||||||
|
assertTrue "failure message for ${assert} was not generated" $?
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# Ensure that test fails if setup/teardown functions fail.
|
||||||
|
testIssue77() {
|
||||||
|
unittestF="${SHUNIT_TMPDIR}/unittest"
|
||||||
|
for func in oneTimeSetUp setUp tearDown oneTimeTearDown; do
|
||||||
|
sed 's/^#//' >"${unittestF}" <<EOF
|
||||||
|
## Environment failure should end test.
|
||||||
|
#${func}() { return ${SHUNIT_FALSE}; }
|
||||||
|
#test_true() { assertTrue ${SHUNIT_TRUE}; }
|
||||||
|
#SHUNIT_COLOR='none'
|
||||||
|
#. ${TH_SHUNIT}
|
||||||
|
EOF
|
||||||
|
# Ignoring errors with `|| :` as we only care about `FAILED` in the output.
|
||||||
|
( exec "${SHELL:-sh}" "${unittestF}" ) >"${stdoutF}" 2>"${stderrF}" || :
|
||||||
|
grep '^FAILED' "${stdoutF}" >/dev/null
|
||||||
|
assertTrue "failure of ${func}() did not end test" $?
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# Ensure a test failure is recorded for code containing syntax errors.
|
||||||
|
# https://github.com/kward/shunit2/issues/84
|
||||||
|
testIssue84() {
|
||||||
|
unittestF="${SHUNIT_TMPDIR}/unittest"
|
||||||
|
sed 's/^#//' >"${unittestF}" <<\EOF
|
||||||
|
## Function with syntax error.
|
||||||
|
#syntax_error() { ${!#3442} -334 a$@2[1]; }
|
||||||
|
#test_syntax_error() {
|
||||||
|
# syntax_error
|
||||||
|
# assertTrue ${SHUNIT_TRUE}
|
||||||
|
#}
|
||||||
|
#SHUNIT_COLOR='none'
|
||||||
|
#SHUNIT_TEST_PREFIX='--- '
|
||||||
|
#. ${TH_SHUNIT}
|
||||||
|
EOF
|
||||||
|
# Ignoring errors with `|| :` as we only care about `FAILED` in the output.
|
||||||
|
( exec "${SHELL:-sh}" "${unittestF}" >"${stdoutF}" 2>"${stderrF}" ) || :
|
||||||
|
if ! grep '^FAILED' "${stdoutF}" >/dev/null; then
|
||||||
|
fail 'failure message was not generated'
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Demonstrate that asserts are no longer executed in subshells.
|
||||||
|
# https://github.com/kward/shunit2/issues/123
|
||||||
|
#
|
||||||
|
# NOTE: this test only works if the `${BASH_SUBSHELL}` variable is present.
|
||||||
|
testIssue123() {
|
||||||
|
if [ -z "${BASH_SUBSHELL:-}" ]; then
|
||||||
|
# shellcheck disable=SC2016
|
||||||
|
startSkipping 'The ${BASH_SUBSHELL} variable is unavailable in this shell.'
|
||||||
|
fi
|
||||||
|
# shellcheck disable=SC2016
|
||||||
|
assertTrue 'not in subshell' '[[ ${BASH_SUBSHELL} -eq 0 ]]'
|
||||||
|
}
|
||||||
|
|
||||||
|
testPrepForSourcing() {
|
||||||
|
assertEquals '/abc' "`_shunit_prepForSourcing '/abc'`"
|
||||||
|
assertEquals './abc' "`_shunit_prepForSourcing './abc'`"
|
||||||
|
assertEquals './abc' "`_shunit_prepForSourcing 'abc'`"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Test the various ways of declaring functions.
|
||||||
|
#
|
||||||
|
# Prefixing (then stripping) with comment symbol so these functions aren't
|
||||||
|
# treated as real functions by shUnit2.
|
||||||
|
testExtractTestFunctions() {
|
||||||
|
f="${SHUNIT_TMPDIR}/extract_test_functions"
|
||||||
|
sed 's/^#//' <<EOF >"${f}"
|
||||||
|
## Function on a single line.
|
||||||
|
#testABC() { echo 'ABC'; }
|
||||||
|
## Multi-line function with '{' on next line.
|
||||||
|
#test_def()
|
||||||
|
# {
|
||||||
|
# echo 'def'
|
||||||
|
#}
|
||||||
|
## Multi-line function with '{' on first line.
|
||||||
|
#testG3 () {
|
||||||
|
# echo 'G3'
|
||||||
|
#}
|
||||||
|
## Function with numerical values in name.
|
||||||
|
#function test4() { echo '4'; }
|
||||||
|
## Leading space in front of function.
|
||||||
|
# test5() { echo '5'; }
|
||||||
|
## Function with '_' chars in name.
|
||||||
|
#some_test_function() { echo 'some func'; }
|
||||||
|
## Function that sets variables.
|
||||||
|
#func_with_test_vars() {
|
||||||
|
# testVariable=1234
|
||||||
|
#}
|
||||||
|
## Function with keyword but no parenthesis
|
||||||
|
#function test6 { echo '6'; }
|
||||||
|
## Function with keyword but no parenthesis, multi-line
|
||||||
|
#function test7 {
|
||||||
|
# echo '7';
|
||||||
|
#}
|
||||||
|
## Function with no parenthesis, '{' on next line
|
||||||
|
#function test8
|
||||||
|
#{
|
||||||
|
# echo '8'
|
||||||
|
#}
|
||||||
|
## Function with hyphenated name
|
||||||
|
#test-9() {
|
||||||
|
# echo '9';
|
||||||
|
#}
|
||||||
|
## Function without parenthesis or keyword
|
||||||
|
#test_foobar { echo 'hello world'; }
|
||||||
|
## Function with multiple function keywords
|
||||||
|
#function function test_test_test() { echo 'lorem'; }
|
||||||
|
EOF
|
||||||
|
|
||||||
|
actual=`_shunit_extractTestFunctions "${f}"`
|
||||||
|
assertEquals 'testABC test_def testG3 test4 test5 test6 test7 test8 test-9' "${actual}"
|
||||||
|
}
|
||||||
|
|
||||||
|
testColors() {
|
||||||
|
while read -r cmd colors desc; do
|
||||||
|
SHUNIT_CMD_TPUT=${cmd}
|
||||||
|
want=${colors} got=`_shunit_colors`
|
||||||
|
assertEquals "${desc}: incorrect number of colors;" \
|
||||||
|
"${got}" "${want}"
|
||||||
|
done <<'EOF'
|
||||||
|
missing_tput 16 missing tput command
|
||||||
|
mock_tput 256 mock tput command
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
testColorsWitoutTERM() {
|
||||||
|
SHUNIT_CMD_TPUT='mock_tput'
|
||||||
|
got=`TERM='' _shunit_colors`
|
||||||
|
want=16
|
||||||
|
assertEquals "${got}" "${want}"
|
||||||
|
}
|
||||||
|
|
||||||
|
mock_tput() {
|
||||||
|
if [ -z "${TERM}" ]; then
|
||||||
|
# shellcheck disable=SC2016
|
||||||
|
echo 'tput: No value for $TERM and no -T specified'
|
||||||
|
return 2
|
||||||
|
fi
|
||||||
|
if [ "$1" = 'colors' ]; then
|
||||||
|
echo 256
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
setUp() {
|
||||||
|
for f in "${stdoutF}" "${stderrF}"; do
|
||||||
|
cp /dev/null "${f}"
|
||||||
|
done
|
||||||
|
|
||||||
|
# Reconfigure coloring as some tests override default behavior.
|
||||||
|
_shunit_configureColor "${SHUNIT_COLOR_DEFAULT}"
|
||||||
|
|
||||||
|
# shellcheck disable=SC2034,SC2153
|
||||||
|
SHUNIT_CMD_TPUT=${__SHUNIT_CMD_TPUT}
|
||||||
|
}
|
||||||
|
|
||||||
|
oneTimeSetUp() {
|
||||||
|
SHUNIT_COLOR_DEFAULT="${SHUNIT_COLOR}"
|
||||||
|
th_oneTimeSetUp
|
||||||
|
}
|
||||||
|
|
||||||
|
# Load and run shUnit2.
|
||||||
|
# shellcheck disable=SC2034
|
||||||
|
[ -n "${ZSH_VERSION:-}" ] && SHUNIT_PARENT=$0
|
||||||
|
. "${TH_SHUNIT}"
|
@ -0,0 +1,70 @@
|
|||||||
|
#! /bin/sh
|
||||||
|
# vim:et:ft=sh:sts=2:sw=2
|
||||||
|
#
|
||||||
|
# shUnit2 unit tests for `shopt` support.
|
||||||
|
#
|
||||||
|
# Copyright 2008-2021 Kate Ward. All Rights Reserved.
|
||||||
|
# Released under the Apache 2.0 license.
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Author: kate.ward@forestent.com (Kate Ward)
|
||||||
|
# https://github.com/kward/shunit2
|
||||||
|
#
|
||||||
|
# Disable source following.
|
||||||
|
# shellcheck disable=SC1090,SC1091
|
||||||
|
|
||||||
|
# Load test helpers.
|
||||||
|
. ./shunit2_test_helpers
|
||||||
|
|
||||||
|
# Call shopt from a variable so it can be mocked if it doesn't work.
|
||||||
|
SHOPT_CMD='shopt'
|
||||||
|
|
||||||
|
testNullglob() {
|
||||||
|
isShoptWorking || startSkipping
|
||||||
|
|
||||||
|
nullglob=$(${SHOPT_CMD} nullglob |cut -f2)
|
||||||
|
|
||||||
|
# Test without nullglob.
|
||||||
|
${SHOPT_CMD} -u nullglob
|
||||||
|
assertEquals 'test without nullglob' 0 0
|
||||||
|
|
||||||
|
# Test with nullglob.
|
||||||
|
${SHOPT_CMD} -s nullglob
|
||||||
|
assertEquals 'test with nullglob' 1 1
|
||||||
|
|
||||||
|
# Reset nullglob.
|
||||||
|
if [ "${nullglob}" = "on" ]; then
|
||||||
|
${SHOPT_CMD} -s nullglob
|
||||||
|
else
|
||||||
|
${SHOPT_CMD} -u nullglob
|
||||||
|
fi
|
||||||
|
|
||||||
|
unset nullglob
|
||||||
|
}
|
||||||
|
|
||||||
|
oneTimeSetUp() {
|
||||||
|
th_oneTimeSetUp
|
||||||
|
|
||||||
|
if ! isShoptWorking; then
|
||||||
|
SHOPT_CMD='mock_shopt'
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# isShoptWorking returns true if the `shopt` shell command is available.
|
||||||
|
# NOTE: `shopt` is not defined as part of the POSIX standard.
|
||||||
|
isShoptWorking() {
|
||||||
|
# shellcheck disable=SC2039,SC3044
|
||||||
|
( shopt >/dev/null 2>&1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
mock_shopt() {
|
||||||
|
if [ $# -eq 0 ]; then
|
||||||
|
echo "nullglob off"
|
||||||
|
fi
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
# Load and run shUnit2.
|
||||||
|
# shellcheck disable=SC2034
|
||||||
|
[ -n "${ZSH_VERSION:-}" ] && SHUNIT_PARENT="$0"
|
||||||
|
. "${TH_SHUNIT}"
|
@ -0,0 +1,36 @@
|
|||||||
|
#! /bin/sh
|
||||||
|
# vim:et:ft=sh:sts=2:sw=2
|
||||||
|
#
|
||||||
|
# shUnit2 unit test for standalone operation.
|
||||||
|
#
|
||||||
|
# Copyright 2008-2021 Kate Ward. All Rights Reserved.
|
||||||
|
# Released under the Apache 2.0 license.
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Author: kate.ward@forestent.com (Kate Ward)
|
||||||
|
# https://github.com/kward/shunit2
|
||||||
|
#
|
||||||
|
# This unit test is purely to test that calling shunit2 directly, while passing
|
||||||
|
# the name of a unit test script, works. When run, this script determines if it
|
||||||
|
# is running as a standalone program, and calls main() if it is.
|
||||||
|
#
|
||||||
|
# Disable source following.
|
||||||
|
# shellcheck disable=SC1090,SC1091
|
||||||
|
|
||||||
|
ARGV0=$(basename "$0")
|
||||||
|
|
||||||
|
# Load test helpers.
|
||||||
|
. ./shunit2_test_helpers
|
||||||
|
|
||||||
|
testStandalone() {
|
||||||
|
assertTrue "${SHUNIT_TRUE}"
|
||||||
|
}
|
||||||
|
|
||||||
|
main() {
|
||||||
|
${TH_SHUNIT} "${ARGV0}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Run main() if are running as a standalone script.
|
||||||
|
if [ "${ARGV0}" = 'shunit2_standalone_test.sh' ]; then
|
||||||
|
main "$@"
|
||||||
|
fi
|
@ -1,124 +0,0 @@
|
|||||||
#! /bin/sh
|
|
||||||
# $Id$
|
|
||||||
# vim:et:ft=sh:sts=2:sw=2
|
|
||||||
#
|
|
||||||
# Copyright 2008 Kate Ward. All Rights Reserved.
|
|
||||||
# Released under the LGPL (GNU Lesser General Public License)
|
|
||||||
# Author: kate.ward@forestent.com (Kate Ward)
|
|
||||||
#
|
|
||||||
# shUnit2 unit test suite runner.
|
|
||||||
#
|
|
||||||
# This script runs all the unit tests that can be found, and generates a nice
|
|
||||||
# report of the tests.
|
|
||||||
|
|
||||||
MY_NAME=`basename $0`
|
|
||||||
MY_PATH=`dirname $0`
|
|
||||||
|
|
||||||
PREFIX='shunit2_test_'
|
|
||||||
SHELLS='/bin/sh /bin/bash /bin/dash /bin/ksh /bin/pdksh /bin/zsh'
|
|
||||||
TESTS=''
|
|
||||||
for test in ${PREFIX}[a-z]*.sh; do
|
|
||||||
TESTS="${TESTS} ${test}"
|
|
||||||
done
|
|
||||||
|
|
||||||
# load common unit test functions
|
|
||||||
. ../lib/versions
|
|
||||||
. ./shunit2_test_helpers
|
|
||||||
|
|
||||||
usage()
|
|
||||||
{
|
|
||||||
echo "usage: ${MY_NAME} [-e key=val ...] [-s shell(s)] [-t test(s)]"
|
|
||||||
}
|
|
||||||
|
|
||||||
env=''
|
|
||||||
|
|
||||||
# process command line flags
|
|
||||||
while getopts 'e:hs:t:' opt; do
|
|
||||||
case ${opt} in
|
|
||||||
e) # set an environment variable
|
|
||||||
key=`expr "${OPTARG}" : '\([^=]*\)='`
|
|
||||||
val=`expr "${OPTARG}" : '[^=]*=\(.*\)'`
|
|
||||||
if [ -z "${key}" -o -z "${val}" ]; then
|
|
||||||
usage
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
eval "${key}='${val}'"
|
|
||||||
export ${key}
|
|
||||||
env="${env:+${env} }${key}"
|
|
||||||
;;
|
|
||||||
h) usage; exit 0 ;; # output help
|
|
||||||
s) shells=${OPTARG} ;; # list of shells to run
|
|
||||||
t) tests=${OPTARG} ;; # list of tests to run
|
|
||||||
*) usage; exit 1 ;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
shift `expr ${OPTIND} - 1`
|
|
||||||
|
|
||||||
# fill shells and/or tests
|
|
||||||
shells=${shells:-${SHELLS}}
|
|
||||||
tests=${tests:-${TESTS}}
|
|
||||||
|
|
||||||
# error checking
|
|
||||||
if [ -z "${tests}" ]; then
|
|
||||||
th_error 'no tests found to run; exiting'
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
cat <<EOF
|
|
||||||
#------------------------------------------------------------------------------
|
|
||||||
# System data
|
|
||||||
#
|
|
||||||
|
|
||||||
# test run info
|
|
||||||
shells: ${shells}
|
|
||||||
tests: ${tests}
|
|
||||||
EOF
|
|
||||||
for key in ${env}; do
|
|
||||||
eval "echo \"${key}=\$${key}\""
|
|
||||||
done
|
|
||||||
echo
|
|
||||||
|
|
||||||
# output system data
|
|
||||||
echo "# system info"
|
|
||||||
echo "$ date"
|
|
||||||
date
|
|
||||||
echo
|
|
||||||
|
|
||||||
echo "$ uname -mprsv"
|
|
||||||
uname -mprsv
|
|
||||||
|
|
||||||
#
|
|
||||||
# run tests
|
|
||||||
#
|
|
||||||
|
|
||||||
for shell in ${shells}; do
|
|
||||||
echo
|
|
||||||
|
|
||||||
# check for existance of shell
|
|
||||||
if [ ! -x ${shell} ]; then
|
|
||||||
th_warn "unable to run tests with the ${shell} shell"
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
|
|
||||||
cat <<EOF
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
|
||||||
# Running the test suite with ${shell}
|
|
||||||
#
|
|
||||||
EOF
|
|
||||||
|
|
||||||
SHUNIT_SHELL=${shell} # pass shell onto tests
|
|
||||||
shell_name=`basename ${shell}`
|
|
||||||
shell_version=`versions_shellVersion "${shell}"`
|
|
||||||
|
|
||||||
echo "shell name: ${shell_name}"
|
|
||||||
echo "shell version: ${shell_version}"
|
|
||||||
|
|
||||||
# execute the tests
|
|
||||||
for suite in ${tests}; do
|
|
||||||
suiteName=`expr "${suite}" : "${PREFIX}\(.*\).sh"`
|
|
||||||
echo
|
|
||||||
echo "--- Executing the '${suiteName}' test suite ---"
|
|
||||||
( exec ${shell} ./${suite} 2>&1; )
|
|
||||||
done
|
|
||||||
done
|
|
@ -1,206 +0,0 @@
|
|||||||
#! /bin/sh
|
|
||||||
# $Id$
|
|
||||||
# vim:et:ft=sh:sts=2:sw=2
|
|
||||||
#
|
|
||||||
# Copyright 2008 Kate Ward. All Rights Reserved.
|
|
||||||
# Released under the LGPL (GNU Lesser General Public License)
|
|
||||||
#
|
|
||||||
# Author: kate.ward@forestent.com (Kate Ward)
|
|
||||||
#
|
|
||||||
# shUnit2 unit test for assert functions
|
|
||||||
|
|
||||||
# load test helpers
|
|
||||||
. ./shunit2_test_helpers
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
|
||||||
# suite tests
|
|
||||||
#
|
|
||||||
|
|
||||||
commonEqualsSame()
|
|
||||||
{
|
|
||||||
fn=$1
|
|
||||||
|
|
||||||
( ${fn} 'x' 'x' >"${stdoutF}" 2>"${stderrF}" )
|
|
||||||
th_assertTrueWithNoOutput 'equal' $? "${stdoutF}" "${stderrF}"
|
|
||||||
|
|
||||||
( ${fn} "${MSG}" 'x' 'x' >"${stdoutF}" 2>"${stderrF}" )
|
|
||||||
th_assertTrueWithNoOutput 'equal; with msg' $? "${stdoutF}" "${stderrF}"
|
|
||||||
|
|
||||||
( ${fn} 'abc def' 'abc def' >"${stdoutF}" 2>"${stderrF}" )
|
|
||||||
th_assertTrueWithNoOutput 'equal with spaces' $? "${stdoutF}" "${stderrF}"
|
|
||||||
|
|
||||||
( ${fn} 'x' 'y' >"${stdoutF}" 2>"${stderrF}" )
|
|
||||||
th_assertFalseWithOutput 'not equal' $? "${stdoutF}" "${stderrF}"
|
|
||||||
|
|
||||||
( ${fn} '' '' >"${stdoutF}" 2>"${stderrF}" )
|
|
||||||
th_assertTrueWithNoOutput 'null values' $? "${stdoutF}" "${stderrF}"
|
|
||||||
|
|
||||||
( ${fn} arg1 >"${stdoutF}" 2>"${stderrF}" )
|
|
||||||
th_assertFalseWithError 'too few arguments' $? "${stdoutF}" "${stderrF}"
|
|
||||||
|
|
||||||
( ${fn} arg1 arg2 arg3 arg4 >"${stdoutF}" 2>"${stderrF}" )
|
|
||||||
th_assertFalseWithError 'too many arguments' $? "${stdoutF}" "${stderrF}"
|
|
||||||
}
|
|
||||||
|
|
||||||
commonNotEqualsSame()
|
|
||||||
{
|
|
||||||
fn=$1
|
|
||||||
|
|
||||||
( ${fn} 'x' 'y' >"${stdoutF}" 2>"${stderrF}" )
|
|
||||||
th_assertTrueWithNoOutput 'not same' $? "${stdoutF}" "${stderrF}"
|
|
||||||
|
|
||||||
( ${fn} "${MSG}" 'x' 'y' >"${stdoutF}" 2>"${stderrF}" )
|
|
||||||
th_assertTrueWithNoOutput 'not same, with msg' $? "${stdoutF}" "${stderrF}"
|
|
||||||
|
|
||||||
( ${fn} 'x' 'x' >"${stdoutF}" 2>"${stderrF}" )
|
|
||||||
th_assertFalseWithOutput 'same' $? "${stdoutF}" "${stderrF}"
|
|
||||||
|
|
||||||
( ${fn} '' '' >"${stdoutF}" 2>"${stderrF}" )
|
|
||||||
th_assertFalseWithOutput 'null values' $? "${stdoutF}" "${stderrF}"
|
|
||||||
|
|
||||||
( ${fn} arg1 >"${stdoutF}" 2>"${stderrF}" )
|
|
||||||
th_assertFalseWithError 'too few arguments' $? "${stdoutF}" "${stderrF}"
|
|
||||||
|
|
||||||
( ${fn} arg1 arg2 arg3 arg4 >"${stdoutF}" 2>"${stderrF}" )
|
|
||||||
th_assertFalseWithError 'too many arguments' $? "${stdoutF}" "${stderrF}"
|
|
||||||
}
|
|
||||||
|
|
||||||
testAssertEquals()
|
|
||||||
{
|
|
||||||
commonEqualsSame 'assertEquals'
|
|
||||||
}
|
|
||||||
|
|
||||||
testAssertNotEquals()
|
|
||||||
{
|
|
||||||
commonNotEqualsSame 'assertNotEquals'
|
|
||||||
}
|
|
||||||
|
|
||||||
testAssertSame()
|
|
||||||
{
|
|
||||||
commonEqualsSame 'assertSame'
|
|
||||||
}
|
|
||||||
|
|
||||||
testAssertNotSame()
|
|
||||||
{
|
|
||||||
commonNotEqualsSame 'assertNotSame'
|
|
||||||
}
|
|
||||||
|
|
||||||
testAssertNull()
|
|
||||||
{
|
|
||||||
( assertNull '' >"${stdoutF}" 2>"${stderrF}" )
|
|
||||||
th_assertTrueWithNoOutput 'null' $? "${stdoutF}" "${stderrF}"
|
|
||||||
|
|
||||||
( assertNull "${MSG}" '' >"${stdoutF}" 2>"${stderrF}" )
|
|
||||||
th_assertTrueWithNoOutput 'null, with msg' $? "${stdoutF}" "${stderrF}"
|
|
||||||
|
|
||||||
( assertNull 'x' >"${stdoutF}" 2>"${stderrF}" )
|
|
||||||
th_assertFalseWithOutput 'not null' $? "${stdoutF}" "${stderrF}"
|
|
||||||
|
|
||||||
( assertNull >"${stdoutF}" 2>"${stderrF}" )
|
|
||||||
th_assertFalseWithError 'too few arguments' $? "${stdoutF}" "${stderrF}"
|
|
||||||
|
|
||||||
( assertNull arg1 arg2 arg3 >"${stdoutF}" 2>"${stderrF}" )
|
|
||||||
th_assertFalseWithError 'too many arguments' $? "${stdoutF}" "${stderrF}"
|
|
||||||
}
|
|
||||||
|
|
||||||
testAssertNotNull()
|
|
||||||
{
|
|
||||||
( assertNotNull 'x' >"${stdoutF}" 2>"${stderrF}" )
|
|
||||||
th_assertTrueWithNoOutput 'not null' $? "${stdoutF}" "${stderrF}"
|
|
||||||
|
|
||||||
( assertNotNull "${MSG}" 'x' >"${stdoutF}" 2>"${stderrF}" )
|
|
||||||
th_assertTrueWithNoOutput 'not null, with msg' $? "${stdoutF}" "${stderrF}"
|
|
||||||
|
|
||||||
( assertNotNull 'x"b' >"${stdoutF}" 2>"${stderrF}" )
|
|
||||||
th_assertTrueWithNoOutput 'not null, with double-quote' $? \
|
|
||||||
"${stdoutF}" "${stderrF}"
|
|
||||||
|
|
||||||
( assertNotNull "x'b" >"${stdoutF}" 2>"${stderrF}" )
|
|
||||||
th_assertTrueWithNoOutput 'not null, with single-quote' $? \
|
|
||||||
"${stdoutF}" "${stderrF}"
|
|
||||||
|
|
||||||
( assertNotNull 'x$b' >"${stdoutF}" 2>"${stderrF}" )
|
|
||||||
th_assertTrueWithNoOutput 'not null, with dollar' $? \
|
|
||||||
"${stdoutF}" "${stderrF}"
|
|
||||||
|
|
||||||
( assertNotNull 'x`b' >"${stdoutF}" 2>"${stderrF}" )
|
|
||||||
th_assertTrueWithNoOutput 'not null, with backtick' $? \
|
|
||||||
"${stdoutF}" "${stderrF}"
|
|
||||||
|
|
||||||
( assertNotNull '' >"${stdoutF}" 2>"${stderrF}" )
|
|
||||||
th_assertFalseWithOutput 'null' $? "${stdoutF}" "${stderrF}"
|
|
||||||
|
|
||||||
# there is no test for too few arguments as $1 might actually be null
|
|
||||||
|
|
||||||
( assertNotNull arg1 arg2 arg3 >"${stdoutF}" 2>"${stderrF}" )
|
|
||||||
th_assertFalseWithError 'too many arguments' $? "${stdoutF}" "${stderrF}"
|
|
||||||
}
|
|
||||||
|
|
||||||
testAssertTrue()
|
|
||||||
{
|
|
||||||
( assertTrue 0 >"${stdoutF}" 2>"${stderrF}" )
|
|
||||||
th_assertTrueWithNoOutput 'true' $? "${stdoutF}" "${stderrF}"
|
|
||||||
|
|
||||||
( assertTrue "${MSG}" 0 >"${stdoutF}" 2>"${stderrF}" )
|
|
||||||
th_assertTrueWithNoOutput 'true, with msg' $? "${stdoutF}" "${stderrF}"
|
|
||||||
|
|
||||||
( assertTrue '[ 0 -eq 0 ]' >"${stdoutF}" 2>"${stderrF}" )
|
|
||||||
th_assertTrueWithNoOutput 'true condition' $? "${stdoutF}" "${stderrF}"
|
|
||||||
|
|
||||||
( assertTrue 1 >"${stdoutF}" 2>"${stderrF}" )
|
|
||||||
th_assertFalseWithOutput 'false' $? "${stdoutF}" "${stderrF}"
|
|
||||||
|
|
||||||
( assertTrue '[ 0 -eq 1 ]' >"${stdoutF}" 2>"${stderrF}" )
|
|
||||||
th_assertFalseWithOutput 'false condition' $? "${stdoutF}" "${stderrF}"
|
|
||||||
|
|
||||||
( assertTrue '' >"${stdoutF}" 2>"${stderrF}" )
|
|
||||||
th_assertFalseWithOutput 'null' $? "${stdoutF}" "${stderrF}"
|
|
||||||
|
|
||||||
( assertTrue >"${stdoutF}" 2>"${stderrF}" )
|
|
||||||
th_assertFalseWithError 'too few arguments' $? "${stdoutF}" "${stderrF}"
|
|
||||||
|
|
||||||
( assertTrue arg1 arg2 arg3 >"${stdoutF}" 2>"${stderrF}" )
|
|
||||||
th_assertFalseWithError 'too many arguments' $? "${stdoutF}" "${stderrF}"
|
|
||||||
}
|
|
||||||
|
|
||||||
testAssertFalse()
|
|
||||||
{
|
|
||||||
( assertFalse 1 >"${stdoutF}" 2>"${stderrF}" )
|
|
||||||
th_assertTrueWithNoOutput 'false' $? "${stdoutF}" "${stderrF}"
|
|
||||||
|
|
||||||
( assertFalse "${MSG}" 1 >"${stdoutF}" 2>"${stderrF}" )
|
|
||||||
th_assertTrueWithNoOutput 'false, with msg' $? "${stdoutF}" "${stderrF}"
|
|
||||||
|
|
||||||
( assertFalse '[ 0 -eq 1 ]' >"${stdoutF}" 2>"${stderrF}" )
|
|
||||||
th_assertTrueWithNoOutput 'false condition' $? "${stdoutF}" "${stderrF}"
|
|
||||||
|
|
||||||
( assertFalse 0 >"${stdoutF}" 2>"${stderrF}" )
|
|
||||||
th_assertFalseWithOutput 'true' $? "${stdoutF}" "${stderrF}"
|
|
||||||
|
|
||||||
( assertFalse '[ 0 -eq 0 ]' >"${stdoutF}" 2>"${stderrF}" )
|
|
||||||
th_assertFalseWithOutput 'true condition' $? "${stdoutF}" "${stderrF}"
|
|
||||||
|
|
||||||
( assertFalse '' >"${stdoutF}" 2>"${stderrF}" )
|
|
||||||
th_assertFalseWithOutput 'true condition' $? "${stdoutF}" "${stderrF}"
|
|
||||||
|
|
||||||
( assertFalse >"${stdoutF}" 2>"${stderrF}" )
|
|
||||||
th_assertFalseWithError 'too few arguments' $? "${stdoutF}" "${stderrF}"
|
|
||||||
|
|
||||||
( assertFalse arg1 arg2 arg3 >"${stdoutF}" 2>"${stderrF}" )
|
|
||||||
th_assertFalseWithError 'too many arguments' $? "${stdoutF}" "${stderrF}"
|
|
||||||
}
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
|
||||||
# suite functions
|
|
||||||
#
|
|
||||||
|
|
||||||
oneTimeSetUp()
|
|
||||||
{
|
|
||||||
th_oneTimeSetUp
|
|
||||||
|
|
||||||
MSG='This is a test message'
|
|
||||||
}
|
|
||||||
|
|
||||||
# load and run shUnit2
|
|
||||||
[ -n "${ZSH_VERSION:-}" ] && SHUNIT_PARENT=$0
|
|
||||||
. ${TH_SHUNIT}
|
|
@ -1,86 +0,0 @@
|
|||||||
#! /bin/sh
|
|
||||||
# $Id$
|
|
||||||
# vim:et:ft=sh:sts=2:sw=2
|
|
||||||
#
|
|
||||||
# Copyright 2008 Kate Ward. All Rights Reserved.
|
|
||||||
# Released under the LGPL (GNU Lesser General Public License)
|
|
||||||
#
|
|
||||||
# Author: kate.ward@forestent.com (Kate Ward)
|
|
||||||
#
|
|
||||||
# shUnit2 unit test for failure functions
|
|
||||||
|
|
||||||
# load common unit-test functions
|
|
||||||
. ./shunit2_test_helpers
|
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------
|
|
||||||
# suite tests
|
|
||||||
#
|
|
||||||
|
|
||||||
testFail()
|
|
||||||
{
|
|
||||||
( fail >"${stdoutF}" 2>"${stderrF}" )
|
|
||||||
th_assertFalseWithOutput 'fail' $? "${stdoutF}" "${stderrF}"
|
|
||||||
|
|
||||||
( fail "${MSG}" >"${stdoutF}" 2>"${stderrF}" )
|
|
||||||
th_assertFalseWithOutput 'fail with msg' $? "${stdoutF}" "${stderrF}"
|
|
||||||
|
|
||||||
( fail arg1 >"${stdoutF}" 2>"${stderrF}" )
|
|
||||||
th_assertFalseWithOutput 'too many arguments' $? "${stdoutF}" "${stderrF}"
|
|
||||||
}
|
|
||||||
|
|
||||||
testFailNotEquals()
|
|
||||||
{
|
|
||||||
( failNotEquals 'x' 'x' >"${stdoutF}" 2>"${stderrF}" )
|
|
||||||
th_assertFalseWithOutput 'same' $? "${stdoutF}" "${stderrF}"
|
|
||||||
|
|
||||||
( failNotEquals "${MSG}" 'x' 'x' >"${stdoutF}" 2>"${stderrF}" )
|
|
||||||
th_assertFalseWithOutput 'same with msg' $? "${stdoutF}" "${stderrF}"
|
|
||||||
|
|
||||||
( failNotEquals 'x' 'y' >"${stdoutF}" 2>"${stderrF}" )
|
|
||||||
th_assertFalseWithOutput 'not same' $? "${stdoutF}" "${stderrF}"
|
|
||||||
|
|
||||||
( failNotEquals '' '' >"${stdoutF}" 2>"${stderrF}" )
|
|
||||||
th_assertFalseWithOutput 'null values' $? "${stdoutF}" "${stderrF}"
|
|
||||||
|
|
||||||
( failNotEquals >"${stdoutF}" 2>"${stderrF}" )
|
|
||||||
th_assertFalseWithError 'too few arguments' $? "${stdoutF}" "${stderrF}"
|
|
||||||
|
|
||||||
( failNotEquals arg1 arg2 arg3 arg4 >"${stdoutF}" 2>"${stderrF}" )
|
|
||||||
th_assertFalseWithError 'too many arguments' $? "${stdoutF}" "${stderrF}"
|
|
||||||
}
|
|
||||||
|
|
||||||
testFailSame()
|
|
||||||
{
|
|
||||||
( failSame 'x' 'x' >"${stdoutF}" 2>"${stderrF}" )
|
|
||||||
th_assertFalseWithOutput 'same' $? "${stdoutF}" "${stderrF}"
|
|
||||||
|
|
||||||
( failSame "${MSG}" 'x' 'x' >"${stdoutF}" 2>"${stderrF}" )
|
|
||||||
th_assertFalseWithOutput 'same with msg' $? "${stdoutF}" "${stderrF}"
|
|
||||||
|
|
||||||
( failSame 'x' 'y' >"${stdoutF}" 2>"${stderrF}" )
|
|
||||||
th_assertFalseWithOutput 'not same' $? "${stdoutF}" "${stderrF}"
|
|
||||||
|
|
||||||
( failSame '' '' >"${stdoutF}" 2>"${stderrF}" )
|
|
||||||
th_assertFalseWithOutput 'null values' $? "${stdoutF}" "${stderrF}"
|
|
||||||
|
|
||||||
( failSame >"${stdoutF}" 2>"${stderrF}" )
|
|
||||||
th_assertFalseWithError 'too few arguments' $? "${stdoutF}" "${stderrF}"
|
|
||||||
|
|
||||||
( failSame arg1 arg2 arg3 arg4 >"${stdoutF}" 2>"${stderrF}" )
|
|
||||||
th_assertFalseWithError 'too many arguments' $? "${stdoutF}" "${stderrF}"
|
|
||||||
}
|
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------
|
|
||||||
# suite functions
|
|
||||||
#
|
|
||||||
|
|
||||||
oneTimeSetUp()
|
|
||||||
{
|
|
||||||
th_oneTimeSetUp
|
|
||||||
|
|
||||||
MSG='This is a test message'
|
|
||||||
}
|
|
||||||
|
|
||||||
# load and run shUnit2
|
|
||||||
[ -n "${ZSH_VERSION:-}" ] && SHUNIT_PARENT=$0
|
|
||||||
. ${TH_SHUNIT}
|
|
@ -1,246 +0,0 @@
|
|||||||
#! /bin/sh
|
|
||||||
# $Id$
|
|
||||||
# vim:et:ft=sh:sts=2:sw=2
|
|
||||||
#
|
|
||||||
# Copyright 2008 Kate Ward. All Rights Reserved.
|
|
||||||
# Released under the LGPL (GNU Lesser General Public License)
|
|
||||||
# Author: kate.ward@forestent.com (Kate Ward)
|
|
||||||
#
|
|
||||||
# shUnit2 unit test for macros.
|
|
||||||
|
|
||||||
# load test helpers
|
|
||||||
. ./shunit2_test_helpers
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
|
||||||
# suite tests
|
|
||||||
#
|
|
||||||
|
|
||||||
testAssertEquals()
|
|
||||||
{
|
|
||||||
# start skipping if LINENO not available
|
|
||||||
[ -z "${LINENO:-}" ] && startSkipping
|
|
||||||
|
|
||||||
( ${_ASSERT_EQUALS_} 'x' 'y' >"${stdoutF}" 2>"${stderrF}" )
|
|
||||||
grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null
|
|
||||||
rtrn=$?
|
|
||||||
assertTrue '_ASSERT_EQUALS_ failure' ${rtrn}
|
|
||||||
[ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2
|
|
||||||
|
|
||||||
( ${_ASSERT_EQUALS_} '"some msg"' 'x' 'y' >"${stdoutF}" 2>"${stderrF}" )
|
|
||||||
grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null
|
|
||||||
rtrn=$?
|
|
||||||
assertTrue '_ASSERT_EQUALS_ w/ msg failure' ${rtrn}
|
|
||||||
[ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2
|
|
||||||
}
|
|
||||||
|
|
||||||
testAssertNotEquals()
|
|
||||||
{
|
|
||||||
# start skipping if LINENO not available
|
|
||||||
[ -z "${LINENO:-}" ] && startSkipping
|
|
||||||
|
|
||||||
( ${_ASSERT_NOT_EQUALS_} 'x' 'x' >"${stdoutF}" 2>"${stderrF}" )
|
|
||||||
grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null
|
|
||||||
rtrn=$?
|
|
||||||
assertTrue '_ASSERT_NOT_EQUALS_ failure' ${rtrn}
|
|
||||||
[ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2
|
|
||||||
|
|
||||||
( ${_ASSERT_NOT_EQUALS_} '"some msg"' 'x' 'x' >"${stdoutF}" 2>"${stderrF}" )
|
|
||||||
grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null
|
|
||||||
rtrn=$?
|
|
||||||
assertTrue '_ASSERT_NOT_EQUALS_ w/ msg failure' ${rtrn}
|
|
||||||
[ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2
|
|
||||||
}
|
|
||||||
|
|
||||||
testSame()
|
|
||||||
{
|
|
||||||
# start skipping if LINENO not available
|
|
||||||
[ -z "${LINENO:-}" ] && startSkipping
|
|
||||||
|
|
||||||
( ${_ASSERT_SAME_} 'x' 'y' >"${stdoutF}" 2>"${stderrF}" )
|
|
||||||
grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null
|
|
||||||
rtrn=$?
|
|
||||||
assertTrue '_ASSERT_SAME_ failure' ${rtrn}
|
|
||||||
[ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2
|
|
||||||
|
|
||||||
( ${_ASSERT_SAME_} '"some msg"' 'x' 'y' >"${stdoutF}" 2>"${stderrF}" )
|
|
||||||
grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null
|
|
||||||
rtrn=$?
|
|
||||||
assertTrue '_ASSERT_SAME_ w/ msg failure' ${rtrn}
|
|
||||||
[ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2
|
|
||||||
}
|
|
||||||
|
|
||||||
testNotSame()
|
|
||||||
{
|
|
||||||
# start skipping if LINENO not available
|
|
||||||
[ -z "${LINENO:-}" ] && startSkipping
|
|
||||||
|
|
||||||
( ${_ASSERT_NOT_SAME_} 'x' 'x' >"${stdoutF}" 2>"${stderrF}" )
|
|
||||||
grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null
|
|
||||||
rtrn=$?
|
|
||||||
assertTrue '_ASSERT_NOT_SAME_ failure' ${rtrn}
|
|
||||||
[ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2
|
|
||||||
|
|
||||||
( ${_ASSERT_NOT_SAME_} '"some msg"' 'x' 'x' >"${stdoutF}" 2>"${stderrF}" )
|
|
||||||
grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null
|
|
||||||
rtrn=$?
|
|
||||||
assertTrue '_ASSERT_NOT_SAME_ w/ msg failure' ${rtrn}
|
|
||||||
[ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2
|
|
||||||
}
|
|
||||||
|
|
||||||
testNull()
|
|
||||||
{
|
|
||||||
# start skipping if LINENO not available
|
|
||||||
[ -z "${LINENO:-}" ] && startSkipping
|
|
||||||
|
|
||||||
( ${_ASSERT_NULL_} 'x' >"${stdoutF}" 2>"${stderrF}" )
|
|
||||||
grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null
|
|
||||||
rtrn=$?
|
|
||||||
assertTrue '_ASSERT_NULL_ failure' ${rtrn}
|
|
||||||
[ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2
|
|
||||||
|
|
||||||
( ${_ASSERT_NULL_} '"some msg"' 'x' >"${stdoutF}" 2>"${stderrF}" )
|
|
||||||
grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null
|
|
||||||
rtrn=$?
|
|
||||||
assertTrue '_ASSERT_NULL_ w/ msg failure' ${rtrn}
|
|
||||||
[ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2
|
|
||||||
}
|
|
||||||
|
|
||||||
testNotNull()
|
|
||||||
{
|
|
||||||
# start skipping if LINENO not available
|
|
||||||
[ -z "${LINENO:-}" ] && startSkipping
|
|
||||||
|
|
||||||
( ${_ASSERT_NOT_NULL_} '' >"${stdoutF}" 2>"${stderrF}" )
|
|
||||||
grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null
|
|
||||||
rtrn=$?
|
|
||||||
assertTrue '_ASSERT_NOT_NULL_ failure' ${rtrn}
|
|
||||||
[ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2
|
|
||||||
|
|
||||||
( ${_ASSERT_NOT_NULL_} '"some msg"' '""' >"${stdoutF}" 2>"${stderrF}" )
|
|
||||||
grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null
|
|
||||||
rtrn=$?
|
|
||||||
assertTrue '_ASSERT_NOT_NULL_ w/ msg failure' ${rtrn}
|
|
||||||
[ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stdoutF}" "${stderrF}" >&2
|
|
||||||
}
|
|
||||||
|
|
||||||
testAssertTrue()
|
|
||||||
{
|
|
||||||
# start skipping if LINENO not available
|
|
||||||
[ -z "${LINENO:-}" ] && startSkipping
|
|
||||||
|
|
||||||
( ${_ASSERT_TRUE_} ${SHUNIT_FALSE} >"${stdoutF}" 2>"${stderrF}" )
|
|
||||||
grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null
|
|
||||||
rtrn=$?
|
|
||||||
assertTrue '_ASSERT_TRUE_ failure' ${rtrn}
|
|
||||||
[ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2
|
|
||||||
|
|
||||||
|
|
||||||
( ${_ASSERT_TRUE_} '"some msg"' ${SHUNIT_FALSE} >"${stdoutF}" 2>"${stderrF}" )
|
|
||||||
grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null
|
|
||||||
rtrn=$?
|
|
||||||
assertTrue '_ASSERT_TRUE_ w/ msg failure' ${rtrn}
|
|
||||||
[ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2
|
|
||||||
}
|
|
||||||
|
|
||||||
testAssertFalse()
|
|
||||||
{
|
|
||||||
# start skipping if LINENO not available
|
|
||||||
[ -z "${LINENO:-}" ] && startSkipping
|
|
||||||
|
|
||||||
( ${_ASSERT_FALSE_} ${SHUNIT_TRUE} >"${stdoutF}" 2>"${stderrF}" )
|
|
||||||
grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null
|
|
||||||
rtrn=$?
|
|
||||||
assertTrue '_ASSERT_FALSE_ failure' ${rtrn}
|
|
||||||
[ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2
|
|
||||||
|
|
||||||
( ${_ASSERT_FALSE_} '"some msg"' ${SHUNIT_TRUE} >"${stdoutF}" 2>"${stderrF}" )
|
|
||||||
grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null
|
|
||||||
rtrn=$?
|
|
||||||
assertTrue '_ASSERT_FALSE_ w/ msg failure' ${rtrn}
|
|
||||||
[ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2
|
|
||||||
}
|
|
||||||
|
|
||||||
testFail()
|
|
||||||
{
|
|
||||||
# start skipping if LINENO not available
|
|
||||||
[ -z "${LINENO:-}" ] && startSkipping
|
|
||||||
|
|
||||||
( ${_FAIL_} >"${stdoutF}" 2>"${stderrF}" )
|
|
||||||
grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null
|
|
||||||
rtrn=$?
|
|
||||||
assertTrue '_FAIL_ failure' ${rtrn}
|
|
||||||
[ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2
|
|
||||||
|
|
||||||
( ${_FAIL_} '"some msg"' >"${stdoutF}" 2>"${stderrF}" )
|
|
||||||
grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null
|
|
||||||
rtrn=$?
|
|
||||||
assertTrue '_FAIL_ w/ msg failure' ${rtrn}
|
|
||||||
[ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2
|
|
||||||
}
|
|
||||||
|
|
||||||
testFailNotEquals()
|
|
||||||
{
|
|
||||||
# start skipping if LINENO not available
|
|
||||||
[ -z "${LINENO:-}" ] && startSkipping
|
|
||||||
|
|
||||||
( ${_FAIL_NOT_EQUALS_} 'x' 'y' >"${stdoutF}" 2>"${stderrF}" )
|
|
||||||
grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null
|
|
||||||
rtrn=$?
|
|
||||||
assertTrue '_FAIL_NOT_EQUALS_ failure' ${rtrn}
|
|
||||||
[ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2
|
|
||||||
|
|
||||||
( ${_FAIL_NOT_EQUALS_} '"some msg"' 'x' 'y' >"${stdoutF}" 2>"${stderrF}" )
|
|
||||||
grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null
|
|
||||||
rtrn=$?
|
|
||||||
assertTrue '_FAIL_NOT_EQUALS_ w/ msg failure' ${rtrn}
|
|
||||||
[ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2
|
|
||||||
}
|
|
||||||
|
|
||||||
testFailSame()
|
|
||||||
{
|
|
||||||
# start skipping if LINENO not available
|
|
||||||
[ -z "${LINENO:-}" ] && startSkipping
|
|
||||||
|
|
||||||
( ${_FAIL_SAME_} 'x' 'x' >"${stdoutF}" 2>"${stderrF}" )
|
|
||||||
grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null
|
|
||||||
rtrn=$?
|
|
||||||
assertTrue '_FAIL_SAME_ failure' ${rtrn}
|
|
||||||
[ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2
|
|
||||||
|
|
||||||
( ${_FAIL_SAME_} '"some msg"' 'x' 'x' >"${stdoutF}" 2>"${stderrF}" )
|
|
||||||
grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null
|
|
||||||
rtrn=$?
|
|
||||||
assertTrue '_FAIL_SAME_ w/ msg failure' ${rtrn}
|
|
||||||
[ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2
|
|
||||||
}
|
|
||||||
|
|
||||||
testFailNotSame()
|
|
||||||
{
|
|
||||||
# start skipping if LINENO not available
|
|
||||||
[ -z "${LINENO:-}" ] && startSkipping
|
|
||||||
|
|
||||||
( ${_FAIL_NOT_SAME_} 'x' 'y' >"${stdoutF}" 2>"${stderrF}" )
|
|
||||||
grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null
|
|
||||||
rtrn=$?
|
|
||||||
assertTrue '_FAIL_NOT_SAME_ failure' ${rtrn}
|
|
||||||
[ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2
|
|
||||||
|
|
||||||
( ${_FAIL_NOT_SAME_} '"some msg"' 'x' 'y' >"${stdoutF}" 2>"${stderrF}" )
|
|
||||||
grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null
|
|
||||||
rtrn=$?
|
|
||||||
assertTrue '_FAIL_NOT_SAME_ w/ msg failure' ${rtrn}
|
|
||||||
[ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2
|
|
||||||
}
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
|
||||||
# suite functions
|
|
||||||
#
|
|
||||||
|
|
||||||
oneTimeSetUp()
|
|
||||||
{
|
|
||||||
th_oneTimeSetUp
|
|
||||||
}
|
|
||||||
|
|
||||||
# load and run shUnit2
|
|
||||||
[ -n "${ZSH_VERSION:-}" ] && SHUNIT_PARENT=$0
|
|
||||||
. ${TH_SHUNIT}
|
|
@ -1,160 +0,0 @@
|
|||||||
#! /bin/sh
|
|
||||||
# $Id$
|
|
||||||
# vim:et:ft=sh:sts=2:sw=2
|
|
||||||
#
|
|
||||||
# Copyright 2008 Kate Ward. All Rights Reserved.
|
|
||||||
# Released under the LGPL (GNU Lesser General Public License)
|
|
||||||
#
|
|
||||||
# Author: kate.ward@forestent.com (Kate Ward)
|
|
||||||
#
|
|
||||||
# shUnit2 unit tests of miscellaneous things
|
|
||||||
|
|
||||||
# load test helpers
|
|
||||||
. ./shunit2_test_helpers
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
|
||||||
# suite tests
|
|
||||||
#
|
|
||||||
|
|
||||||
# Note: the test script is prefixed with '#' chars so that shUnit2 does not
|
|
||||||
# incorrectly interpret the embedded functions as real functions.
|
|
||||||
testUnboundVariable()
|
|
||||||
{
|
|
||||||
unittestF="${SHUNIT_TMPDIR}/unittest"
|
|
||||||
sed 's/^#//' >"${unittestF}" <<EOF
|
|
||||||
## treat unset variables as an error when performing parameter expansion
|
|
||||||
#set -u
|
|
||||||
#
|
|
||||||
#boom() { x=\$1; } # this function goes boom if no parameters are passed!
|
|
||||||
#test_boom()
|
|
||||||
#{
|
|
||||||
# assertEquals 1 1
|
|
||||||
# boom # No parameter given
|
|
||||||
# assertEquals 0 \$?
|
|
||||||
#}
|
|
||||||
#. ${TH_SHUNIT}
|
|
||||||
EOF
|
|
||||||
( exec ${SHUNIT_SHELL:-sh} "${unittestF}" >"${stdoutF}" 2>"${stderrF}" )
|
|
||||||
assertFalse 'expected a non-zero exit value' $?
|
|
||||||
grep '^ASSERT:Unknown failure' "${stdoutF}" >/dev/null
|
|
||||||
assertTrue 'assert message was not generated' $?
|
|
||||||
grep '^Ran [0-9]* test' "${stdoutF}" >/dev/null
|
|
||||||
assertTrue 'test count message was not generated' $?
|
|
||||||
grep '^FAILED' "${stdoutF}" >/dev/null
|
|
||||||
assertTrue 'failure message was not generated' $?
|
|
||||||
}
|
|
||||||
|
|
||||||
testIssue7()
|
|
||||||
{
|
|
||||||
( assertEquals 'Some message.' 1 2 >"${stdoutF}" 2>"${stderrF}" )
|
|
||||||
diff "${stdoutF}" - >/dev/null <<EOF
|
|
||||||
ASSERT:Some message. expected:<1> but was:<2>
|
|
||||||
EOF
|
|
||||||
rtrn=$?
|
|
||||||
assertEquals ${SHUNIT_TRUE} ${rtrn}
|
|
||||||
[ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2
|
|
||||||
}
|
|
||||||
|
|
||||||
testPrepForSourcing()
|
|
||||||
{
|
|
||||||
assertEquals '/abc' `_shunit_prepForSourcing '/abc'`
|
|
||||||
assertEquals './abc' `_shunit_prepForSourcing './abc'`
|
|
||||||
assertEquals './abc' `_shunit_prepForSourcing 'abc'`
|
|
||||||
}
|
|
||||||
|
|
||||||
testEscapeCharInStr()
|
|
||||||
{
|
|
||||||
actual=`_shunit_escapeCharInStr '\' ''`
|
|
||||||
assertEquals '' "${actual}"
|
|
||||||
assertEquals 'abc\\' `_shunit_escapeCharInStr '\' 'abc\'`
|
|
||||||
assertEquals 'abc\\def' `_shunit_escapeCharInStr '\' 'abc\def'`
|
|
||||||
assertEquals '\\def' `_shunit_escapeCharInStr '\' '\def'`
|
|
||||||
|
|
||||||
actual=`_shunit_escapeCharInStr '"' ''`
|
|
||||||
assertEquals '' "${actual}"
|
|
||||||
assertEquals 'abc\"' `_shunit_escapeCharInStr '"' 'abc"'`
|
|
||||||
assertEquals 'abc\"def' `_shunit_escapeCharInStr '"' 'abc"def'`
|
|
||||||
assertEquals '\"def' `_shunit_escapeCharInStr '"' '"def'`
|
|
||||||
|
|
||||||
actual=`_shunit_escapeCharInStr '$' ''`
|
|
||||||
assertEquals '' "${actual}"
|
|
||||||
assertEquals 'abc\$' `_shunit_escapeCharInStr '$' 'abc$'`
|
|
||||||
assertEquals 'abc\$def' `_shunit_escapeCharInStr '$' 'abc$def'`
|
|
||||||
assertEquals '\$def' `_shunit_escapeCharInStr '$' '$def'`
|
|
||||||
|
|
||||||
# actual=`_shunit_escapeCharInStr "'" ''`
|
|
||||||
# assertEquals '' "${actual}"
|
|
||||||
# assertEquals "abc\\'" `_shunit_escapeCharInStr "'" "abc'"`
|
|
||||||
# assertEquals "abc\\'def" `_shunit_escapeCharInStr "'" "abc'def"`
|
|
||||||
# assertEquals "\\'def" `_shunit_escapeCharInStr "'" "'def"`
|
|
||||||
|
|
||||||
# # must put the backtick in a variable so the shell doesn't misinterpret it
|
|
||||||
# # while inside a backticked sequence (e.g. `echo '`'` would fail).
|
|
||||||
# backtick='`'
|
|
||||||
# actual=`_shunit_escapeCharInStr ${backtick} ''`
|
|
||||||
# assertEquals '' "${actual}"
|
|
||||||
# assertEquals '\`abc' \
|
|
||||||
# `_shunit_escapeCharInStr "${backtick}" ${backtick}'abc'`
|
|
||||||
# assertEquals 'abc\`' \
|
|
||||||
# `_shunit_escapeCharInStr "${backtick}" 'abc'${backtick}`
|
|
||||||
# assertEquals 'abc\`def' \
|
|
||||||
# `_shunit_escapeCharInStr "${backtick}" 'abc'${backtick}'def'`
|
|
||||||
}
|
|
||||||
|
|
||||||
testEscapeCharInStr_specialChars()
|
|
||||||
{
|
|
||||||
# make sure our forward slash doesn't upset sed
|
|
||||||
assertEquals '/' `_shunit_escapeCharInStr '\' '/'`
|
|
||||||
|
|
||||||
# some shells escape these differently
|
|
||||||
#assertEquals '\\a' `_shunit_escapeCharInStr '\' '\a'`
|
|
||||||
#assertEquals '\\b' `_shunit_escapeCharInStr '\' '\b'`
|
|
||||||
}
|
|
||||||
|
|
||||||
# Test the various ways of declaring functions.
|
|
||||||
#
|
|
||||||
# Prefixing (then stripping) with comment symbol so these functions aren't
|
|
||||||
# treated as real functions by shUnit2.
|
|
||||||
testExtractTestFunctions()
|
|
||||||
{
|
|
||||||
f="${SHUNIT_TMPDIR}/extract_test_functions"
|
|
||||||
sed 's/^#//' <<EOF >"${f}"
|
|
||||||
#testABC() { echo 'ABC'; }
|
|
||||||
#test_def() {
|
|
||||||
# echo 'def'
|
|
||||||
#}
|
|
||||||
#testG3 ()
|
|
||||||
#{
|
|
||||||
# echo 'G3'
|
|
||||||
#}
|
|
||||||
#function test4() { echo '4'; }
|
|
||||||
# test5() { echo '5'; }
|
|
||||||
#some_test_function() { echo 'some func'; }
|
|
||||||
#func_with_test_vars() {
|
|
||||||
# testVariable=1234
|
|
||||||
#}
|
|
||||||
EOF
|
|
||||||
|
|
||||||
actual=`_shunit_extractTestFunctions "${f}"`
|
|
||||||
assertEquals 'testABC test_def testG3 test4 test5' "${actual}"
|
|
||||||
}
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
|
||||||
# suite functions
|
|
||||||
#
|
|
||||||
|
|
||||||
setUp()
|
|
||||||
{
|
|
||||||
for f in ${expectedF} ${stdoutF} ${stderrF}; do
|
|
||||||
cp /dev/null ${f}
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
oneTimeSetUp()
|
|
||||||
{
|
|
||||||
th_oneTimeSetUp
|
|
||||||
}
|
|
||||||
|
|
||||||
# load and run shUnit2
|
|
||||||
[ -n "${ZSH_VERSION:-}" ] && SHUNIT_PARENT=$0
|
|
||||||
. ${TH_SHUNIT}
|
|
@ -1,41 +0,0 @@
|
|||||||
#! /bin/sh
|
|
||||||
# $Id$
|
|
||||||
# vim:et:ft=sh:sts=2:sw=2
|
|
||||||
#
|
|
||||||
# Copyright 2010 Kate Ward. All Rights Reserved.
|
|
||||||
# Released under the LGPL (GNU Lesser General Public License)
|
|
||||||
# Author: kate.ward@forestent.com (Kate Ward)
|
|
||||||
#
|
|
||||||
# shUnit2 unit test for standalone operation.
|
|
||||||
#
|
|
||||||
# This unit test is purely to test that calling shunit2 directly, while passing
|
|
||||||
# the name of a unit test script, works. When run, this script determines if it
|
|
||||||
# is running as a standalone program, and calls main() if it is.
|
|
||||||
|
|
||||||
ARGV0=`basename "$0"`
|
|
||||||
|
|
||||||
# load test helpers
|
|
||||||
. ./shunit2_test_helpers
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
|
||||||
# suite tests
|
|
||||||
#
|
|
||||||
|
|
||||||
testStandalone()
|
|
||||||
{
|
|
||||||
assertTrue ${SHUNIT_TRUE}
|
|
||||||
}
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
|
||||||
# main
|
|
||||||
#
|
|
||||||
|
|
||||||
main()
|
|
||||||
{
|
|
||||||
${TH_SHUNIT} "${ARGV0}"
|
|
||||||
}
|
|
||||||
|
|
||||||
# are we running as a standalone?
|
|
||||||
if [ "${ARGV0}" = 'shunit2_test_standalone.sh' ]; then
|
|
||||||
if [ $# -gt 0 ]; then main "$@"; else main; fi
|
|
||||||
fi
|
|
@ -0,0 +1,191 @@
|
|||||||
|
#! /bin/sh
|
||||||
|
# vim:et:ft=sh:sts=2:sw=2
|
||||||
|
#
|
||||||
|
# Unit test suite runner.
|
||||||
|
#
|
||||||
|
# Copyright 2008-2020 Kate Ward. All Rights Reserved.
|
||||||
|
# Released under the Apache 2.0 license.
|
||||||
|
#
|
||||||
|
# Author: kate.ward@forestent.com (Kate Ward)
|
||||||
|
# https://github.com/kward/shlib
|
||||||
|
#
|
||||||
|
# This script runs all the unit tests that can be found, and generates a nice
|
||||||
|
# report of the tests.
|
||||||
|
#
|
||||||
|
### Sample usage:
|
||||||
|
#
|
||||||
|
# Run all tests for all shells.
|
||||||
|
# $ ./test_runner
|
||||||
|
#
|
||||||
|
# Run all tests for single shell.
|
||||||
|
# $ ./test_runner -s /bin/bash
|
||||||
|
#
|
||||||
|
# Run single test for all shells.
|
||||||
|
# $ ./test_runner -t shunit_asserts_test.sh
|
||||||
|
#
|
||||||
|
# Run single test for single shell.
|
||||||
|
# $ ./test_runner -s /bin/bash -t shunit_asserts_test.sh
|
||||||
|
#
|
||||||
|
### ShellCheck (http://www.shellcheck.net/)
|
||||||
|
# Disable source following.
|
||||||
|
# shellcheck disable=SC1090,SC1091
|
||||||
|
# expr may be antiquated, but it is the only solution in some cases.
|
||||||
|
# shellcheck disable=SC2003
|
||||||
|
# $() are not fully portable (POSIX != portable).
|
||||||
|
# shellcheck disable=SC2006
|
||||||
|
|
||||||
|
# Return if test_runner already loaded.
|
||||||
|
[ -z "${RUNNER_LOADED:-}" ] || return 0
|
||||||
|
RUNNER_LOADED=0
|
||||||
|
|
||||||
|
RUNNER_ARGV0=`basename "$0"`
|
||||||
|
RUNNER_SHELLS='/bin/sh ash /bin/bash /bin/dash /bin/ksh /bin/mksh /bin/zsh'
|
||||||
|
RUNNER_TEST_SUFFIX='_test.sh'
|
||||||
|
true; RUNNER_TRUE=$?
|
||||||
|
false; RUNNER_FALSE=$?
|
||||||
|
|
||||||
|
runner_warn() { echo "runner:WARN $*" >&2; }
|
||||||
|
runner_error() { echo "runner:ERROR $*" >&2; }
|
||||||
|
runner_fatal() { echo "runner:FATAL $*" >&2; exit 1; }
|
||||||
|
|
||||||
|
runner_usage() {
|
||||||
|
echo "usage: ${RUNNER_ARGV0} [-e key=val ...] [-s shell(s)] [-t test(s)]"
|
||||||
|
}
|
||||||
|
|
||||||
|
_runner_tests() { echo ./*${RUNNER_TEST_SUFFIX} |sed 's#\./##g'; }
|
||||||
|
_runner_testName() {
|
||||||
|
# shellcheck disable=SC1117
|
||||||
|
_runner_testName_=`expr "${1:-}" : "\(.*\)${RUNNER_TEST_SUFFIX}"`
|
||||||
|
if [ -n "${_runner_testName_}" ]; then
|
||||||
|
echo "${_runner_testName_}"
|
||||||
|
else
|
||||||
|
echo 'unknown'
|
||||||
|
fi
|
||||||
|
unset _runner_testName_
|
||||||
|
}
|
||||||
|
|
||||||
|
main() {
|
||||||
|
# Find and load versions library.
|
||||||
|
for _runner_dir_ in . ${LIB_DIR:-lib}; do
|
||||||
|
if [ -r "${_runner_dir_}/versions" ]; then
|
||||||
|
_runner_lib_dir_="${_runner_dir_}"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
[ -n "${_runner_lib_dir_}" ] || runner_fatal 'Unable to find versions library.'
|
||||||
|
. "${_runner_lib_dir_}/versions" || runner_fatal 'Unable to load versions library.'
|
||||||
|
unset _runner_dir_ _runner_lib_dir_
|
||||||
|
|
||||||
|
# Process command line flags.
|
||||||
|
env=''
|
||||||
|
while getopts 'e:hs:t:' opt; do
|
||||||
|
case ${opt} in
|
||||||
|
e) # set an environment variable
|
||||||
|
key=`expr "${OPTARG}" : '\([^=]*\)='`
|
||||||
|
val=`expr "${OPTARG}" : '[^=]*=\(.*\)'`
|
||||||
|
# shellcheck disable=SC2166
|
||||||
|
if [ -z "${key}" -o -z "${val}" ]; then
|
||||||
|
runner_usage
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
eval "${key}='${val}'"
|
||||||
|
eval "export ${key}"
|
||||||
|
env="${env:+${env} }${key}"
|
||||||
|
;;
|
||||||
|
h) runner_usage; exit 0 ;; # help output
|
||||||
|
s) shells=${OPTARG} ;; # list of shells to run
|
||||||
|
t) tests=${OPTARG} ;; # list of tests to run
|
||||||
|
*) runner_usage; exit 1 ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
shift "`expr ${OPTIND} - 1`"
|
||||||
|
|
||||||
|
# Fill shells and/or tests.
|
||||||
|
shells=${shells:-${RUNNER_SHELLS}}
|
||||||
|
[ -z "${tests}" ] && tests=`_runner_tests`
|
||||||
|
|
||||||
|
# Error checking.
|
||||||
|
if [ -z "${tests}" ]; then
|
||||||
|
runner_error 'no tests found to run; exiting'
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
cat <<EOF
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
# System data.
|
||||||
|
#
|
||||||
|
|
||||||
|
$ uname -mprsv
|
||||||
|
`uname -mprsv`
|
||||||
|
|
||||||
|
OS Name: `versions_osName`
|
||||||
|
OS Version: `versions_osVersion`
|
||||||
|
|
||||||
|
### Test run info.
|
||||||
|
shells: ${shells}
|
||||||
|
tests: ${tests}
|
||||||
|
EOF
|
||||||
|
for key in ${env}; do
|
||||||
|
eval "echo \"${key}=\$${key}\""
|
||||||
|
done
|
||||||
|
|
||||||
|
# Run tests.
|
||||||
|
runner_passing_=${RUNNER_TRUE}
|
||||||
|
for shell in ${shells}; do
|
||||||
|
echo
|
||||||
|
|
||||||
|
cat <<EOF
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
# Running the test suite with ${shell}.
|
||||||
|
#
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# Check for existence of shell.
|
||||||
|
shell_bin=${shell}
|
||||||
|
shell_name=''
|
||||||
|
shell_present=${RUNNER_FALSE}
|
||||||
|
case ${shell} in
|
||||||
|
ash)
|
||||||
|
shell_bin=`command -v busybox`
|
||||||
|
[ $? -eq "${RUNNER_TRUE}" ] && shell_present="${RUNNER_TRUE}"
|
||||||
|
shell_bin="${shell_bin:+${shell_bin} }ash"
|
||||||
|
shell_name=${shell}
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
[ -x "${shell_bin}" ] && shell_present="${RUNNER_TRUE}"
|
||||||
|
shell_name=`basename "${shell}"`
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
if [ "${shell_present}" -eq "${RUNNER_FALSE}" ]; then
|
||||||
|
runner_warn "unable to run tests with the ${shell_name} shell"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
shell_version=`versions_shellVersion "${shell}"`
|
||||||
|
|
||||||
|
echo "shell name: ${shell_name}"
|
||||||
|
echo "shell version: ${shell_version}"
|
||||||
|
|
||||||
|
# Execute the tests.
|
||||||
|
for t in ${tests}; do
|
||||||
|
echo
|
||||||
|
echo "--- Executing the '`_runner_testName "${t}"`' test suite. ---"
|
||||||
|
# ${shell_bin} needs word splitting.
|
||||||
|
# shellcheck disable=SC2086
|
||||||
|
( exec ${shell_bin} "./${t}" 2>&1; )
|
||||||
|
shell_passing=$?
|
||||||
|
if [ "${shell_passing}" -ne "${RUNNER_TRUE}" ]; then
|
||||||
|
runner_warn "${shell_bin} not passing"
|
||||||
|
fi
|
||||||
|
test "${runner_passing_}" -eq ${RUNNER_TRUE} -a ${shell_passing} -eq ${RUNNER_TRUE}
|
||||||
|
runner_passing_=$?
|
||||||
|
done
|
||||||
|
done
|
||||||
|
return ${runner_passing_}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Execute main() if this is run in standalone mode (i.e. not from a unit test).
|
||||||
|
if [ -z "${SHUNIT_VERSION}" ]; then
|
||||||
|
main "$@"
|
||||||
|
fi
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,53 @@
|
|||||||
|
#!/sbin/openrc-run
|
||||||
|
#
|
||||||
|
# PROGRAM="osync-srv"
|
||||||
|
# SCRIPT_BUILD=2018051701
|
||||||
|
# Script written by Brian Evans (grknight@gentoo.org) in 2018
|
||||||
|
# How to use:
|
||||||
|
#
|
||||||
|
# 0) Rename this to osync-srv, and place it in /etc/init.d.
|
||||||
|
# 1) Ensure that your config is located in /etc/osync, under some name with a
|
||||||
|
# .conf extension.
|
||||||
|
# 2) Ensure that osync.sh can be found in /usr/local/bin.
|
||||||
|
# 3) Ensure that you have rsync and inotify-tools installed.
|
||||||
|
# 4) Symlink this to a name with an extension equal to the basename of your
|
||||||
|
# config file.
|
||||||
|
# 5) Add to the default runlevel under the symlinked name.
|
||||||
|
#
|
||||||
|
# Example:
|
||||||
|
#
|
||||||
|
# Suppose the config is located at /etc/osync/documents.conf. You then want to
|
||||||
|
# symlink as follows:
|
||||||
|
#
|
||||||
|
# # ln -s /etc/init.d/osync-srv /etc/init.d/osync-srv.documents
|
||||||
|
#
|
||||||
|
# Then you can start the service as normal:
|
||||||
|
#
|
||||||
|
# # rc-update add osync-srv.documents default
|
||||||
|
|
||||||
|
depend() {
|
||||||
|
use localmount chrony ntp-client
|
||||||
|
}
|
||||||
|
|
||||||
|
description="Two way directory sync daemon"
|
||||||
|
command=/usr/local/bin/osync.sh
|
||||||
|
conffile="${RC_SVCNAME#*.}.conf"
|
||||||
|
cfgfile="/etc/osync/${conffile}"
|
||||||
|
command_args="${cfgfile} --on-changes --errors-only"
|
||||||
|
command_background="yes"
|
||||||
|
pidfile="/var/run/${RC_SVCNAME}"
|
||||||
|
stopsig=TERM
|
||||||
|
|
||||||
|
start_pre() {
|
||||||
|
if [ "${conffile}" = ".conf" ]; then
|
||||||
|
eerror "${RC_SVCNAME} cannot be started directly. You must create"
|
||||||
|
eerror "symbolic links to it for the configuration you want to start"
|
||||||
|
eerror "osync on and add those to the appropriate runlevels."
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! [ -f "${cfgfile}" ]; then
|
||||||
|
eerror "Cannot find configuration file ${cfgfile}."
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
@ -0,0 +1,139 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
# osync-srv Two way directory sync daemon
|
||||||
|
#
|
||||||
|
# chkconfig: - 90 99
|
||||||
|
# description: monitors a local directory and syncs to a local or remote \
|
||||||
|
# directory on file changes
|
||||||
|
# processname: /usr/local/bin/osync.sh
|
||||||
|
# config: /etc/osync/*.conf
|
||||||
|
# pidfile: /var/run/osync
|
||||||
|
|
||||||
|
### BEGIN INIT INFO
|
||||||
|
# Provides: osync-target-helper-srv
|
||||||
|
# Required-Start: $local_fs $time
|
||||||
|
# Required-Stop: $local_fs $time
|
||||||
|
# Default-Start: 2 3 4 5
|
||||||
|
# Default-Stop: 0 1 6
|
||||||
|
# Short-Description: osync-target-helpder daemon
|
||||||
|
# Description: Two way directory sync daemon
|
||||||
|
### END INIT INFO
|
||||||
|
|
||||||
|
prog=osync
|
||||||
|
progexec=osync.sh
|
||||||
|
progpath=/usr/local/bin
|
||||||
|
confdir=/etc/osync
|
||||||
|
pidfile=/var/run/$prog-target-helper
|
||||||
|
SCRIPT_BUILD=2018100101
|
||||||
|
|
||||||
|
if [ ! -f $progpath/$progexec ] && [ ! -f $progexec ]; then
|
||||||
|
echo "Cannot find $prog executable in $progpath nor in local path."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -w $(dirname $pidfile) ]; then
|
||||||
|
pidfile=./$prog
|
||||||
|
fi
|
||||||
|
|
||||||
|
start() {
|
||||||
|
if ! ls "$confdir/"*.conf > /dev/null 2>&1; then
|
||||||
|
echo "Cannot find any configuration files in $confdir."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
errno=0
|
||||||
|
|
||||||
|
for cfgfile in "$confdir/"*.conf
|
||||||
|
do
|
||||||
|
if [ -f $progpath/$progexec ]; then
|
||||||
|
$progpath/$progexec $cfgfile --on-changes-target --errors-only > /dev/null 2>&1 &
|
||||||
|
else
|
||||||
|
echo "Cannot find $prog executable in $progpath"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
pid=$!
|
||||||
|
retval=$?
|
||||||
|
|
||||||
|
if [ $? == 0 ]; then
|
||||||
|
echo $pid > "$pidfile-$(basename $cfgfile)"
|
||||||
|
echo "$prog successfully started for configuration file $cfgfile"
|
||||||
|
else
|
||||||
|
echo "Cannot start $prog for configuration file $cfgfile"
|
||||||
|
errno=1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
exit $errno
|
||||||
|
}
|
||||||
|
|
||||||
|
stop() {
|
||||||
|
if [ ! -f $pidfile-* ]; then
|
||||||
|
echo "No running $prog instances found."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
for pfile in $pidfile-*
|
||||||
|
do
|
||||||
|
if ps -p$(cat $pfile) > /dev/null 2>&1
|
||||||
|
then
|
||||||
|
kill -TERM $(cat $pfile)
|
||||||
|
if [ $? == 0 ]; then
|
||||||
|
rm -f $pfile
|
||||||
|
echo "$prog instance $(basename $pfile) stopped."
|
||||||
|
else
|
||||||
|
echo "Cannot stop $prog instance $(basename $pfile)"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
rm -f $pfile
|
||||||
|
echo "$prog instance $pfile (pid $(cat $pfile)) is dead but pidfile exists."
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
status() {
|
||||||
|
if [ ! -f $pidfile-* ]; then
|
||||||
|
echo "Cannot find any running $prog instance."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
errno=0
|
||||||
|
|
||||||
|
for pfile in $pidfile-*
|
||||||
|
do
|
||||||
|
if ps -p$(cat $pfile) > /dev/null 2>&1
|
||||||
|
then
|
||||||
|
echo "$prog instance $(basename $pfile) is running (pid $(cat $pfile))"
|
||||||
|
else
|
||||||
|
echo "$prog instance $pfile (pid $(cat $pfile)) is dead but pidfile exists."
|
||||||
|
errno=1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
exit $errno
|
||||||
|
}
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
start)
|
||||||
|
start
|
||||||
|
;;
|
||||||
|
stop)
|
||||||
|
stop
|
||||||
|
;;
|
||||||
|
restart)
|
||||||
|
stop
|
||||||
|
start
|
||||||
|
;;
|
||||||
|
status)
|
||||||
|
status
|
||||||
|
;;
|
||||||
|
condrestart|try-restart)
|
||||||
|
status || exit 0
|
||||||
|
restart
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Usage: $0 {start|stop|restart|status}"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
exit 0
|
@ -0,0 +1,13 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=osync - Target helper service
|
||||||
|
After=time-sync.target local-fs.target network-online.target
|
||||||
|
Requires=time-sync.target local-fs.target
|
||||||
|
Wants=network-online.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
ExecStart=/usr/local/bin/osync.sh /etc/osync/%i --on-changes-target --errors-only
|
||||||
|
SuccessExitStatus=0 2
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
@ -0,0 +1,11 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=A robust two way (bidirectional) file sync script based on rsync with fault tolerance
|
||||||
|
After=time-sync.target local-fs.target network-online.target
|
||||||
|
Wants=network-online.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
ExecStart=/usr/local/bin/osync.sh /etc/osync/%i --on-changes-target --silent
|
||||||
|
SuccessExitStatus=0 2
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
@ -1,25 +1,113 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
git clone git+ssh://aur@aur.archlinux.org/osync.git osync.aur &&
|
HELPTEXT=\
|
||||||
cd "osync.aur" &&
|
"Usage: $0 [OPTIONS]\n"\
|
||||||
srcdir="." &&
|
"Automatically updates the osync version in the AUR.\n"\
|
||||||
source "PKGBUILD" &&
|
"\n"\
|
||||||
|
"-y, --yes Do not prompt before committing\n"\
|
||||||
|
"-n, --name=USERNAME Username to use with git in case no global username is set\n"\
|
||||||
|
"-e, --email=EMAIL Email address to use with git in case no global email is set"
|
||||||
|
|
||||||
url=$(echo -n ${source[0]} | sed 's/git+//g' | sed 's/#.*//g') &&
|
function cleanup {
|
||||||
branch=$(echo -n ${source[0]} | sed 's/.*#branch=//g') &&
|
echo "Cleanup..."
|
||||||
git clone -b $branch $url &&
|
cd ..
|
||||||
|
rm -rf osync.aur
|
||||||
|
}
|
||||||
|
|
||||||
# Get pkgver from current osync
|
# Check getopt compatibility
|
||||||
pkgver=$(grep PROGRAM_VERSION= ./osync/osync.sh)
|
getopt --test > /dev/null
|
||||||
pkgver=${pkgver##*=}
|
if [[ $? -ne 4 ]]; then
|
||||||
echo $pkgver
|
echo "You don't seem to have the GNU-enhanced getopt available. That shouldn't happen on a modern system with bash installed."
|
||||||
|
exit 38
|
||||||
|
fi
|
||||||
|
|
||||||
sed -i "s/pkgver=.*/pkgver=$(pkgver)/g" "PKGBUILD" &&
|
# Parse command line arguments
|
||||||
|
OPTIONS=hyn:e:
|
||||||
|
LONGOPTIONS=help,yes,name:,email:
|
||||||
|
|
||||||
|
PARSED=$(getopt --options=$OPTIONS --longoptions=$LONGOPTIONS --name "$0" -- "$@")
|
||||||
|
if [[ $? -ne 0 ]]; then
|
||||||
|
exit 22
|
||||||
|
fi
|
||||||
|
eval set -- "$PARSED"
|
||||||
|
|
||||||
|
while true; do
|
||||||
|
case "$1" in
|
||||||
|
-h|--help)
|
||||||
|
echo -e "$HELPTEXT"
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
-y|--yes)
|
||||||
|
yes="y"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-n|--name)
|
||||||
|
name="$2"
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
|
-e|--email)
|
||||||
|
email="$2"
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
|
--)
|
||||||
|
shift
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Programming error" > /dev/stderr
|
||||||
|
exit 131
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
if [[ -z $name ]];then
|
||||||
|
name=$(git config --global user.name)
|
||||||
|
if [[ -z $name ]]; then
|
||||||
|
echo "Please specify a username for the git commit with the -n|--name option or set it globally with 'git config --global user.name USERNAME"
|
||||||
|
exit 22
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -z $email ]];then
|
||||||
|
email=$(git config --global user.email)
|
||||||
|
if [[ -z $email ]]; then
|
||||||
|
echo "Please specify an e-mail for the git commit with the -e|--email option or set it globally with 'git config --global user.email EMAIL"
|
||||||
|
exit 22
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
### Main ###
|
||||||
|
|
||||||
|
echo "Cloning AUR package..."
|
||||||
|
if ! git clone -q git+ssh://aur@aur.archlinux.org/osync.git osync.aur || ! cd osync.aur; then
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
git config user.name "$name"
|
||||||
|
git config user.email "$email"
|
||||||
|
|
||||||
|
echo "Cloning most recent stable version of osync..." &&
|
||||||
|
git clone -qb stable https://github.com/deajan/osync.git > /dev/null &&
|
||||||
|
|
||||||
|
echo "Fetching version..." &&
|
||||||
|
cd osync &&
|
||||||
|
pkgversion="$(git describe --tags --long | sed 's/\([^-]*-\)g/r\1/;s/-/./g')" &&
|
||||||
|
cd .. &&
|
||||||
|
|
||||||
|
echo "Updating version..." &&
|
||||||
|
sed -i "s/pkgver=.*/pkgver=${pkgversion}/g" "PKGBUILD" &&
|
||||||
../mksrcinfo &&
|
../mksrcinfo &&
|
||||||
rm -rf "osync" &&
|
rm -rf "osync" &&
|
||||||
git add . &&
|
|
||||||
git commit -m "Updated version" &&
|
[[ ! -z $yes ]] || (read -p "About to commit changes to AUR. Are you sure? (y/n) " -n 1 -r && echo "" &&
|
||||||
git push origin master &&
|
[[ $REPLY =~ ^[Yy]$ ]]) &&
|
||||||
cd .. &&
|
|
||||||
rm -rf "osync.aur" &&
|
echo "Committing changes to AUR..." &&
|
||||||
echo "Package updated successfully"
|
git add PKGBUILD .SRCINFO &&
|
||||||
|
git commit -qm "Updated version to ${pkgversion}" &&
|
||||||
|
git push -q origin master &&
|
||||||
|
|
||||||
|
cleanup &&
|
||||||
|
echo "Package updated successfully to version ${pkgversion}" || cleanup
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
@ -0,0 +1,102 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
###### osync - Rsync based two way sync engine with fault tolerance
|
||||||
|
###### (C) 2013-2020 by Orsiris de Jong (www.netpower.fr)
|
||||||
|
|
||||||
|
[GENERAL]
|
||||||
|
CONFIG_FILE_REVISION=1.3.0
|
||||||
|
|
||||||
|
## Sync job identification
|
||||||
|
INSTANCE_ID="target_test"
|
||||||
|
|
||||||
|
## Directories to synchronize.
|
||||||
|
## Initiator is the system osync runs on. The initiator directory must be a local path.
|
||||||
|
INITIATOR_SYNC_DIR="/home/git/osync/dir1"
|
||||||
|
#INITIATOR_SYNC_DIR="ssh://backupuser@yourhost.old:22//home/git/osync/dir1"
|
||||||
|
|
||||||
|
## Target is the system osync synchronizes to (can be the same system as the initiator in case of local sync tasks). The target directory can be a local or remote path.
|
||||||
|
TARGET_SYNC_DIR="/home/git/osync/dir2"
|
||||||
|
|
||||||
|
## If the target system is remote, you can specify a RSA key (please use full path). If not defined, the default ~/.ssh/id_rsa will be used. See documentation for further information.
|
||||||
|
SSH_RSA_PRIVATE_KEY="/home/backupuser/.ssh/id_rsa"
|
||||||
|
|
||||||
|
## Alternatively, you may specify an SSH password file (less secure). Needs sshpass utility installed.
|
||||||
|
SSH_PASSWORD_FILE=""
|
||||||
|
|
||||||
|
## When using ssh filter, you must specify a remote token matching the one setup in authorized_keys
|
||||||
|
_REMOTE_TOKEN=SomeAlphaNumericToken9
|
||||||
|
|
||||||
|
## Log file location. Leaving this empty will create a logfile at /var/log/osync_version_SYNC_ID.log (or current directory if /var/log doesn't exist)
|
||||||
|
LOGFILE=""
|
||||||
|
|
||||||
|
## If enabled, synchronization on remote system will be processed as superuser. See documentation for /etc/sudoers file configuration.
|
||||||
|
SUDO_EXEC=false
|
||||||
|
|
||||||
|
## ---------- REMOTE SYNC OPTIONS
|
||||||
|
|
||||||
|
## ssh compression should be used unless your remote connection is good enough (LAN)
|
||||||
|
SSH_COMPRESSION=true
|
||||||
|
|
||||||
|
## Ignore ssh known hosts. DANGER WILL ROBINSON DANGER ! This can lead to security issues. Only enable this if you know what you're doing.
|
||||||
|
SSH_IGNORE_KNOWN_HOSTS=false
|
||||||
|
|
||||||
|
## Check for connectivity to remote host before launching remote sync task. Be sure the hosts responds to ping. Failing to ping will stop sync.
|
||||||
|
REMOTE_HOST_PING=false
|
||||||
|
|
||||||
|
## Check for internet access by pinging one or more 3rd party hosts before remote sync task. Leave empty if you don't want this check to be be performed. Failing to ping will stop sync.
|
||||||
|
## If you use this function, you should set more than one 3rd party host, and be sure you can ping them.
|
||||||
|
## Be aware some DNS like opendns redirect false hostnames. Also, this adds an extra execution time of a bit less than a minute.
|
||||||
|
REMOTE_3RD_PARTY_HOSTS="www.kernel.org www.google.com"
|
||||||
|
|
||||||
|
## Log a message every KEEP_LOGGING seconds just to know the task is still alive
|
||||||
|
KEEP_LOGGING=1801
|
||||||
|
|
||||||
|
## Minimum time (in seconds) in file monitor /daemon mode between modification detection and sync task in order to let copy operations finish.
|
||||||
|
MIN_WAIT=60
|
||||||
|
|
||||||
|
## Maximum time (in seconds) waiting in file monitor / daemon mode. After this time, sync is run.
|
||||||
|
## Use 0 to wait indefinitely.
|
||||||
|
MAX_WAIT=7200
|
||||||
|
|
||||||
|
[ALERT_OPTIONS]
|
||||||
|
|
||||||
|
## List of alert mails separated by spaces
|
||||||
|
## Most Unix systems (including Win10 bash) have mail support out of the box
|
||||||
|
## Just make sure that the current user has enough privileges to use mail / mutt / sendmail and that the mail system is configured to allow outgoing mails
|
||||||
|
## on pfSense platform, smtp support needs to be configured in System > Advanced > Notifications
|
||||||
|
DESTINATION_MAILS="your@alert.tld"
|
||||||
|
|
||||||
|
## Optional change of mail body encoding (using iconv)
|
||||||
|
## By default, all mails are sent in UTF-8 format without header (because of maximum compatibility of all platforms)
|
||||||
|
## You may specify an optional encoding here (like "ISO-8859-1" or whatever iconv can handle)
|
||||||
|
MAIL_BODY_CHARSET=""
|
||||||
|
|
||||||
|
## Additional mail parameters needed for Android / Busybox / Cygwin / MSYS
|
||||||
|
## Android & Busybox use sendmail (and openssl if encryption is needed)
|
||||||
|
## MSYS & Cygwin Windows mail support relies on mailsend.exe from muquit, http://github.com/muquit/mailsend which needs to be in %PATH% environment variable
|
||||||
|
SENDER_MAIL="alert@your.system.tld"
|
||||||
|
SMTP_SERVER=smtp.your.isp.tld
|
||||||
|
SMTP_PORT=25
|
||||||
|
# encryption can be tls, ssl or none
|
||||||
|
SMTP_ENCRYPTION=none
|
||||||
|
SMTP_USER=
|
||||||
|
SMTP_PASSWORD=
|
||||||
|
|
||||||
|
[EXECUTION_HOOKS]
|
||||||
|
|
||||||
|
## Commands can will be run before and / or after sync process (remote execution will only happen if REMOTE_OPERATION is set).
|
||||||
|
LOCAL_RUN_BEFORE_CMD=""
|
||||||
|
LOCAL_RUN_AFTER_CMD=""
|
||||||
|
|
||||||
|
REMOTE_RUN_BEFORE_CMD=""
|
||||||
|
REMOTE_RUN_AFTER_CMD=""
|
||||||
|
|
||||||
|
## Max execution time of commands before they get force killed. Leave 0 if you don't wan't this to happen. Time is specified in seconds.
|
||||||
|
MAX_EXEC_TIME_PER_CMD_BEFORE=0
|
||||||
|
MAX_EXEC_TIME_PER_CMD_AFTER=0
|
||||||
|
|
||||||
|
## Stops osync execution if one of the above commands fail
|
||||||
|
STOP_ON_CMD_ERROR=true
|
||||||
|
|
||||||
|
## Run local and remote after sync commands even on failure
|
||||||
|
RUN_AFTER_CMD_ON_ERROR=false
|
Loading…
Reference in New Issue