j178 / leetgo

Best LeetCode friend for geek. :snowboarder:
MIT License
540 stars 32 forks source link

[Bug] Cannot run local tests without internet #315

Open amyruic opened 4 days ago

amyruic commented 4 days ago

leetgo debug

Leetgo version info :

1.4.11
commit: 2656a5ce011a8874d2e04ae6cb4b02263499c595
built at: 2024-11-09T05:14:22Z
goos: darwin
goarch: arm64

Home dir : /Users/amyr/.config/leetgo Project root : /Users/amyr/code/my-sols Working dir : /Users/amyr/code/my-sols/python/0001.two-sum Project config file : /Users/amyr/code/my-sols/leetgo.yaml Project configuration:

# Leetgo configuration file, see more at https://github.com/j178/leetgo

# Your name
author: amyrd
# Language of the question description: 'zh' (Simplified Chinese) or 'en' (English).
language: en
code:
  # Language of code generated for questions: go, cpp, python, java... 
  # (will be overridden by command line flag -l/--lang).
  lang: python
  # The default template to generate filename (without extension), e.g. {{.Id}}.{{.Slug}}
  # Available attributes: Id, Slug, Title, Difficulty, Lang, SlugIsMeaningful
  # (Most questions have descriptive slugs, but some consist of random characters. The SlugIsMeaningful boolean indicates whether a slug is meaningful.)
  # Available functions: lower, upper, trim, padWithZero, toUnderscore, group.
  filename_template: '{{ .Id | padWithZero 4 }}{{ if .SlugIsMeaningful }}.{{ .Slug }}{{ end }}'
  # Generate question description into a separate question.md file, otherwise it will be embed in the code file.
  separate_description_file: true
  # Default modifiers for all languages.
  modifiers:
    - name: removeUselessComments
  go:
    # Base directory to put generated questions, defaults to the language slug, e.g. go, python, cpp.
    out_dir: go
    # Functions that modify the generated code.
    modifiers:
      - name: removeUselessComments
      - name: changeReceiverName
      - name: addNamedReturn
      - name: addMod
  python3:
    # Base directory to put generated questions, defaults to the language slug, e.g. go, python, cpp.
    out_dir: python
    # Path to the python executable that creates the venv.
    executable: python3
  cpp:
    # Base directory to put generated questions, defaults to the language slug, e.g. go, python, cpp.
    out_dir: cpp
    # C++ compiler
    cxx: g++
    # C++ compiler flags (our Leetcode I/O library implementation requires C++17).
    cxxflags: -O2 -std=c++17
  rust:
    # Base directory to put generated questions, defaults to the language slug, e.g. go, python, cpp.
    out_dir: rust
  java:
    # Base directory to put generated questions, defaults to the language slug, e.g. go, python, cpp.
    out_dir: java
leetcode:
  # LeetCode site, https://leetcode.com or https://leetcode.cn
  site: https://leetcode.com
  # Credentials to access LeetCode.
  credentials:
    # How to provide credentials: browser, cookies, password or none.
    from: cookies    # Browsers to get cookies from: chrome, safari, edge or firefox. If empty, all browsers will be tried. Only used when 'from' is 'browser'.

    browsers: []
contest:
  # Base directory to put generated contest questions.
  out_dir: contest
  # Template to generate filename of the question.
  filename_template: '{{ .ContestShortSlug }}/{{ .Id }}{{ if .SlugIsMeaningful }}.{{ .Slug }}{{ end }}'
  # Open the contest page in browser after generating.
  open_in_browser: true
# Editor settings to open generated files.
editor:
  # Use a predefined editor: vim, vscode, goland
  # Set to 'none' to disable, set to 'custom' to provide your own command and args.
  use: custom
  # Custom command to open files.
  command: "nvim"
  # Arguments to your custom command.
  # String contains {{.CodeFile}}, {{.TestFile}}, {{.DescriptionFile}}, {{.TestCasesFile}} will be replaced with corresponding file path.
  # {{.Folder}} will be substituted with the output directory.
  # {{.Files}} will be substituted with the list of all file paths.
  args: ""

Full configuration :

author: amyrd
language: en
code:
  lang: python
  filename_template: '{{ .Id | padWithZero 4 }}{{ if .SlugIsMeaningful }}.{{ .Slug }}{{ end }}'
  separate_description_file: true
  modifiers:
    - name: removeUselessComments
  go:
    out_dir: go
    modifiers:
      - name: removeUselessComments
      - name: changeReceiverName
      - name: addNamedReturn
      - name: addMod
  python3:
    out_dir: python
    executable: python3
  cpp:
    out_dir: cpp
    cxx: g++
    cxxflags: -O2 -std=c++17
  rust:
    out_dir: rust
  java:
    out_dir: java
leetcode:
  site: https://leetcode.com
  credentials:
    from: cookies
    browsers: []
contest:
  out_dir: contest
  filename_template: '{{ .ContestShortSlug }}/{{ .Id }}{{ if .SlugIsMeaningful }}.{{ .Slug }}{{ end }}'
  open_in_browser: true
editor:
  use: custom
  command: nvim
  args: ""

Debug log

No response

Description

I honestly don't know if this is a bug or not but I though "local" testing means I can run it even offline. But it only works if I have internet?

image

j178 commented 4 days ago

Thanks for the report, will take a look.

j178 commented 3 days ago

I reviewed the local test code path and, unfortunately, we can't make local testing work entirely offline. We might need to redefine "local testing" to mean running tests locally with an internet connection.