From beb319d3d034a2f717afc21f0252372d33e48422 Mon Sep 17 00:00:00 2001 From: Derek Keeler Date: Fri, 15 Mar 2019 21:04:59 -0700 Subject: [PATCH 1/4] Split out steps from the job matrix - will re-use the steps in CI and Nightly --- build/ci/templates/test_phases.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build/ci/templates/test_phases.yml b/build/ci/templates/test_phases.yml index 8c9f7a769d28..5163435f7177 100644 --- a/build/ci/templates/test_phases.yml +++ b/build/ci/templates/test_phases.yml @@ -83,7 +83,7 @@ steps: # Show all versions installed/available on PATH if in verbose mode. # Example command line (windows pwsh): - # > Write-Host Node ver: $(& node -v) NPM Ver: $(& npm -v) Python ver: $(& python --version)" + # > Write-Host "Node ver: $(& node -v) NPM Ver: $(& npm -v) Python ver: $(& python --version)" - bash: | echo AVAILABLE DEPENDENCY VERSIONS echo Node Version = `node -v` @@ -127,6 +127,7 @@ steps: # Example command line (windows pwsh): # > npm run test:unittests - bash: | + npm run cover:enable npm run test:unittests:cover displayName: 'run test:unittest' condition: and(succeeded(), contains(variables['TestsToRun'], 'testUnitTests')) From ab92c45f5df5b8c5a049e29e1f0a10d424fa3613 Mon Sep 17 00:00:00 2001 From: Derek Keeler Date: Mon, 18 Mar 2019 10:11:22 -0700 Subject: [PATCH 2/4] Correct python version specification - was running Python 3.7 in all cases before - Updated AGENT_OS usage - Add display name to show dependency versions (was 'Bash') - skip Python unittests for normalizeForInterpreter in python 2.7 --- .../tests/test_normalize_for_interpreter.py | 27 ++++++++----------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/pythonFiles/tests/test_normalize_for_interpreter.py b/pythonFiles/tests/test_normalize_for_interpreter.py index 721ee114701d..5f4ff2e927dc 100644 --- a/pythonFiles/tests/test_normalize_for_interpreter.py +++ b/pythonFiles/tests/test_normalize_for_interpreter.py @@ -11,18 +11,16 @@ class TestNormalizationScript(object): """Basic unit tests for the normalization script.""" - @pytest.mark.skipif(sys.version_info.major == 2, - reason="normalizeForInterpreter not working for 2.7, see GH #4805") + reason="normalizeForInterpreter not working for 2.7, see GH #4805") def test_basicNormalization(self, capsys): src = 'print("this is a test")' normalizeForInterpreter.normalize_lines(src) captured = capsys.readouterr() assert captured.out == src - @pytest.mark.skipif(sys.version_info.major == 2, - reason="normalizeForInterpreter not working for 2.7, see GH #4805") + reason="normalizeForInterpreter not working for 2.7, see GH #4805") def test_moreThanOneLine(self, capsys): src = textwrap.dedent("""\ # Some rando comment @@ -30,14 +28,13 @@ def test_moreThanOneLine(self, capsys): def show_something(): print("Something") """ - ) + ) normalizeForInterpreter.normalize_lines(src) captured = capsys.readouterr() assert captured.out == src - @pytest.mark.skipif(sys.version_info.major == 2, - reason="normalizeForInterpreter not working for 2.7, see GH #4805") + reason="normalizeForInterpreter not working for 2.7, see GH #4805") def test_withHangingIndent(self, capsys): src = textwrap.dedent("""\ x = 22 @@ -48,14 +45,13 @@ def test_withHangingIndent(self, capsys): if result == 42: print("The answer to life, the universe, and everything") """ - ) + ) normalizeForInterpreter.normalize_lines(src) captured = capsys.readouterr() assert captured.out == src - @pytest.mark.skipif(sys.version_info.major == 2, - reason="normalizeForInterpreter not working for 2.7, see GH #4805") + reason="normalizeForInterpreter not working for 2.7, see GH #4805") def test_clearOutExtraneousNewlines(self, capsys): src = textwrap.dedent("""\ value_x = 22 @@ -67,7 +63,7 @@ def test_clearOutExtraneousNewlines(self, capsys): print(value_x + value_y + value_z) """ - ) + ) expectedResult = textwrap.dedent("""\ value_x = 22 value_y = 30 @@ -75,14 +71,13 @@ def test_clearOutExtraneousNewlines(self, capsys): print(value_x + value_y + value_z) """ - ) + ) normalizeForInterpreter.normalize_lines(src) result = capsys.readouterr() assert result.out == expectedResult - @pytest.mark.skipif(sys.version_info.major == 2, - reason="normalizeForInterpreter not working for 2.7, see GH #4805") + reason="normalizeForInterpreter not working for 2.7, see GH #4805") def test_clearOutExtraLinesAndWhitespace(self, capsys): src = textwrap.dedent("""\ if True: @@ -95,7 +90,7 @@ def test_clearOutExtraLinesAndWhitespace(self, capsys): print(x + y + z) """ - ) + ) expectedResult = textwrap.dedent("""\ if True: x = 22 @@ -105,7 +100,7 @@ def test_clearOutExtraLinesAndWhitespace(self, capsys): print(x + y + z) """ - ) + ) normalizeForInterpreter.normalize_lines(src) result = capsys.readouterr() assert result.out == expectedResult From 5144d5fbeb848a6e866945e3c63e6341f6f2f6e2 Mon Sep 17 00:00:00 2001 From: Derek Keeler Date: Mon, 18 Mar 2019 10:34:44 -0700 Subject: [PATCH 3/4] Put all python tests in the same vicinity. - run them before system tests in the interest of early exit for fast tests - Do not run internal-tool tests on Python != 3.x --- build/ci/templates/test_phases.yml | 48 ++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/build/ci/templates/test_phases.yml b/build/ci/templates/test_phases.yml index 5163435f7177..2d4beb4895c3 100644 --- a/build/ci/templates/test_phases.yml +++ b/build/ci/templates/test_phases.yml @@ -246,6 +246,54 @@ steps: buildPlatform: '$(Agent.Os)-Py$(pythonVersion)' buildConfiguration: 'UnitTests' + # Run the News tool tests. + # + # This task only runs if the string 'pythonUnitTests' exists in variable `TestsToRun` + # + # Example command line (windows pwsh): + # > python -m pip install -U -r news/requirements.txt + # > python -m pytest tpn --color=yes --junit-xml=python-news-junit.xml + - script: | + python -m pip install --upgrade -r news/requirements.txt + python -m pytest news --color=yes --junit-xml=$COMMON_TESTRESULTSDIRECTORY/python-news-junit.xml + displayName: 'Run Python tests for news' + condition: and(succeeded(), contains(variables['TestsToRun'], 'pythonUnitTests'), startsWith(variables['PythonVersion'], '3')) + + # Upload the test results to Azure DevOps to facilitate test reporting in their UX. + - task: PublishTestResults@2 + displayName: 'Publish News test results' + condition: and(contains(variables['TestsToRun'], 'pythonUnitTests'), startsWith(variables['PythonVersion'], '3')) + inputs: + testResultsFiles: 'python-news-junit.xml' + searchFolder: '$(Common.TestResultsDirectory)' + testRunTitle: 'NEWS-$(Platform)-Py$(pythonVersion)' + buildPlatform: '$(Platform)-Py$(pythonVersion)' + buildConfiguration: 'Unittests' + + # Run the TPN tool tests. + # + # This task only runs if the string 'pythonUnitTests' exists in variable `TestsToRun` + # + # Example command line (windows pwsh): + # > python -m pip install -U -r tpn/requirements.txt + # > python -m pytest tpn --color=yes --junit-xml=python-tpn-junit.xml + - script: | + python -m pip install --upgrade -r tpn/requirements.txt + python -m pytest tpn --color=yes --junit-xml=$COMMON_TESTRESULTSDIRECTORY/python-tpn-junit.xml + displayName: 'Run Python tests for TPN tool' + condition: and(contains(variables['TestsToRun'], 'pythonUnitTests'), startsWith(variables['PythonVersion'], '3')) + + # Upload the test results to Azure DevOps to facilitate test reporting in their UX. + - task: PublishTestResults@2 + displayName: 'Publish JUnit test results' + condition: and(contains(variables['TestsToRun'], 'pythonUnitTests'), startsWith(variables['PythonVersion'], '3')) + inputs: + testResultsFiles: 'python-tpn-junit.xml' + searchFolder: '$(Common.TestResultsDirectory)' + testRunTitle: 'TPN-$(Platform)-Py$(pythonVersion)' + buildPlatform: '$(Platform)-Py$(pythonVersion)' + buildConfiguration: 'Unittests' + # Start the X virtual frame buffer (X-windows in memory only) on Linux. Linux VMs do not # provide a desktop so VS Code cannot properly launch there. To get around this we use the # xvfb service to emulate a desktop instead. See From 20074237ffa2084b281322081c9e83e4ac50b2ec Mon Sep 17 00:00:00 2001 From: Derek Keeler Date: Thu, 21 Mar 2019 04:09:58 -0700 Subject: [PATCH 4/4] Remove redundant changes. --- build/ci/templates/test_phases.yml | 49 ------------------------------ 1 file changed, 49 deletions(-) diff --git a/build/ci/templates/test_phases.yml b/build/ci/templates/test_phases.yml index 2d4beb4895c3..1486a3a9072c 100644 --- a/build/ci/templates/test_phases.yml +++ b/build/ci/templates/test_phases.yml @@ -127,7 +127,6 @@ steps: # Example command line (windows pwsh): # > npm run test:unittests - bash: | - npm run cover:enable npm run test:unittests:cover displayName: 'run test:unittest' condition: and(succeeded(), contains(variables['TestsToRun'], 'testUnitTests')) @@ -246,54 +245,6 @@ steps: buildPlatform: '$(Agent.Os)-Py$(pythonVersion)' buildConfiguration: 'UnitTests' - # Run the News tool tests. - # - # This task only runs if the string 'pythonUnitTests' exists in variable `TestsToRun` - # - # Example command line (windows pwsh): - # > python -m pip install -U -r news/requirements.txt - # > python -m pytest tpn --color=yes --junit-xml=python-news-junit.xml - - script: | - python -m pip install --upgrade -r news/requirements.txt - python -m pytest news --color=yes --junit-xml=$COMMON_TESTRESULTSDIRECTORY/python-news-junit.xml - displayName: 'Run Python tests for news' - condition: and(succeeded(), contains(variables['TestsToRun'], 'pythonUnitTests'), startsWith(variables['PythonVersion'], '3')) - - # Upload the test results to Azure DevOps to facilitate test reporting in their UX. - - task: PublishTestResults@2 - displayName: 'Publish News test results' - condition: and(contains(variables['TestsToRun'], 'pythonUnitTests'), startsWith(variables['PythonVersion'], '3')) - inputs: - testResultsFiles: 'python-news-junit.xml' - searchFolder: '$(Common.TestResultsDirectory)' - testRunTitle: 'NEWS-$(Platform)-Py$(pythonVersion)' - buildPlatform: '$(Platform)-Py$(pythonVersion)' - buildConfiguration: 'Unittests' - - # Run the TPN tool tests. - # - # This task only runs if the string 'pythonUnitTests' exists in variable `TestsToRun` - # - # Example command line (windows pwsh): - # > python -m pip install -U -r tpn/requirements.txt - # > python -m pytest tpn --color=yes --junit-xml=python-tpn-junit.xml - - script: | - python -m pip install --upgrade -r tpn/requirements.txt - python -m pytest tpn --color=yes --junit-xml=$COMMON_TESTRESULTSDIRECTORY/python-tpn-junit.xml - displayName: 'Run Python tests for TPN tool' - condition: and(contains(variables['TestsToRun'], 'pythonUnitTests'), startsWith(variables['PythonVersion'], '3')) - - # Upload the test results to Azure DevOps to facilitate test reporting in their UX. - - task: PublishTestResults@2 - displayName: 'Publish JUnit test results' - condition: and(contains(variables['TestsToRun'], 'pythonUnitTests'), startsWith(variables['PythonVersion'], '3')) - inputs: - testResultsFiles: 'python-tpn-junit.xml' - searchFolder: '$(Common.TestResultsDirectory)' - testRunTitle: 'TPN-$(Platform)-Py$(pythonVersion)' - buildPlatform: '$(Platform)-Py$(pythonVersion)' - buildConfiguration: 'Unittests' - # Start the X virtual frame buffer (X-windows in memory only) on Linux. Linux VMs do not # provide a desktop so VS Code cannot properly launch there. To get around this we use the # xvfb service to emulate a desktop instead. See