Comments (6)
Great idea. It is definitely on my to-do list (currently doing a manual rebuild and deploy). Thanks for the links.
from cpppatterns-patterns.
👍
from cpppatterns-patterns.
I would like to do continuous deployment as well as integration. This project involves two repos though (CppSamples-Web and CppSamples-Samples) - anybody know if you can have Travis-CI trigger a build when either repo is updated?
Edit: Looks like maybe this would work if I used git submodules. Then I just need to push updates the submodule.
from cpppatterns-patterns.
Glad you found the right way. I am not a expert 😅 , so can't help much .
from cpppatterns-patterns.
I've implemented continuous integration/deployment for the website itself, which basically pulls in the samples, builds the site, and then pushes it to the GitHub Pages repository where it is hosted. I'll soon do some CI for this samples repository, but I need to think of a better way to test the samples (not just seeing if they compile). (sorry, just putting my thoughts here to keep note)
from cpppatterns-patterns.
Just a suggestion off the top of my head:
Given the simplicity of the tests, incorporating a proper test and mock framework is probably insane overkill. You could probably get by with simple hand-cranked tests in each sample file. Also it would probably be better if each sample was entirely self-contained - and thus self-testing. Trying to shadow the sample tree with a test tree just seems like an unnecessary pain.
The sample format already looks like this:
// preamble
<sample code>
// text
<hidden code>
If you specify that the "sample code" has to be a function, and the "hidden code" has to be a legal main function that calls the sample code function, you could then further specify that the main function has to do tests on the sample code.
For example (borrowing from the count()
sample):
// Count occurrences of value in a range
# include <iostream>
# include <algorithm>
# include <vector>
template <typename Range>
int count_occurrences_of_3(Range const& range)
{
int count = std::count(std::begin(range),
std::end(range),
3);
return count;
}
// Sample description
// ...
// ...
// ...
int main()
{
auto result = 0;
std::vector<int> numbers = {1, 2, 3, 5, 6, 3, 4, 1};
auto e1 = std::count(std::begin(numbers), std::end(numbers), 3);
auto r1 = count_occurrences_of_3(numbers);
if (r1 != e1)
{
std::cout << "[count-values-in-range] test 1 failed; expected [" <<
e1 << "], got [" << r1 << "]\n";
++result;
}
// Maybe other tests...
return result;
}
Now you can test by building the sample cpp file, and running it. The non-zero exit status will alert your CI tool - whatever you use - that there was an error, and you get some info on stdout about what went wrong. And because everything after the sample text comment block is invisible on the site, you could add as many tests as you like, or make the tests as complex as you please.
from cpppatterns-patterns.
Related Issues (20)
- Add clear notes to samples involving experimental features
- Examples that involve non-standard libraries HOT 5
- Suggestion: Singleton pattern HOT 1
- Suggestion: mixing formatted and unformatted input
- Suggestion: mixing formatted and unformatted input
- Suggestion: Lambdas
- Add "old-style" C++ for comparison HOT 4
- Adjust layout so code has a bit more width
- Suggestion: Add .clang-format indentation guide HOT 1
- std::string and utf-8 HOT 2
- Suggestion: <chrono> samples
- Remove Algorithms category HOT 1
- Suggestion: Rosettacode link?
- Suggestion: linking contributor github profiles HOT 2
- Suggestion: summing up values in a range (`std::accumulate`)
- Suggestion: add HTTPS HOT 1
- pimpl.cpp not compiled on macOS 10.13.3
- Suggestion: Support tags per pattern
- std::experimental::dynarray no longer supported in array passing example
- Suggestion: In the CRTP example, make impl method private in the derived class
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 cpppatterns-patterns.