Skip to content
Open
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
2 changes: 2 additions & 0 deletions build-web.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

set -e -o pipefail # stop if a command or pipeline fails

cd -- "$(dirname -- "${BASH_SOURCE[0]}")"

lake exe cache get
lake -R -Kenv=dev build Analysis:docs
lake build
Expand Down
2 changes: 2 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@

set -e -o pipefail # stop if a command or pipeline fails

cd -- "$(dirname -- "${BASH_SOURCE[0]}")"

lake exe cache get
lake build
5 changes: 3 additions & 2 deletions serve.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
import urllib
from http import HTTPStatus

BOOK_SITE = os.path.abspath('./.lake/build/literate-html')
DOCS_SITE = os.path.abspath('./.lake/build/doc')
ROOT = os.path.dirname(os.path.abspath(__file__))
BOOK_SITE = os.path.join(ROOT, '.lake', 'build', 'literate-html')
DOCS_SITE = os.path.join(ROOT, '.lake', 'build', 'doc')

class CustomHTTPRequestHandler(SimpleHTTPRequestHandler):
# Avoid spurious error messages from /favicon.ico
Expand Down
36 changes: 36 additions & 0 deletions tests/test_script_roots.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import json
from pathlib import Path
import os
import shutil
import subprocess
import sys
import tempfile
import unittest


class TestScriptRoots(unittest.TestCase):
def test_builds_and_preview_resolve_paths_from_repository(self):
source = Path(__file__).resolve().parents[1]
with tempfile.TemporaryDirectory() as directory:
base = Path(directory).resolve()
repo = base / 'checkout with spaces'
repo.mkdir()
for name in ('build.sh', 'build-web.sh', 'serve.py'):
shutil.copyfile(source / name, repo / name)
tools = base / 'bin'
tools.mkdir()
lake = tools / 'lake'
lake.write_text('#!/bin/sh\npwd >> "$LAKE_CWD_LOG"\n')
lake.chmod(0o755)
log = base / 'lake.log'
env = dict(os.environ, PATH=str(tools) + os.pathsep + os.environ['PATH'],
LAKE_CWD_LOG=str(log))
for name in ('build.sh', 'build-web.sh'):
subprocess.run(['bash', str(repo / name)], cwd=base, env=env, check=True)
self.assertEqual(log.read_text().splitlines(), [str(repo)] * 6)
code = ('import json, runpy; m=runpy.run_path(' + repr(str(repo / 'serve.py')) + '); '
'print(json.dumps([m["BOOK_SITE"], m["DOCS_SITE"]]))')
result = subprocess.run([sys.executable, '-c', code], cwd=base,
text=True, capture_output=True, check=True)
self.assertEqual(json.loads(result.stdout),
[str(repo / '.lake/build/literate-html'), str(repo / '.lake/build/doc')])
Loading