Skip to content

Commit

Permalink
Revert "Rewrite tools/format.py in deno (denoland#1528)" (denoland#1752)
Browse files Browse the repository at this point in the history
tools/format.ts is making CI flaky and it's difficult to run right now.
Reverting to tools/format.py

This reverts commit f19622e.
  • Loading branch information
ry authored Feb 12, 2019
1 parent 9240f9b commit 0b0d962
Show file tree
Hide file tree
Showing 21 changed files with 59 additions and 264 deletions.
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
js/flatbuffers.js
tests/error_syntax.js
tests/badly_formatted.js
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ before_script:
# Default script for release builds.
script:
- ./tools/lint.py
- ./tools/build.py -C target/release
- ./tools/test_format.py
- ./tools/build.py -C target/release
- DENO_BUILD_MODE=release ./tools/test.py

jobs:
Expand Down
2 changes: 0 additions & 2 deletions js/unit_tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ import "./url_search_params_test.ts";
import "./write_file_test.ts";
import "./performance_test.ts";

import "../tools/util_test.ts";

import "../website/app_test.js";

import "deps/https/deno.land/x/std/testing/main.ts";
50 changes: 50 additions & 0 deletions tools/format.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/usr/bin/env python
# Copyright 2018 the Deno authors. All rights reserved. MIT license.
from glob import glob
import os
import sys
from third_party import fix_symlinks, google_env, python_env
from third_party import clang_format_path, third_party_path
from util import root_path, run, find_exts, platform

fix_symlinks()

prettier = os.path.join(third_party_path, "node_modules", "prettier",
"bin-prettier.js")
tools_path = os.path.join(root_path, "tools")
rustfmt_config = os.path.join(root_path, ".rustfmt.toml")

os.chdir(root_path)


def qrun(cmd, env=None):
run(cmd, quiet=True, env=env)


print "clang_format"
qrun([clang_format_path, "-i", "-style", "Google"] +
find_exts(["libdeno"], [".cc", ".h"]))

print "gn format"
for fn in ["BUILD.gn", ".gn"] + find_exts(["build_extra", "libdeno"],
[".gn", ".gni"]):
qrun(["third_party/depot_tools/gn", "format", fn], env=google_env())

print "yapf"
qrun(
[sys.executable, "third_party/python_packages/bin/yapf", "-i"] + find_exts(
["tools", "build_extra"], [".py"], skip=["tools/clang"]),
env=python_env())

print "prettier"
qrun(["node", prettier, "--write", "--loglevel=error"] + ["rollup.config.js"] +
glob("*.json") + glob("*.md") +
find_exts([".github", "js", "tests", "tools", "website"],
[".js", ".json", ".ts", ".md"],
skip=["tools/clang", "js/deps"]))

print "rustfmt"
qrun([
"third_party/rustfmt/" + platform() +
"/rustfmt", "--config-path", rustfmt_config, "build.rs"
] + find_exts(["src"], [".rs"]))
86 changes: 0 additions & 86 deletions tools/format.ts

This file was deleted.

28 changes: 3 additions & 25 deletions tools/test_format.py
Original file line number Diff line number Diff line change
@@ -1,40 +1,18 @@
#!/usr/bin/env python
# Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
# This program fails if ./tools/format.ts changes any files.
# This program fails if ./tools/format.py changes any files.

import os
import sys
import util
import sys
import subprocess
from distutils.spawn import find_executable


def lookup_deno_path():
deno_exe = "deno" + util.executable_suffix
release_deno = os.path.join(util.root_path, "target", "release", deno_exe)
debug_deno = os.path.join(util.root_path, "target", "debug", deno_exe)

if os.path.exists(release_deno):
return release_deno
if os.path.exists(debug_deno):
return debug_deno

return find_executable("deno")


def main():
deno_path = lookup_deno_path()

if not deno_path:
print "No available deno executable."
sys.exit(1)

util.run([deno_path, "--allow-read", "--allow-run", "tools/format.ts"])
util.run([sys.executable, "tools/format.py"])
output = util.run_output(
["git", "status", "-uno", "--porcelain", "--ignore-submodules"])
if len(output) > 0:
print "Run tools/format.ts "
print "Run tools/format.py "
print output
sys.exit(1)

Expand Down
1 change: 0 additions & 1 deletion tools/testdata/find_files_testdata/bar.md

This file was deleted.

1 change: 0 additions & 1 deletion tools/testdata/find_files_testdata/bar.ts

This file was deleted.

1 change: 0 additions & 1 deletion tools/testdata/find_files_testdata/bar.txt

This file was deleted.

1 change: 0 additions & 1 deletion tools/testdata/find_files_testdata/foo.md

This file was deleted.

1 change: 0 additions & 1 deletion tools/testdata/find_files_testdata/foo.ts

This file was deleted.

1 change: 0 additions & 1 deletion tools/testdata/find_files_testdata/foo.txt

This file was deleted.

1 change: 0 additions & 1 deletion tools/testdata/find_files_testdata/subdir0/bar.ts

This file was deleted.

1 change: 0 additions & 1 deletion tools/testdata/find_files_testdata/subdir0/foo.ts

This file was deleted.

1 change: 0 additions & 1 deletion tools/testdata/find_files_testdata/subdir0/subdir0/bar.ts

This file was deleted.

1 change: 0 additions & 1 deletion tools/testdata/find_files_testdata/subdir0/subdir0/foo.ts

This file was deleted.

1 change: 0 additions & 1 deletion tools/testdata/find_files_testdata/subdir1/bar.ts

This file was deleted.

1 change: 0 additions & 1 deletion tools/testdata/find_files_testdata/subdir1/foo.ts

This file was deleted.

72 changes: 0 additions & 72 deletions tools/util.ts

This file was deleted.

61 changes: 0 additions & 61 deletions tools/util_test.ts

This file was deleted.

7 changes: 2 additions & 5 deletions website/manual.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,7 @@ cd deno
./tools/test.py
# Format code.
# TODO: set PYTHONPATH in format.ts when run API has env option.
PYTHONPATH=third_party/python_packages deno ./tools/format.ts --allow-read --allow-run
./tools/format.py
```

#### Prerequisites
Expand Down Expand Up @@ -612,9 +611,7 @@ Before submitting, please make sure the following is done:

1. There are tests that cover the changes.
2. Ensure `./tools/test.py` passes.
3. Format your code with
`PYTHONPATH=third_party/python_packages deno ./tools/format.ts --allow-read --allow-run`.
<!-- TODO: set PYTHONPATH in format.ts when run API has env option -->
3. Format your code with `tools/format.py`
4. Make sure `./tools/lint.py` passes.

### Changes to `third_party`
Expand Down

0 comments on commit 0b0d962

Please sign in to comment.