タグ: vscode

  • VS Codeでリポジトリをクローン

    普段はシェルから操作することが多いのですが、VS Code の使い方を確認しておこうと思いまして。

    VS Code左側のメニューで Source Control を選択して Clone Repository をクリック。

    clone repository
    Clone Repository

    入力ダイアログで Clone From GitHub を選択。アプリの認証が要求されたら適宜認証を進めて完了させる。

    リポジトリ名を入力。(GitHub側にリポジトリが作成されている前提)

    クローン先(ローカル)の場所を指定(Select Repository Location)。

    例えば Local の WordPress環境 で子テーマを作成して GitHub で管理する場合は

    .../(sitename)/app/public/wp-content/themes

    のような場所になります。

    クローンできたらOpen。

    適宜WorkSpaceを名前をつけて保存するなど。

  • phpのテスト環境 – Windows

    メモ書き程度で恐縮ですが。

    ローカル環境の場合

    レシピ
    – Windows10
    – PHP-7.4.x
    – phpunit
    – Git for Windows
    – VS Code

    https://windows.php.net/download/
    ここからNon Thread Safeのzipファイルをダウンロードして展開し、C:\php へ配置。

    環境変数(システム -> 詳細設定 -> 環境変数)を開いてユーザーもしくはシステムの環境変数:PATH に C:\php を追加。

    合わせて git の環境も整えておく。

    (さらに…)
  • Visual Studio Codeを使ってみる – macOS

    Get Started Tutorialにそって進めてみる

    Getting Started with Python

    Python環境の確認

    Python 3.0 Release
    パッケージをインストール

    $ which python3
    /Library/Frameworks/Python.framework/Versions/3.6/bin/python3
    $ python3 --version
    Python 3.6.5
    

    Visual Studio Code インストール

    Visual Studio Code

    python3 -m venv

    $ cd Hello
    $ python3 -m venv venv
    

    Running VS Code on macOS

    $ cat << EOF >> ~/.bash_profile
    # Add Visual Studio Code (code)
    export PATH="\$PATH:/Applications/Visual Studio Code.app/Contents/Resources/app/bin"
    EOF
    

    VSCodeを起動

    $ code .
    

    VSCode起動

    Configure Python Environment

    Configuring Python environments

    Command + Shift + P
    Python: Select Interpreter

    ./venv/bin/python
    

    Python3.6.5(venv)

    早速コードを書き始めると linter(pylint)のインストールを促される。
    そのままインストール。

    Successfully installed astroid-1.6.3 isort-4.3.4 lazy-object-proxy-1.3.1 mccabe-0.6.1 pylint-1.8.4 six-1.11.0 wrapt-1.10.11
    You are using pip version 9.0.3, however version 10.0.0 is available.
    You should consider upgrading via the 'pip install --upgrade pip' command.
    

    pipのアップデート
    最後のメッセージにしたがって、

    $ pip install --upgrade pip
    

    ひとまずの環境が整ったようなので動かしてみる。

    hello.pyを追加(編集)

    print('Hello World!!')
    

    VSCodeのterminalから

    $ source venv/bin/activate
    $ python hello.py
    

    Unit Testing

    Unit testing Python in VS Code
    Command + Shift + P
    で Command Pallete を開いて Unit と入力。
    Command Pallete

    Python: Run All Unit Tests
    

    を選択すると、画面右下に次の表示。
    Enable and configure a Test Framework

    青いボタンをクリックしてテスト環境の設定を進める。
    unittest

    テストコードをtestフォルダにまとめたいので test を選択。
    (testフォルダがなければ作成しておく。
    test folder

    testから始まるファイルをテストコードの対象に。
    test*.py

    出来上がった .vscode/settings.json

    ではコードを書いていきます。

    test/testCalc.py

    calc.py

    ステータスバーの [Run Tests] をクリックして [Run All Unit Tests] を実行。
    OUTPUT の Python Test Log に OK が表示されればOK。
    ただし、テストの2回目以降に、

    OK
    Unhandled exception in thread started by

    のような例外が発生する模様。
    しばらく様子をみます。

    [追記:2018.06.09]

    VS Code 1.24.0 にバージョンアップしたら上記の例外が出なくなりました。