From 36680718efc38a2fa61c4046674e2bab8120aae3 Mon Sep 17 00:00:00 2001 From: Nizar Date: Sun, 17 Mar 2024 21:55:24 +0400 Subject: [PATCH 1/2] Add maxdepth input test --- .github/workflows/test.yml | 27 +++++++++++++++++++++++++-- tests/maxdepth/main.expected.js | 1 + tests/maxdepth/main.js | 7 +++++++ tests/maxdepth/not-affected/main.js | 7 +++++++ 4 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 tests/maxdepth/main.expected.js create mode 100644 tests/maxdepth/main.js create mode 100644 tests/maxdepth/not-affected/main.js diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 128df11..902d50f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -18,7 +18,7 @@ jobs: - name: Test on affected directory uses: ./ with: - directory: "tests/directory/affected/*" + directory: "tests/directory/affected" - name: Assert not affected result does not exist run: | @@ -30,6 +30,29 @@ jobs: tests/directory/affected/main.expected.js \ tests/directory/affected/main.min.js + maxdepth: + runs-on: ubuntu-latest + + steps: + - name: Checkout the repository + uses: actions/checkout@v4 + + - name: Test on shallow maxdepth + uses: ./ + with: + directory: "tests/maxdepth/affected" + maxdepth: 1 + + - name: Assert shallow result matches expected + run: | + git diff --exit-code --no-index \ + tests/maxdepth/main.expected.js \ + tests/maxdepth/main.min.js + + - name: Assert deep result does not exist + run: | + ! test -e tests/maxdepth/not-affected/main.min.js + overwrite: runs-on: ubuntu-latest @@ -40,7 +63,7 @@ jobs: - name: Test overwrite uses: ./ with: - directory: "tests/overwrite/*" + directory: "tests/overwrite" overwrite: true - name: Assert overwrite result matches expected diff --git a/tests/maxdepth/main.expected.js b/tests/maxdepth/main.expected.js new file mode 100644 index 0000000..28e60c1 --- /dev/null +++ b/tests/maxdepth/main.expected.js @@ -0,0 +1 @@ +function print_hello(){console.log("hello world from maxdepth")}window.addEventListener("load",function(){print_hello()}); \ No newline at end of file diff --git a/tests/maxdepth/main.js b/tests/maxdepth/main.js new file mode 100644 index 0000000..953dc64 --- /dev/null +++ b/tests/maxdepth/main.js @@ -0,0 +1,7 @@ +function print_hello() { + console.log('hello world from maxdepth'); +} + +window.addEventListener('load', function () { + print_hello(); +}); diff --git a/tests/maxdepth/not-affected/main.js b/tests/maxdepth/not-affected/main.js new file mode 100644 index 0000000..f63074b --- /dev/null +++ b/tests/maxdepth/not-affected/main.js @@ -0,0 +1,7 @@ +function print_hello() { + console.log('hello world from maxdepth/not-affected'); +} + +window.addEventListener('load', function () { + print_hello(); +}); From d9c4be319c4017dcc697a7aeaaeed5370bf2639a Mon Sep 17 00:00:00 2001 From: Nizar Date: Sun, 17 Mar 2024 21:58:12 +0400 Subject: [PATCH 2/2] Fix maxdepth test directory --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 902d50f..6b8e510 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -40,7 +40,7 @@ jobs: - name: Test on shallow maxdepth uses: ./ with: - directory: "tests/maxdepth/affected" + directory: "tests/maxdepth" maxdepth: 1 - name: Assert shallow result matches expected