Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@ tools.json
gathered_links.json
colophon.html
index.html
__pycache__/
*.pyc
.pytest_cache/
18 changes: 5 additions & 13 deletions sloccount.html
Original file line number Diff line number Diff line change
Expand Up @@ -373,19 +373,11 @@ <h3>Language Breakdown</h3>
// Initialize WebPerl
async function initializeWebPerl() {
try {
showStatus('Loading Perl WebAssembly runtime...', 'info');
showStatus('Initializing...', 'info');

// Wait for Perl to be ready
await Perl.init();

showStatus('Loading SLOCCount tools from GitHub...', 'info');

// Download sloccount scripts from GitHub
const commitHash = '7220ff627334a8f646617fe0fa542d401fb5287e';
const zipUrl = `https://github.com/licquia/sloccount/archive/${commitHash}.zip`;

// For now, we'll implement a simpler version using basic line counting
// In a production version, we would fetch and extract the full sloccount
// For now, we implement a simpler version using basic line counting
// without requiring the full WebPerl/sloccount integration
// This makes the tool work immediately without external dependencies
perlReady = true;

analyzePasteBtn.textContent = 'Analyze Code';
Expand Down Expand Up @@ -602,4 +594,4 @@ <h3>Language Breakdown</h3>
initializeWebPerl();
</script>
</body>
</html>
</html>
29 changes: 15 additions & 14 deletions tests/test_sloccount.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import pathlib
from playwright.sync_api import Page, expect
import pytest
import re
from subprocess import Popen, PIPE
import time

Expand Down Expand Up @@ -48,8 +49,8 @@ def test_initial_state(page: Page, static_server):
expect(page.locator('.tab[data-tab="github"]')).to_have_text("GitHub Repository")

# Paste tab should be active by default
expect(page.locator('.tab[data-tab="paste"]')).to_have_class(/active/)
expect(page.locator('#paste-tab')).to_have_class(/active/)
expect(page.locator('.tab[data-tab="paste"]')).to_have_class(re.compile("active"))
expect(page.locator('#paste-tab')).to_have_class(re.compile("active"))

# Results should be hidden initially
expect(page.locator("#results")).not_to_be_visible()
Expand All @@ -61,15 +62,15 @@ def test_tab_switching(page: Page, static_server):

# Click GitHub tab
page.locator('.tab[data-tab="github"]').click()
expect(page.locator('.tab[data-tab="github"]')).to_have_class(/active/)
expect(page.locator('#github-tab')).to_have_class(/active/)
expect(page.locator('#paste-tab')).not_to_have_class(/active/)
expect(page.locator('.tab[data-tab="github"]')).to_have_class(re.compile("active"))
expect(page.locator('#github-tab')).to_have_class(re.compile("active"))
expect(page.locator('#paste-tab')).not_to_have_class(re.compile("active"))

# Click back to Paste tab
page.locator('.tab[data-tab="paste"]').click()
expect(page.locator('.tab[data-tab="paste"]')).to_have_class(/active/)
expect(page.locator('#paste-tab')).to_have_class(/active/)
expect(page.locator('#github-tab')).not_to_have_class(/active/)
expect(page.locator('.tab[data-tab="paste"]')).to_have_class(re.compile("active"))
expect(page.locator('#paste-tab')).to_have_class(re.compile("active"))
expect(page.locator('#github-tab')).not_to_have_class(re.compile("active"))


def test_analyze_python_code(page: Page, static_server):
Expand Down Expand Up @@ -172,7 +173,7 @@ def test_empty_code_validation(page: Page, static_server):

# Should show error status
expect(page.locator("#status")).to_be_visible()
expect(page.locator("#status")).to_have_class(/error/)
expect(page.locator("#status")).to_have_class(re.compile("error"))


def test_missing_filename_validation(page: Page, static_server):
Expand All @@ -190,15 +191,15 @@ def test_missing_filename_validation(page: Page, static_server):

# Should show error status
expect(page.locator("#status")).to_be_visible()
expect(page.locator("#status")).to_have_class(/error/)
expect(page.locator("#status")).to_have_class(re.compile("error"))


def test_github_repo_validation(page: Page, static_server):
"""Test GitHub repo URL validation"""
page.goto("http://127.0.0.1:8123/sloccount.html")

# Wait for initialization
page.wait_for_selector("#analyze-repo-btn:not([disabled])", timeout=10000)
# Wait for initialization (wait for visible button in active tab)
page.wait_for_selector("#analyze-paste-btn:not([disabled])", timeout=10000)

# Switch to GitHub tab
page.locator('.tab[data-tab="github"]').click()
Expand All @@ -208,7 +209,7 @@ def test_github_repo_validation(page: Page, static_server):

# Should show error status
expect(page.locator("#status")).to_be_visible()
expect(page.locator("#status")).to_have_class(/error/)
expect(page.locator("#status")).to_have_class(re.compile("error"))


def test_language_detection(page: Page, static_server):
Expand Down Expand Up @@ -255,4 +256,4 @@ def test_mobile_responsive(page: Page, static_server):
# Check that elements are still visible
expect(page.locator("h1")).to_be_visible()
expect(page.locator("#code-input")).to_be_visible()
expect(page.locator("#analyze-paste-btn")).to_be_visible()
expect(page.locator("#analyze-paste-btn")).to_be_visible()