Skip to content

Instantly share code, notes, and snippets.

@ChrisColeTech
Last active August 17, 2025 18:47
Show Gist options
  • Select an option

  • Save ChrisColeTech/94b6706f7eb7e35082493445e86cf0d5 to your computer and use it in GitHub Desktop.

Select an option

Save ChrisColeTech/94b6706f7eb7e35082493445e86cf0d5 to your computer and use it in GitHub Desktop.
README documentation for the toast notification test script

Toast Notification Test Script

This test script provides automated testing for the Windows Toast Notification system in WSL environments. It performs a complete uninstall and reinstall cycle to verify that all components are working correctly.

Overview

The test script (test_toast_install.sh) automates the complete lifecycle testing of toast notifications by:

  1. Uninstalling existing components - Removes both WSL and Windows toast components
  2. Reinstalling fresh components - Downloads and installs the latest versions
  3. Testing functionality - Verifies that toast notifications work end-to-end

Usage

Download and run the test script:

For WSL Users:

# Step 1: Verify PowerShell is accessible (use full path)
/mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe -Command "Get-Host | Select-Object Version"

# Step 2: Download and run the test script
curl -fsSL 'https://gist.githubusercontent.com/ChrisColeTech/fa65773ebbdd4956678327841a895669/raw/test_toast_install.sh' -o test_toast_install.sh
chmod +x test_toast_install.sh
./test_toast_install.sh

Note for WSL users: The test script automatically detects WSL environment and uses the correct PowerShell path (/mnt/c/). No PATH modification needed.

For MSYS2/Git Bash Users:

# Step 1: Add PowerShell to PATH (MSYS2/Git Bash users)
export PATH="/c/Windows/System32/WindowsPowerShell/v1.0:$PATH"
echo 'export PATH="/c/Windows/System32/WindowsPowerShell/v1.0:$PATH"' >> ~/.bashrc
source ~/.bashrc

# Step 2: Verify PowerShell is accessible
powershell.exe -Command "Get-Host | Select-Object Version"

# Step 3: Download and run the test script
curl -fsSL 'https://gist.githubusercontent.com/ChrisColeTech/fa65773ebbdd4956678327841a895669/raw/test_toast_install.sh' -o test_toast_install.sh
chmod +x test_toast_install.sh
./test_toast_install.sh

What the Test Does

Step 1: Uninstall WSL Components

  • Downloads the WSL uninstaller script
  • Removes toast function from shell configuration files (.bashrc, .zshrc)
  • Removes the ~/bin/toast executable script
  • Cleans up PATH modifications

Step 2: Uninstall Windows Components

  • Downloads the Windows uninstaller script
  • Removes PowerShell scripts (toast.ps1, toast.cmd)
  • Removes the ~/bin directory from Windows PATH
  • Uninstalls the BurntToast PowerShell module (with -Force flag)
  • Cleans up Windows user profile modifications

Step 3: Fresh Installation

  • Downloads the latest WSL installer script
  • Automatically detects Windows username
  • Installs Windows components:
    • NuGet package provider
    • BurntToast PowerShell module
    • PowerShell and CMD wrapper scripts
  • Installs WSL components:
    • Shell functions for bash and zsh
    • Executable script in ~/bin/toast
    • PATH modifications

Step 4: Functionality Test

  • Sources shell configuration to load new functions
  • Sends a test notification: "Test Complete - Toast notification system is working correctly!"
  • Verifies that the toast command is available and functional

Expected Output

The test script provides colored output with clear status messages:

=== Toast Notification Test Script ===

[INFO] Step 1: Uninstalling WSL toast components...
[INFO] Step 2: Uninstalling Windows toast components...
[INFO] Step 3: Installing toast notifications (both Windows and WSL)...
[INFO] Step 4: Testing toast notification functionality...
[INFO] ✓ Toast notification test successful!

=== Test Script Complete ===
[INFO] Toast notification system has been successfully uninstalled and reinstalled.
[INFO] You should have seen a test notification appear.

Requirements

  • Windows 10/11 with WSL enabled
  • Internet connection for downloading scripts and PowerShell modules
  • PowerShell execution permissions (handled automatically by the script)
  • Basic shell access (bash or zsh)

Troubleshooting

Test Fails at Step 1 or 2 (Uninstall)

  • Ensure you have write permissions to your home directory
  • Check that you can access Windows file system from WSL (/mnt/c/)

Test Fails at Step 3 (Installation)

  • Verify internet connectivity for downloading scripts
  • Ensure PowerShell is available at /mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe
  • Check that you can write to Windows Downloads folder

PowerShell Not Found Error

If you get "powershell.exe: command not found":

For WSL users:

# Try alternative PowerShell location (32-bit systems):
export PATH="/mnt/c/Windows/syswow64/WindowsPowerShell/v1.0:$PATH"
echo 'export PATH="/mnt/c/Windows/syswow64/WindowsPowerShell/v1.0:$PATH"' >> ~/.bashrc
source ~/.bashrc

# Or try using full path directly:
/mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe -Command "Get-Host | Select-Object Version"

For MSYS2/Git Bash users:

# Try alternative PowerShell location (32-bit systems):
export PATH="/c/Windows/syswow64/WindowsPowerShell/v1.0:$PATH"
echo 'export PATH="/c/Windows/syswow64/WindowsPowerShell/v1.0:$PATH"' >> ~/.bashrc
source ~/.bashrc

Test Fails at Step 4 (Testing)

  • Try opening a new terminal session and running toast "test" "message" manually
  • Verify that ~/bin is in your PATH: echo $PATH | grep bin
  • Check that the toast function is loaded: type toast

No Toast Notification Appears

  • Check Windows notification settings (Settings > System > Notifications)
  • Ensure Focus Assist is not blocking notifications
  • Try running the toast command manually: toast "Manual Test" "Hello World"

Related Scripts

This test script works with the following components:

  • WSL Installer: https://gist.github.com/ChrisColeTech/010a3a1f313fa39a10566a328c32424b
  • Windows Installer: https://gist.github.com/ChrisColeTech/1f79919c60bf210982a04bc607a1a1d7
  • WSL Uninstaller: https://gist.github.com/ChrisColeTech/42d5862c4817c269ef6aa42f7ff490ce
  • Windows Uninstaller: https://gist.github.com/ChrisColeTech/c7c8d4fb8f8e72ac01722cb5d5ce79f9

Exit Codes

  • 0: All tests passed successfully
  • 1: Failed to download required scripts
  • 1: Installation or testing failed

Security Notes

  • The script downloads and executes PowerShell scripts from trusted gist sources
  • All temporary files are cleaned up after execution
  • The script uses -ExecutionPolicy Bypass only for the specific toast installation scripts
  • No permanent system modifications are made beyond the toast notification functionality

Support

If you encounter issues with the test script, ensure that:

  1. The individual installation scripts work when run manually
  2. Your WSL environment has proper access to the Windows file system
  3. Windows PowerShell execution is not blocked by group policy
  4. You have sufficient permissions to install PowerShell modules

For detailed troubleshooting, run the individual installer scripts manually to isolate any specific issues.

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