Bladeren bron

Add support for code coverage

Yegappan Lakshmanan 4 jaren geleden
bovenliggende
commit
2a97e8a09c
3 gewijzigde bestanden met toevoegingen van 45 en 4 verwijderingen
  1. 35 0
      .github/workflows/coverage.yml
  2. 3 0
      test/.coveragerc
  3. 7 4
      test/unit_tests.vim

+ 35 - 0
.github/workflows/coverage.yml

@@ -0,0 +1,35 @@
+name: coverage
+on: [push, pull_request]
+jobs:
+  linux:
+    name: linux
+    runs-on: ubuntu-latest
+    steps:
+      - name: Run Tests
+        run: |
+          uname -a
+          export MRU_PROFILE=1
+          export VIMPRG=vim
+          $VIMPRG --version
+          cd ./test
+          ./run_mru_tests.sh
+      - name: Install Python
+        uses: actions/setup-python@v1
+      - name: Install covimerage
+        run: |
+          pip install covimerage
+          covimerage --version
+      - name: Run covimerage
+        run: |
+          cd ./test
+          covimerage write_coverage profile.txt
+      - name: Take coverage
+        run: |
+          cd ./test
+          coverage report
+          coverage xml
+      - name: Upload coverage to codecov
+        uses: codecov/codecov-action@v1
+        with:
+          token: ${{ secrets.CODECOV_TOKEN }}
+          file: ./test/coverage.xml

+ 3 - 0
test/.coveragerc

@@ -0,0 +1,3 @@
+[run]
+plugins = covimerage
+data_file = .coverage_covimerage

+ 7 - 4
test/unit_tests.vim

@@ -6,13 +6,16 @@ let MRU_Auto_Close=1
 let MRU_Max_Entries=10
 let MRU_buffer_name = '-RecentFiles-'
 
-" Set the following variable to 1, to profile the MRU plugin
-let s:do_profile=0
+" Set the $MRU_PROFILE environment variable to profile the MRU plugin
+let s:do_profile = 0
+if exists('$MRU_PROFILE')
+  let s:do_profile = 1
+endif
 
 " Profile the MRU plugin
 if s:do_profile
-    profile start mru_profile.txt
-    profile! file */mru.vim
+  profile start mru_profile.txt
+  profile! file */mru.vim
 endif
 
 source ../plugin/mru.vim