diff --git a/tests/test_pabot.py b/tests/test_pabot.py index c60c7439..4b48a695 100644 --- a/tests/test_pabot.py +++ b/tests/test_pabot.py @@ -1226,6 +1226,106 @@ def test_copy_output_artifacts_include_subfolders(self): file_path = os.path.join(_opts["outputdir"], f) self.assertTrue(os.path.isfile(file_path), "file not copied: {}".format(f)) os.remove(file_path) # clean up + + def test_merge_one_run_with_and_without_legacyoutput(self): + dtemp = tempfile.mkdtemp() + # Create the same directory structure as pabot + test_outputs = os.path.join(dtemp, 'outputs') + os.makedirs(test_outputs) + test_output = os.path.join(test_outputs, 'output.xml') + # Create a minimal but valid output.xml + with open(test_output, 'w') as f: + f.write(""" + + + + + +hello +hello +Logs the given message with the given level. + + + + + + + + + +hello +hello +Logs the given message with the given level. + + + + + + +[https://pabot.org/?ref=log|Pabot] result from 1 executions. + + + + +All Tests + + + + +Suites +Suites.Test +Suites.Test + + + +Error in file '/Users/mkorpela/workspace/pabot/test.robot' on line 2: Library 'Easter' expected 0 arguments, got 1. +Error in file '/Users/mkorpela/workspace/pabot/test.robot' on line 2: Library 'Easter' expected 0 arguments, got 1. + +""") + + self._options['outputdir'] = dtemp + self._options['legacyoutput'] = True + try: + output = pabot._merge_one_run( + outs_dir=dtemp, + options=self._options, + tests_root_name='Test', # Should match suite name in XML + stats={ + "total": 0, + "passed": 0, + "failed": 0, + "skipped": 0, + }, + copied_artifacts=[], + outputfile='merged_output.xml') # Use different name to avoid confusion + self.assertTrue(output, "merge_one_run returned empty string") # Verify we got output path + with open(output, 'r') as f: + content = f.read() + self.assertIn('schemaversion="4"', content) + self.assertNotIn('schemaversion="5"', content) + del self._options['legacyoutput'] + output = pabot._merge_one_run( + outs_dir=dtemp, + options=self._options, + tests_root_name='Test', # Should match suite name in XML + stats={ + "total": 0, + "passed": 0, + "failed": 0, + "skipped": 0, + }, + copied_artifacts=[], + outputfile='merged_2_output.xml') # Use different name to avoid confusion + self.assertTrue(output, "merge_one_run returned empty string") # Verify we got output path + with open(output, 'r') as f: + content = f.read() + if ROBOT_VERSION >= "7.0": + self.assertIn('schemaversion="5"', content) + self.assertNotIn('schemaversion="4"', content) + else: + self.assertIn('schemaversion="4"', content) + finally: + shutil.rmtree(dtemp) if __name__ == "__main__":