mirror of
https://github.com/cpm-cmake/CPM.cmake.git
synced 2025-11-24 05:08:01 -05:00
Tips
This commit is contained in:
2
test/integration/.gitignore
vendored
Normal file
2
test/integration/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
# Use this to have a local integration test which is for personal experiments
|
||||||
|
test_local.rb
|
||||||
@@ -41,3 +41,4 @@ Writing tests makes use of the custom integration test framework in `lib.rb`. It
|
|||||||
* [A basic tutorial on writing integration tests.](tutorial.md)
|
* [A basic tutorial on writing integration tests.](tutorial.md)
|
||||||
* [A brief reference of the integration test framework](reference.md)
|
* [A brief reference of the integration test framework](reference.md)
|
||||||
* Make sure you're familiar with the [idiosyncrasies](idiosyncrasies.md) of writing integration tests
|
* Make sure you're familiar with the [idiosyncrasies](idiosyncrasies.md) of writing integration tests
|
||||||
|
* [Some tips and tricks](tips.md)
|
||||||
|
|||||||
@@ -1,20 +0,0 @@
|
|||||||
require_relative './lib'
|
|
||||||
|
|
||||||
# Tests and experiments with the integration test framework itself
|
|
||||||
|
|
||||||
class ALib < IntegrationTest
|
|
||||||
def test_zza
|
|
||||||
f = -> {
|
|
||||||
assert_equal 2, 2
|
|
||||||
}
|
|
||||||
f.()
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_b
|
|
||||||
test_foo('xxx')
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_foo(xxx)
|
|
||||||
assert_equal 'xxx', xxx
|
|
||||||
end
|
|
||||||
end
|
|
||||||
35
test/integration/tips.md
Normal file
35
test/integration/tips.md
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
# Tips and Tricks
|
||||||
|
|
||||||
|
## Playing and experimenting
|
||||||
|
|
||||||
|
Create a file called `test_local.rb` in this directory to have an integration test which is for your personal experiments and just playing with the integration test framework. `test_local.rb` is gitignored.
|
||||||
|
|
||||||
|
## Speeding-up development
|
||||||
|
|
||||||
|
Running an integration test requires configuring directories with CMake which can be quite slow. To speed-up development of integration tests consider doing the following steps:
|
||||||
|
|
||||||
|
**Work with standalone tests**
|
||||||
|
|
||||||
|
Instead of starting the runner, run just your integration test (`$ ruby test_your_test.rb`). This won't burden the execution with the others.
|
||||||
|
|
||||||
|
**Export the environment variable `CPM_INTEGRATION_TEST_DIR` to some local directory**
|
||||||
|
|
||||||
|
By default the framework generates a new temporary directory for each test run. If you override the temp directory to a specific one, rerunning the tests will work with the binary directories from the previous run and will improve the performance considerably.
|
||||||
|
|
||||||
|
*NOTE HOWEVER* that in certain cases this may not be an option. Some tests might assert that certain artifacts in the temporary directory are missing but upon rerunning in an existing directory they will be there causing the test to fail.
|
||||||
|
|
||||||
|
*ALSO NOTE* that this may silently affect reruns based on CMake caches from previous runs. If your test fails in peculiar ways on reruns, try a clean run. Always do a clean run before declaring a test a success.
|
||||||
|
|
||||||
|
**Set `CPM_SOURCE_CACHE` even if the test doesn't require it**
|
||||||
|
|
||||||
|
This is not a option for tests which explicitly check that there is no source cache. However certain tests may be indiferent to this. For such cases in development, you can add a setup function in the lines of:
|
||||||
|
|
||||||
|
```ruby
|
||||||
|
def setup
|
||||||
|
ENV['CPM_SOURCE_CACHE'] = '/home/myself/.testcpmcache'
|
||||||
|
end
|
||||||
|
```
|
||||||
|
|
||||||
|
Then the packages from your test will be cached and not redownloaded every time which is a dramatic improvement in performance.
|
||||||
|
|
||||||
|
*NOTE HOWEVER* that this may introduce subtle bugs. Always test without this dev-only addition, before declaring a test a success.
|
||||||
Reference in New Issue
Block a user