ctrl+shift+p filters: :st2 :st3 :win :osx :linux
Browse

Color​Scheme​Unit

by gerardroche ST3

A testing framework for Sublime Text color schemes.

Details

Installs

  • Total 990
  • Win 684
  • OS X 153
  • Linux 153
Dec 12 Dec 11 Dec 10 Dec 9 Dec 8 Dec 7 Dec 6 Dec 5 Dec 4 Dec 3 Dec 2 Dec 1 Nov 30 Nov 29 Nov 28 Nov 27 Nov 26 Nov 25 Nov 24 Nov 23 Nov 22 Nov 21 Nov 20 Nov 19 Nov 18 Nov 17 Nov 16 Nov 15 Nov 14 Nov 13 Nov 12 Nov 11 Nov 10 Nov 9 Nov 8 Nov 7 Nov 6 Nov 5 Nov 4 Nov 3 Nov 2 Nov 1 Oct 31 Oct 30 Oct 29 Oct 28
Windows 2 2 0 1 2 4 4 1 1 5 1 3 2 1 5 1 3 3 4 3 4 7 2 0 0 3 3 7 0 2 1 7 3 3 4 5 4 4 0 1 7 0 2 1 2 2
OS X 0 0 1 0 0 0 1 0 0 0 1 0 1 0 0 0 1 0 2 0 1 1 0 0 0 1 1 0 0 2 0 1 1 0 0 0 0 0 0 0 1 0 0 0 2 2
Linux 0 1 0 0 0 0 2 1 0 0 0 2 1 0 0 0 0 1 0 0 2 0 1 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 1 0 1 1 0 0 0 1

Readme

Source
raw.​githubusercontent.​com

WHAT COLOR SCHEME UNIT IS

A testing framework for Sublime Text color schemes.

Build Status Build status Coverage Status Minimum Sublime Version Latest Stable Version GitHub stars Downloads Author

Many color schemes available for Sublime Text are not kept up to date, don't support plugins, use too many variants of the same colors, or only exist to be compatible with a specific theme. They tend to go out of date and break in unexpected and unknown ways. ColorSchemeUnit, which is a testing framework for Sublime Text color schemes, helps improve the quality of color schemes and prevent regressions.

Screenshot

OVERVIEW

INSTALLATION

Package Control installation

The preferred method of installation is Package Control.

Manual installation

Close Sublime Text then download or clone this repository to a directory named ColorSchemeUnit in the Sublime Text Packages directory for your platform:

  • Linux: git clone https://github.com/gerardroche/sublime-color-scheme-unit.git ~/.config/sublime-text-3/Packages/ColorSchemeUnit
  • OSX: git clone https://github.com/gerardroche/sublime-color-scheme-unit.git ~/Library/Application\ Support/Sublime\ Text\ 3/Packages/ColorSchemeUnit
  • Windows: git clone https://github.com/gerardroche/sublime-color-scheme-unit.git %APPDATA%\Sublime/ Text/ 3/Packages/ColorSchemeUnit

COMMANDS

The Test plugin is recommended to unify testing commands and keymaps.

Command Palette Command Description
:TestSuite color_scheme_unit_test_suite Run test suite of the current file.
:TestFile color_scheme_unit_test_file Run tests for the current file.
:TestResults color_scheme_unit_test_results Show the test results panel.
:ShowScopeAndColors color_scheme_unit_show_scope_name_and_styles Show the scope name and applied colors of scheme at point under cursor.
:InsertAssertions color_scheme_unit_insert_assertions Inserts assertions for the current line.
:InsertSyntaxAssertions color_scheme_unit_insert_syntax_assertions Inserts syntax assertions for the current line.

KEY BINDINGS

The Test plugin is recommended to unify testing commands and keymaps.

Add your preferred key bindings:

Menu > Preferences > Key Bindings

[
    { "keys": ["ctrl+shift+a"], "command": "color_scheme_unit_test_suite" },
    { "keys": ["ctrl+shift+f"], "command": "color_scheme_unit_test_file" },
    { "keys": ["ctrl+shift+r"], "command": "color_scheme_unit_test_results" },
    { "keys": ["ctrl+shift+alt+p"], "command": "color_scheme_unit_show_scope_name_and_styles" },
    { "keys": ["ctrl+a"], "command": "color_scheme_unit_insert_assertions" },
    { "keys": ["ctrl+f"], "command": "color_scheme_unit_insert_syntax_assertions" },
]

Key bindings provided by default:

Key Description
F4 Jump to Next Failure
Shift+F4 Jump to Previous Failure

CONFIGURATION

Key Description Type Default
color_scheme_unit.debug Enable debug messages. boolean false
color_scheme_unit.coverage Enable coverage report. boolean true

Menu > Preferences > Settings - User

{
    "color_scheme_unit.debug": true,
    "color_scheme_unit.coverage": true
}

Testing

When building a color scheme, rather than manually checking the styles, you can define a color scheme test file that will do the checking for you:

// COLOR SCHEME TEST "MonokaiFree/MonokaiFree.tmTheme" "C"

#include <windows.h>
// ^^^^^ fg=#f92672 fs=
//       ^^^^^^^^^^^ fg=#e6db74 fs=

typedef int myint;
// ^^^^ fg=#66d9ef fs=italic
//      ^^^ fg=#66d9ef fs=italic
//          ^^^^^ fg=#a6e22e fs=
//               ^ fg=#f8f8f2 fs=

int main(int argc, char **argv) {}
//  ^^^^ fg=#a6e22e fs=
//      ^ fg=#f8f8f2 fs=
//       ^^^ fg=#66d9ef fs=italic
//           ^^^^ fg=#fd971f fs=italic
//               ^ fg=#f8f8f2 fs=
//                 ^^^^ fg=#66d9ef fs=italic
//                      ^^ fg=#f92672 fs=
//                        ^^^^ fg=#fd971f fs=italic
//                            ^ fg=#f8f8f2 fs=
//                              ^^ fg=#f8f8f2 fs=

Tests are similar to syntax tests. To make one, follow these rules:

  1. Ensure the file name starts with color_scheme_test.
  2. Ensure the file is saved somewhere within the Packages directory: next to the corresponding .sublime-syntax file is a good choice.
  3. Ensure the first line of the file starts with: <comment_token> COLOR SCHEME TEST "<color_scheme>" [SKIP IF NOT ]"<syntax>". Note that [SKIP IF NOT ] is optional.
  4. Test files must use spaces (not tabs).

Here is a suggested project layout:

.
├── Name.tmTheme
└── tests
  ├── color_scheme_test.css
  ├── color_scheme_test.html
  ├── color_scheme_test.js
  ├── color_scheme_test.json
  └── ...

Once the above conditions are met, running a test command from the Command Palette with a color scheme test or color scheme file selected will run the tests, and show the results in an output panel. Next Result (F4) can be used to navigate to the first failing test.

Each test in the color scheme test file must first start the comment token (established on the first line, it doesn't have to be a comment according to the syntax), and then a ^ token.

There is one type of test:

Caret: ^ this will test the following selector against the scope on the most recent non-test line. It will test it at the same column the ^ is in. Consecutive ^'s will test each column against the selector. Assertions are specified after the caret.

There are four types of assertions:

Description Examples
Foreground color fg=#f8f8f2
Background color bg=#272822
Font style (space delimited list) fs=italic, fs=italic bold
Sublime Text build version (only >= constraint is supported) build>=3127

One or more assertions are required, and they must be specified in the order: fg, bg, fs, and build. Here are some examples of valid assertions:

def somefunc(param1='', param2=0):
# ^ fg=#66d9ef
# ^ bg=#272822
# ^ fs=italic
# ^ fg=#66d9ef bg=#272822
# ^ fg=#66d9ef bg=#272822 fs=italic bold
# ^ fg=#66d9ef bg=#272822 fs=italic build>=3127

Examples

Explore the MonokaiFree color scheme test suite for more examples.

# COLOR SCHEME TEST "MonokaiFree/MonokaiFree.tmTheme" "Python" # flake8: noqa

import os
# ^ fg=#f8f8f2 bg=#272822 fs=
#  ^^^ fg=#f92672 fs=
#      ^^ fg=#f8f8f2

def f_name(arg1='', arg2=0):
# ^ fg=#66d9ef fs=italic
#   ^^^^^^ fg=#a6e22e fs=
#          ^ fg=#fd971f fs=italic
#              ^ fg=#f92672 fs=
#               ^^ fg=#e6db74 fs=
#                 ^ fg=#f8f8f2 fs=
#                   ^ fg=#fd971f fs=italic
#                       ^ fg=#f92672 fs=
#                        ^ fg=#ae81ff fs=
    if arg1 > arg2: # interesting
    #   ^ fg=#f92672 fs=
    #           ^ fg=#f92672 fs=
        print 'Gre\'ater'
        # ^ fg=#f92672 fs=
        #     ^^^^ fg=#e6db74 fs=
        #         ^^ fg=#ae81ff fs=
        #           ^^^^^ fg=#e6db74 fs=
<!DOCTYPE html>


<html>
    <head>

        <meta charset="utf-8">






    </head>
    <body>
        <p class="title" id='title'>Title</p>











    </body>

</html>
<?php // COLOR SCHEME TEST "MonokaiFree/MonokaiFree.tmTheme" "PHP"

use \Psr\Http\Message\ServerRequestInterface as Request;
//^ fg=#f92672 fs=
//  ^^^^^^^^^^^^^^^^^^ fg=#f8f8f2 fs=
//                    ^^^^^^^^^^^^^^^^^^^^^^ fg=#66d9ef fs=italic
//                                           ^^ fg=#f92672 fs=
//                                              ^^^^^^^ fg=#a6e22e fs=
//                                                     ^ fg=#f8f8f2 fs=
use \Psr\Http\Message\ResponseInterface as Response;
//^ fg=#f92672 fs=
//  ^^^^^^^^^^^^^^^^^^ fg=#f8f8f2 fs=
//                    ^^^^^^^^^^^^^^^^^ fg=#66d9ef fs=italic
//                                      ^^ fg=#f92672 fs=
//                                         ^^^^^^^^ fg=#a6e22e fs=
//                                                 ^ fg=#f8f8f2 fs=

require 'vendor/autoload.php';
// ^^^^ fg=#f92672 fs=
//      ^^^^^^^^^^^^^^^^^^^^^ fg=#e6db74 fs=
//                           ^ fg=#f8f8f2 fs=

CONTINUOUS INTEGRATION

Travis CI

language: python

env:
    global:
        - PACKAGE="MonokaiFree"
    matrix:
        - SUBLIME_TEXT_VERSION="3"

matrix:
    include:
        - os: linux
          python: 3.3

before_install:
    - curl -OL https://raw.githubusercontent.com/randy3k/UnitTesting/master/sbin/appveyor.ps1

install:
    - sh travis.sh bootstrap
    - sh travis.sh install_color_scheme_unit

script:
    - sh travis.sh run_color_scheme_tests --coverage

notifications:
    email: false

AppVeyor

environment:
    global:
        PACKAGE: "MonokaiFree"
        SUBLIME_TEXT_VERSION: "3"

clone_depth: 5

install:
    - ps: appveyor DownloadFile "https://raw.githubusercontent.com/randy3k/UnitTesting/master/sbin/appveyor.ps1"
    - ps: .\appveyor.ps1 "bootstrap" -verbose
    - ps: .\appveyor.ps1 "install_color_scheme_unit" -verbose

build: off

test_script:
    - ps: .\appveyor.ps1 "run_color_scheme_tests" -coverage

More documentation can be found in the UnitTesting documentation.

You can also explore the MonokaiFree for example usage.

CONTRIBUTING

Your issue reports and pull requests are always welcome.

CHANGELOG

See CHANGELOG.md.

LICENSE

Released under the BSD 3-Clause License.