Skip to content

Instantly share code, notes, and snippets.

@come-maiz
Last active September 5, 2016 18:01
Show Gist options
  • Save come-maiz/32489ae04a68ef15d33739b25db72498 to your computer and use it in GitHub Desktop.
Save come-maiz/32489ae04a68ef15d33739b25db72498 to your computer and use it in GitHub Desktop.
Micro snap testing

Smoke tests for the micro snap

First, build and install the micro snap:

  1. sudo apt install git snapcraft
  2. git clone https://github.com/elopio/micro
  3. cd micro
  4. git checkout snapcraft
  5. snapcraft
  6. sudo snap install micro*.snap

Open the editor:

$ micro

Print the help:

Ctrl+e
> help

Close the help:

Ctrl+g

Save a file:

  1. Enter some $TEXT.
  2. Save the file with Ctrl+s.
  3. Enter the $FILENAME.
  4. Press Enter.
  5. Exit the editor with Ctrl+q.
  6. Print the file contents with cat $FILENAME.
    • Verify that the $TEXT is printed.

Edit an exiting file:

  1. Create a file with echo test > $HOME/test.micro.
  2. Open the file in the editor with `micro $HOME/test.micro``.
  3. Edit the file adding some lines with text.
  4. Save the file with Ctrl+s.
  5. Exit the editor with Ctrl+q.
  6. Print the file contents with cat $HOME/test.micro.
    • Verify that the original content and the added lines are printed.

Open a python file:

  1. Copy a python file to the home directory. (Because the snap is isolated and only has access to the home directory and it's own storage)
  2. Open the file with micro $HOME/$FILENAME.
    • Verify that the syntax is highlighted with different colors.

Use a plugin:

  1. Open micro with the micro command.
  2. Enter (, { and [.
    • Verify that the closing symbol is automatically written.

Run a shell command:

  1. With the micro editor open, enter the command mode with Ctrl+e.
  2. Enter run snapcraft.

Use the clipboard inside the editor:

  1. With the micro editor open and some text written, select a part of the text with the mouse.
  2. Enter Ctrl+c.
  3. Move the cursor to a differet line in the editor.
  4. Enter Ctrl+v.
    • Verify that the selected text was pasted to the new line.

Use the clipboard from outside of the editor:

  1. With the micro editor open and some text wirtten, select a part of the text with the mouse.
  2. Enter Ctrl+c.
  3. Open an editor with a graphical user interface, like gedit.
  4. Enter Ctrl+v.
    • Verify that the selected text was pasted to the GUI editor.
@come-maiz
Copy link
Author

Tested in a clean and up-to-date Ubuntu xenial virtual machine with kvm.

Some problems:

  • When I open the editor, I get:
Unable to load pre-installed syntax file pascal

Press enter to continue
  • When I try to run a command, I get something like:
    snapcraft exited with error: exec: not started:
    It is being discussed in the mailing list how to securely give access to snaps to run other commands.
  • The clipboard only works inside the editor. To make it work with other applications we can bundle xclip with the snap and use the X11 interface. I tested it and works, but it defeats a little the purpose of the confinement, as explained in https://askubuntu.com/questions/760803/security-of-snaps-under-x11. It can be easily added, just needs a discussion about the trade-offs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment