travis-ci. It is a cloud continuous integration service. This tool will submit code every time you push. , perform functional testing of the code to run all tests in the t/ directory under the Perl module directory. This test will automatically create a virtual machine and can test different Perl versions. If it passes, it will display green, if it fails, it will Displayed in red, very convenient.
Configuration of DSL mode
To use this function, you only need to add a ".travis.yml" configuration file to the Perl module on your Github. This will automatically monitor the changes to the code on your Github and automatically submit for testing.
The commonly used Perl configuration test image is as follows
代码如下 | |
language: perl perl: - "5.20" - "5.18" - "5.16" - "5.14" - "5.12" - "5.10" env: - "HARNESS_OPTIONS=j9 TEST_POD=1 TEST_EV=1 TEST_IPV6=1 TEST_SOCKS=1 TEST_TLS=1" install: - "cpanm -n Test::Pod Test::Pod::Coverage EV IO::Socket::IP IO::Socket::Socks IO::Socket::SSL" - "cpanm -n --installdeps ." notifications: email: false |
First specify the language of your project through the language above. Then specify the Perl version you need to use for testing. You can write what modules you need to install before testing.
Github and Travis CI integration
After the above configuration file is configured and placed in the directory of your git project, you need to go to the https://travis-ci.org website to activate the testing function of your project through your github account. Enter After that, click "Travis CI for private Repositories", and the following picture will appear. You can see your project on github, and then choose to open... Note that your project must have the files mentioned above.
After doing this, every time you submit code to github, this tool will automatically create a clean virtual machine, and then conduct automated testing through the Perl version you specified.
Test process and result query
You can write notifications to notify you of the test results. In addition, you can also go to the website https://travis-ci.com/ to view the detailed test results, as shown below. If it is red, it means failure, you can click directly Turn on red to see the detailed failure reasons and test process.
Test code coverage
According to Fayland’s guidance... I discovered another interesting thing. For example, we added the following content to the ".travis.yml" configuration file above
代码如下 | |
before_install: - "cpanm Mojo::UserAgent" - "cpanm Test::More" - "cpanm Devel::Cover::Report::Coveralls" script: perl Makefile.PL && make test && cover -test -report coveralls |
The main thing is to add the cover -test -report coveralls part. Because it requires the support of the Devel::Cover::Report::Coveralls module, let it install this first.
Then go to https://coveralls.io and open it. This will send the cover data to that website.
In this way, you can also add badges to the github page to display code coverage