File tree Expand file tree Collapse file tree
python-commons/src/test/java/org/sonar/plugins/python Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -696,6 +696,30 @@ void test_exception_should_fail_analysis_if_configured_so() throws IOException {
696696 .hasCauseInstanceOf (FileNotFoundException .class );
697697 }
698698
699+ @ Test
700+ void test_completion_exception_with_error () throws IOException {
701+ activeRules = new ActiveRulesBuilder ().build ();
702+
703+ DefaultInputFile inputFile = spy (TestInputFileBuilder .create ("moduleKey" , FILE_1 )
704+ .setModuleBaseDir (baseDir .toPath ())
705+ .setCharset (UTF_8 )
706+ .setType (Type .MAIN )
707+ .setLanguage (Python .KEY )
708+ .initMetadata (TestUtils .fileContent (new File (baseDir , FILE_1 ), UTF_8 ))
709+ .setStatus (InputFile .Status .ADDED )
710+ .build ());
711+ when (inputFile .contents ()).thenThrow (new OutOfMemoryError ("Test out of memory error" ));
712+
713+ context .fileSystem ().add (inputFile );
714+
715+ context .setSettings (new MapSettings ().setProperty ("sonar.python.analysis.threads" , "2" ));
716+ PythonSensor sensor = sensor ();
717+
718+ assertThatThrownBy (() -> sensor .execute (context ))
719+ .isInstanceOf (OutOfMemoryError .class )
720+ .hasMessage ("Test out of memory error" );
721+ }
722+
699723 @ Test
700724 void test_python_version_parameter_warning () {
701725 context .fileSystem ().add (inputFile (FILE_1 ).wrappedFile ());
You can’t perform that action at this time.
0 commit comments