2016-10-30 2 views
0

개념 증명 일부 나는 Appveyor와 Travis에서 빌드해야하는 NetCoreXunit의 xUnit 테스트에서 간단한 netcore repo를했습니다. 나는 실패한 테스트를했고 Appveyor는 빌드를 실패하지만 트래비스가 똑같이하도록 고투하고 있습니다. 테스트를 행복하게 실행하고 테스트 중 하나가 실패했지만 빌드를 전달합니다.dotnet 테스트 실패시 Travis-CI 빌드를 깨뜨림

Google 검색 결과가 봤는데 yaml 구성의 스크립트 단계에서 출력을 파이프하고 구문 분석하려고했지만 스크립트 지식이 좋지 않습니다.

누군가가 트래비스가 빌드를 실패하게하는 데 도움이 될 수 있다면 고맙겠습니다. GitHub 레포에서 내 Appveyor 및 Travis 빌드 모두에 대한 링크가 있으며 Repo에 커밋하면 자동으로 생성됩니다.

- UPDATE-- 그래서 두 개의 테스트 어셈블리의 출력을 구문 분석하고 테스트 실패가 있는지 정확하게 확인했습니다. 하지만 출구를 던지기 전에 두 어셈블리가 테스트되도록 변수를 만들어야합니다. 나는 이것을 얻기 위해 어리석은 농구를 뛰어 넘어야했다. 하나는 트래비스가 불평하지 않고 변수를 정의하는 것처럼 보이지 않는 것입니다. 하드 코드 된 것뿐만 아니라 모든 테스트 어셈블리를 찾는 데까지 확장하고 싶습니다.

after_success: 
    # Run tests 
    - dotnet test ./src/NetCoreXunit -xml ./out/NetCoreXunit.xml; 
    if grep -q 'result="Fail"' ./out/NetCoreXunit.xml ; then 
     echo 'Failed tests detected.'; 
    else 
     echo 'All tests passed.'; 
    fi; 
    - dotnet test ./src/NetCoreXunitB -xml ./out/NetCoreXunitB.xml; 
    if grep -q 'result="Fail"' ./out/NetCoreXunitB.xml ; then 
     echo 'Failed tests detected.'; 
    else 
     echo 'All tests passed.'; 
    fi; 

어떤 조언 에 감사드립니다 : 어떻게 모든 테스트 어셈블리의 목록을받을 수 있나요 내가 어떻게 선언하고 난 다음에 ExitCode를 할 수있는 부울을 설정합니까?

답변

0

오랜 시간 동안 .travis.yml을 작동 시키려고했습니다. 방금 Python 루트를 따라 가야했습니다. 다음과 같이 yml에서 호출됩니다.

import os 
import sys 
import re 
from subprocess import call 

root_directory = os.getcwd() 
print (root_directory) 

regexp = re.compile(r'src[\/\\]NetCoreXunit.?$') 
result = False 
for child in os.walk(root_directory): 
    print (child[0]) 
    if regexp.search(child[0]) is not None: 
     print ("Matched") 
     test_path = os.path.join(root_directory, child[0]) 
     if os.path.isdir(test_path): 
      print ("IsDir") 
      print (test_path) 
      os.chdir(test_path) 
      call (["dotnet", "test", "-xml", "output.xml"]) 
      if 'result="Fail"' in open("output.xml").read(): 
       print (test_path + ": Failed tests detected") 
       result = True 
      else: 
       print (test_path + ": All tests passed") 

os.chdir(root_directory) 

if result: 
    print ("Failed tests detected") 
    sys.exit(1) 
관련 문제