Comments (4)
I managed to make it not exit the terminal run running it in a subshell:
(source tests.sh; runTests;)
- https://stackoverflow.com/questions/52063180/bash-source-a-file-that-has-an-exit-command-at-the-end
But running it like this, it does not find any tests and it throws an error:
$ (source tests.sh; runTests;)
grep: bash: No such file or directory
Ran 0 tests.
OK
If I edit the example to:
#!/bin/bash
runTests() {
source shUnit2
}
testEquality() {
assertEquals 1 1
}
runTests
And call it like this (bash timer_calculator.sh;)
everything works fine:
$ (bash timer_calculator.sh;)
testEquality
Ran 1 test.
OK
from shunit2.
Original comment by [email protected]
on 15 Mar 2011 at 2:10
- Added labels: Priority-High
- Removed labels: Priority-Medium
from shunit2.
Any update?
from shunit2.
Small example to reproduce it:
tests.sh
#!/bin/bash
runTests() {
source shUnit2
}
testEquality() {
assertEquals 1 1
}
Now open a terminal and run:
source tests.sh; runTests;
from shunit2.
Related Issues (20)
- call to [ not protected somewhere ERROR
- "Ran X tests." message is not accurate if a test exits
- fail fails to fail the test immediately HOT 4
- shunit2 Debian/Ubuntu packages out of date HOT 20
- Use https://bpkg.sh/ as package manager
- Warning "can only `return' from a function or sourced script" when executing in standalone mode (in Bash shell) HOT 1
- Should there be a counter for skipped tests in addition to the number of skipped asserts? HOT 5
- "[[: not found" error when sourcing files
- Test with bash in posix mode
- Next release ? HOT 4
- Mock and expect HOT 3
- Update version distributed through apt HOT 3
- [BASH] _SHUNIT_LINENO_ error if IFS is redefined HOT 4
- How to only execute specified test cases instead of all ? HOT 1
- What scenarios and how to use Error handling?
- Cannot source unit tests from unit tests HOT 1
- 执行单个案例,是否可以打印他的执行过程
- assertNotNull not working with set -e HOT 2
- egrep: warning: egrep is obsolescent; using grep -E HOT 5
- Add snapshot testing support
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from shunit2.