From 0ce7d93cef727247e0973f1f98fcd044aeae3e25 Mon Sep 17 00:00:00 2001 From: mlangkabel Date: Mon, 4 Feb 2019 17:44:41 +0100 Subject: [PATCH] test: updated custom command test to index python code --- .../custom_command/checklist.txt | 38 ----------- .../project_setup/custom_command/data/add.py | 6 -- .../custom_command/data/src/a.txt | 0 .../custom_command/data/src/b.txt | 0 .../custom_command/data/src/c.txt | 0 .../project_setup/custom_command/data/src/d.c | 0 .../custom_command/data/src/excl.txt | 0 .../1_setup.sh | 0 .../custom_command_python/2_update.sh | 17 +++++ .../3_teardown.sh} | 0 .../custom_command_python/checklist.txt | 64 +++++++++++++++++++ .../custom_command_python/data/src/bar.py | 3 + .../custom_command_python/data/src/foo.py | 5 ++ .../custom_command_python/data/src/main.py | 5 ++ 14 files changed, 94 insertions(+), 44 deletions(-) delete mode 100644 testing/project_setup/custom_command/checklist.txt delete mode 100644 testing/project_setup/custom_command/data/add.py delete mode 100644 testing/project_setup/custom_command/data/src/a.txt delete mode 100644 testing/project_setup/custom_command/data/src/b.txt delete mode 100644 testing/project_setup/custom_command/data/src/c.txt delete mode 100644 testing/project_setup/custom_command/data/src/d.c delete mode 100644 testing/project_setup/custom_command/data/src/excl.txt rename testing/project_setup/{custom_command => custom_command_python}/1_setup.sh (100%) mode change 100755 => 100644 create mode 100644 testing/project_setup/custom_command_python/2_update.sh rename testing/project_setup/{custom_command/2_teardown.sh => custom_command_python/3_teardown.sh} (100%) mode change 100755 => 100644 create mode 100644 testing/project_setup/custom_command_python/checklist.txt create mode 100644 testing/project_setup/custom_command_python/data/src/bar.py create mode 100644 testing/project_setup/custom_command_python/data/src/foo.py create mode 100644 testing/project_setup/custom_command_python/data/src/main.py diff --git a/testing/project_setup/custom_command/checklist.txt b/testing/project_setup/custom_command/checklist.txt deleted file mode 100644 index bb47f4d2..00000000 --- a/testing/project_setup/custom_command/checklist.txt +++ /dev/null @@ -1,38 +0,0 @@ -* Run "1_setup.sh" -* Start up Sourcetrail -* Click "New Project" -* Enter a project name -* Set "./working_copy" as project location -* Click "Add Source Group" -* Select "Custom" -> "Custom Command Source Group" -* Click "Next" -* Add "python add.py %{PROJECT_FILE_PATH} %{DATABASE_FILE_PATH} %{DATABASE_VERSION} %{SOURCE_FILE_PATH}" to "Custom Command" -* Add "./src" to "Files & Directories to Index" -* Add "**excl.txt" to "Excluded Files & Directories" -* Add ".txt" to "Source File Extensions" -* Click "Next" -* Click "Create" -* Validate "All files" is the only option selectable -* Validate "source files to index" shows "3" -* Click "Start" -* Validate Project indexed without error -* Click "OK" -* Validate "out.txt" contains 3 lines: - /a.txt - /b.txt - /c.txt -* Press "Refresh" button -* Validate "Updated files" is selected -* Validate "source files to index" shows "3" again -* Click "Cancel" -* Click "Edit Project" -* Change "Custom Command" to "pyt add.py" -* Click "Save" -* Validate "Warning appears that %{SOURCE_FILE_PATH} is not defined in command" -* Change "Custom Command" to "pyt add.py %{SOURCE_FILE_PATH}" -* Click "Save" -* Click "Refresh" button -* Click "Start" -* Validate "Log View appears showing errors that command execution failed". -* Close Sourcetrail -* Run "2_teardown.sh" diff --git a/testing/project_setup/custom_command/data/add.py b/testing/project_setup/custom_command/data/add.py deleted file mode 100644 index 7ba77c86..00000000 --- a/testing/project_setup/custom_command/data/add.py +++ /dev/null @@ -1,6 +0,0 @@ -import sys -# import time -# time.sleep(1) - -with open("out.txt", "a") as myfile: - myfile.write(sys.argv[1] + ' ' + sys.argv[2] + ' ' + sys.argv[3] + ' ' + sys.argv[4] + '\n') diff --git a/testing/project_setup/custom_command/data/src/a.txt b/testing/project_setup/custom_command/data/src/a.txt deleted file mode 100644 index e69de29b..00000000 diff --git a/testing/project_setup/custom_command/data/src/b.txt b/testing/project_setup/custom_command/data/src/b.txt deleted file mode 100644 index e69de29b..00000000 diff --git a/testing/project_setup/custom_command/data/src/c.txt b/testing/project_setup/custom_command/data/src/c.txt deleted file mode 100644 index e69de29b..00000000 diff --git a/testing/project_setup/custom_command/data/src/d.c b/testing/project_setup/custom_command/data/src/d.c deleted file mode 100644 index e69de29b..00000000 diff --git a/testing/project_setup/custom_command/data/src/excl.txt b/testing/project_setup/custom_command/data/src/excl.txt deleted file mode 100644 index e69de29b..00000000 diff --git a/testing/project_setup/custom_command/1_setup.sh b/testing/project_setup/custom_command_python/1_setup.sh old mode 100755 new mode 100644 similarity index 100% rename from testing/project_setup/custom_command/1_setup.sh rename to testing/project_setup/custom_command_python/1_setup.sh diff --git a/testing/project_setup/custom_command_python/2_update.sh b/testing/project_setup/custom_command_python/2_update.sh new file mode 100644 index 00000000..31dbf7b6 --- /dev/null +++ b/testing/project_setup/custom_command_python/2_update.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +# get absolute path to parent directory of script +MY_PATH=`dirname "$0"` +if [[ "${MY_PATH}" != *\\* ]] +then + cd $MY_PATH + MY_PATH=`pwd` +fi +MY_PATH="${MY_PATH//\\//}" + +WORKING_COPY_PATH=$MY_PATH/working_copy + +echo "" >> $WORKING_COPY_PATH/src/bar.py + +echo "Update Complete" + diff --git a/testing/project_setup/custom_command/2_teardown.sh b/testing/project_setup/custom_command_python/3_teardown.sh old mode 100755 new mode 100644 similarity index 100% rename from testing/project_setup/custom_command/2_teardown.sh rename to testing/project_setup/custom_command_python/3_teardown.sh diff --git a/testing/project_setup/custom_command_python/checklist.txt b/testing/project_setup/custom_command_python/checklist.txt new file mode 100644 index 00000000..be4ab163 --- /dev/null +++ b/testing/project_setup/custom_command_python/checklist.txt @@ -0,0 +1,64 @@ +* Run "1_setup.sh" +* Download the SourcetrailPythonIndexer project from https://github.com/CoatiSoftware/SourcetrailPythonIndexer +* Extract the archive to "./working_copy/SourcetrailPythonIndexer" +* Fetch the SourcetrailDB release for your OS from https://github.com/CoatiSoftware/SourcetrailDB/releases +* Extract the archive to "./working_copy/SourcetrailPythonIndexer" +* Start up Sourcetrail +* Click "New Project" +* Enter a project name +* Set "./working_copy" as project location +* Click "Add Source Group" +* Select "Custom" -> "Custom Command Source Group" +* Click "Next" +* Add "python /SourcetrailPythonIndexer/run.py --source-file-path=%{SOURCE_FILE_PATH} --database-file-path=%{DATABASE_FILE_PATH}" to "Custom Command" +* Add "./src" to "Files & Directories to Index" +* Add "**main*" to "Excluded Files & Directories" +* Add ".py" to "Source File Extensions" +* Click "Next" +* Click "Create" +* Validate "All files" is the only option selectable +* Validate "source files to index" shows "2" +* Click "Start" +* Validate Project indexed without error +* Click "OK" +* Enter "print" in the search bar and press "Enter" +* Validate the search bar shows "foo.Foo.print" +* Validate the graph shows some nodes and edges +* Validate the code view shows some code with syntax highlighting +* Press "Refresh" button +* Validate "Updated files" is selected +* Validate "source files to index" shows "0" +* Click "Cancel" +* Click "Edit Project" +* Clear the "Excluded Files & Directories" list +* Click "Save" +* Validate a project-file-was-changed-notification appears +* Click "Reindex" +* Validate "Updated files" is selected +* Validate "source files to index" shows "3" +* Click "Updated files" +* Validate "source files to index" shows "1" +* Click Start +* Validate Project indexed without error +* Click "OK" +* Validate content of code and graph view changed and display calls from "main" +* Run "2_update.sh" +* Validate "Updated files" is selected +* Validate "source files to index" shows "1" +* Click Start +* Validate a dialog appears that states that the project cannot be partially cleared +* Click "Fill Re-Index" +* Validate Project indexed without error +* Click "OK" +* Click "Edit Project" +* In "Custom Command" replace "python" with "pyt" +* In "Custom Command" replace "%{SOURCE_FILE_PATH}" with "foo" +* Click "Save" +* Validate "Warning appears that %{SOURCE_FILE_PATH} is not defined in command" +* In "Custom Command" replace "foo" with "%{SOURCE_FILE_PATH}" +* Click "Save" +* Click "Refresh" button +* Click "Start" +* Validate "Log View appears showing errors that command execution failed". +* Close Sourcetrail +* Run "3_teardown.sh" diff --git a/testing/project_setup/custom_command_python/data/src/bar.py b/testing/project_setup/custom_command_python/data/src/bar.py new file mode 100644 index 00000000..6d720050 --- /dev/null +++ b/testing/project_setup/custom_command_python/data/src/bar.py @@ -0,0 +1,3 @@ +class Bar: + def __init__(self): + self.baz = 'Initial String' diff --git a/testing/project_setup/custom_command_python/data/src/foo.py b/testing/project_setup/custom_command_python/data/src/foo.py new file mode 100644 index 00000000..baa8c26e --- /dev/null +++ b/testing/project_setup/custom_command_python/data/src/foo.py @@ -0,0 +1,5 @@ +import bar + +class Foo(bar.Bar): + def print(self): + print(self.baz) diff --git a/testing/project_setup/custom_command_python/data/src/main.py b/testing/project_setup/custom_command_python/data/src/main.py new file mode 100644 index 00000000..2702fa9e --- /dev/null +++ b/testing/project_setup/custom_command_python/data/src/main.py @@ -0,0 +1,5 @@ +import foo + +def main(): + f = foo.Foo() + f.print()