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 807
  • Win 542
  • OS X 133
  • Linux 132
Oct 18 Oct 17 Oct 16 Oct 15 Oct 14 Oct 13 Oct 12 Oct 11 Oct 10 Oct 9 Oct 8 Oct 7 Oct 6 Oct 5 Oct 4 Oct 3 Oct 2 Oct 1 Sep 30 Sep 29 Sep 28 Sep 27 Sep 26 Sep 25 Sep 24 Sep 23 Sep 22 Sep 21 Sep 20 Sep 19 Sep 18 Sep 17 Sep 16 Sep 15 Sep 14 Sep 13 Sep 12 Sep 11 Sep 10 Sep 9 Sep 8 Sep 7 Sep 6 Sep 5 Sep 4 Sep 3
Windows 1 3 2 1 1 4 2 1 2 5 4 4 2 4 3 0 2 6 1 2 3 3 5 2 3 2 4 3 1 5 4 1 3 3 5 4 4 2 2 2 0 0 3 0 1 1
OS X 1 1 0 0 0 1 0 1 0 2 0 0 0 1 1 0 1 0 1 0 1 2 1 1 2 1 1 0 0 2 4 0 1 1 3 1 0 0 0 2 0 1 1 0 0 0
Linux 0 2 1 1 0 1 0 0 2 0 2 0 1 0 0 0 0 0 1 0 1 1 1 1 0 0 1 1 1 0 1 2 1 1 2 2 0 0 0 0 0 0 1 0 0 0

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
}

Writing tests

Color scheme tests are very similar to syntax tests.

  • Test must be saved within the Packages directory.
  • Tests musts use spaces (not tabs).

Test file names must begin with: “color_scheme_test” e.g. color_scheme_test.php, color_scheme_test.css, and can also contain long descriptions e.g. color_scheme_test_long_description.js. Here is a suggested layout for your tests:

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

The first line of test files must begin a test case definition in the format:

<comment_token> COLOR SCHEME TEST "<color_scheme>" [SKIP IF NOT ]"<syntax>"

Python example:

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

PHP example:

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

Syntaxes can be optionally skipped if they do not exist:

<?php // COLOR SCHEME TEST "MonokaiFree/MonokaiFree.tmTheme" SKIP IF NOT "blade"

Each test in the syntax 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

Linux example:

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.