Skip to content
Merged
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 @@ -141,3 +141,6 @@ cython_debug/
# static files generated from Django application using `collectstatic`
media
static

test/fixtures/out
*.actual
31 changes: 31 additions & 0 deletions test/fixtures/expected-darwin/cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
cmake_minimum_required(VERSION 2.8.8 FATAL_ERROR)
cmake_policy(VERSION 2.8.8)
project(test)
set(configuration "Default")
enable_language(ASM)
set(builddir "${CMAKE_CURRENT_BINARY_DIR}")
set(obj "${builddir}/obj")

set(CMAKE_C_OUTPUT_EXTENSION_REPLACE 1)
set(CMAKE_CXX_OUTPUT_EXTENSION_REPLACE 1)



#*/gyp-next/test/fixtures/integration.gyp:test#target
set(TARGET "test")
set(TOOLSET "target")
set(test__cxx_srcs "../../test.cc")
link_directories( ../../mylib
)
add_executable(test ${test__cxx_srcs})
set_target_properties(test PROPERTIES EXCLUDE_FROM_ALL "FALSE")
set_target_properties(test PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${builddir}")
set_target_properties(test PROPERTIES PREFIX "")
set_target_properties(test PROPERTIES RUNTIME_OUTPUT_NAME "test")
set_target_properties(test PROPERTIES SUFFIX "")
set_source_files_properties(${builddir}/test PROPERTIES GENERATED "TRUE")
set(test__include_dirs "${CMAKE_CURRENT_LIST_DIR}/../../include")
set_property(TARGET test APPEND PROPERTY INCLUDE_DIRECTORIES ${test__include_dirs})
set_target_properties(test PROPERTIES COMPILE_FLAGS "-fasm-blocks -mpascal-strings -Os -gdwarf-2 -arch x86_64 ")
unset(TOOLSET)
unset(TARGET)
86 changes: 86 additions & 0 deletions test/fixtures/expected-darwin/make/test.target.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# This file is generated by gyp; do not edit.

TOOLSET := target
TARGET := test
DEFS_Default :=

# Flags passed to all source files.
CFLAGS_Default := \
-fasm-blocks \
-mpascal-strings \
-Os \
-gdwarf-2 \
-arch \
x86_64

# Flags passed to only C files.
CFLAGS_C_Default :=

# Flags passed to only C++ files.
CFLAGS_CC_Default :=

# Flags passed to only ObjC files.
CFLAGS_OBJC_Default :=

# Flags passed to only ObjC++ files.
CFLAGS_OBJCC_Default :=

INCS_Default := \
-I$(srcdir)/include

OBJS := \
$(obj).target/$(TARGET)/test.o

# Add to the list of files we specially track dependencies for.
all_deps += $(OBJS)

# CFLAGS et al overrides must be target-local.
# See "Target-specific Variable Values" in the GNU Make manual.
$(OBJS): TOOLSET := $(TOOLSET)
$(OBJS): GYP_CFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE))
$(OBJS): GYP_CXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE))
$(OBJS): GYP_OBJCFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE)) $(CFLAGS_OBJC_$(BUILDTYPE))
$(OBJS): GYP_OBJCXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE)) $(CFLAGS_OBJCC_$(BUILDTYPE))

# Suffix rules, putting all outputs into $(obj).

$(obj).$(TOOLSET)/$(TARGET)/%.o: $(srcdir)/%.cc FORCE_DO_CMD
@$(call do_cmd,cxx,1)

# Try building from generated source, too.

$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj).$(TOOLSET)/%.cc FORCE_DO_CMD
@$(call do_cmd,cxx,1)

$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj)/%.cc FORCE_DO_CMD
@$(call do_cmd,cxx,1)

# End of this set of suffix rules
### Rules for final target.
LDFLAGS_Default := \
-arch \
x86_64 \
-L$(builddir) \
-Lmylib

LIBTOOLFLAGS_Default :=

LIBS :=

$(builddir)/test: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE))
$(builddir)/test: LIBS := $(LIBS)
$(builddir)/test: GYP_LIBTOOLFLAGS := $(LIBTOOLFLAGS_$(BUILDTYPE))
$(builddir)/test: LD_INPUTS := $(OBJS)
$(builddir)/test: TOOLSET := $(TOOLSET)
$(builddir)/test: $(OBJS) FORCE_DO_CMD
$(call do_cmd,link)

all_deps += $(builddir)/test
# Add target alias
.PHONY: test
test: $(builddir)/test

# Add executable to "all" target.
.PHONY: all
all: $(builddir)/test

15 changes: 15 additions & 0 deletions test/fixtures/expected-darwin/ninja/test.ninja
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
defines =
includes = -I../../include
cflags = -fasm-blocks -mpascal-strings -Os -gdwarf-2 -arch x86_64
cflags_c =
cflags_cc =
cflags_objc = $cflags_c
cflags_objcc = $cflags_cc
arflags =

build obj/test.test.o: cxx ../../test.cc

ldflags = -arch x86_64 -L./
libs = -L../../mylib
build test: link obj/test.test.o
ld = $ldxx
32 changes: 32 additions & 0 deletions test/fixtures/expected-linux/cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
cmake_minimum_required(VERSION 2.8.8 FATAL_ERROR)
cmake_policy(VERSION 2.8.8)
project(test)
set(configuration "Default")
enable_language(ASM)
set(builddir "${CMAKE_CURRENT_BINARY_DIR}")
set(obj "${builddir}/obj")

set(CMAKE_C_OUTPUT_EXTENSION_REPLACE 1)
set(CMAKE_CXX_OUTPUT_EXTENSION_REPLACE 1)

set(CMAKE_NINJA_FORCE_RESPONSE_FILE 1)


#*/test/fixtures/integration.gyp:test#target
set(TARGET "test")
set(TOOLSET "target")
set(test__cxx_srcs "../../test.cc")
link_directories( ../../mylib
)
add_executable(test ${test__cxx_srcs})
set_target_properties(test PROPERTIES EXCLUDE_FROM_ALL "FALSE")
set_target_properties(test PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${builddir}")
set_target_properties(test PROPERTIES PREFIX "")
set_target_properties(test PROPERTIES RUNTIME_OUTPUT_NAME "test")
set_target_properties(test PROPERTIES SUFFIX "")
set_source_files_properties(${builddir}/test PROPERTIES GENERATED "TRUE")
set(test__include_dirs "${CMAKE_CURRENT_LIST_DIR}/../../include")
set_property(TARGET test APPEND PROPERTY INCLUDE_DIRECTORIES ${test__include_dirs})
set_target_properties(test PROPERTIES COMPILE_FLAGS "")
unset(TOOLSET)
unset(TARGET)
66 changes: 66 additions & 0 deletions test/fixtures/expected-linux/make/test.target.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# This file is generated by gyp; do not edit.

TOOLSET := target
TARGET := test
DEFS_Default :=

# Flags passed to all source files.
CFLAGS_Default :=

# Flags passed to only C files.
CFLAGS_C_Default :=

# Flags passed to only C++ files.
CFLAGS_CC_Default :=

INCS_Default := \
-I$(srcdir)/include

OBJS := \
$(obj).target/$(TARGET)/test.o

# Add to the list of files we specially track dependencies for.
all_deps += $(OBJS)

# CFLAGS et al overrides must be target-local.
# See "Target-specific Variable Values" in the GNU Make manual.
$(OBJS): TOOLSET := $(TOOLSET)
$(OBJS): GYP_CFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE))
$(OBJS): GYP_CXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE))

# Suffix rules, putting all outputs into $(obj).

$(obj).$(TOOLSET)/$(TARGET)/%.o: $(srcdir)/%.cc FORCE_DO_CMD
@$(call do_cmd,cxx,1)

# Try building from generated source, too.

$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj).$(TOOLSET)/%.cc FORCE_DO_CMD
@$(call do_cmd,cxx,1)

$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj)/%.cc FORCE_DO_CMD
@$(call do_cmd,cxx,1)

# End of this set of suffix rules
### Rules for final target.
LDFLAGS_Default := \
-Lmylib

LIBS :=

$(builddir)/test: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE))
$(builddir)/test: LIBS := $(LIBS)
$(builddir)/test: LD_INPUTS := $(OBJS)
$(builddir)/test: TOOLSET := $(TOOLSET)
$(builddir)/test: $(OBJS) FORCE_DO_CMD
$(call do_cmd,link)

all_deps += $(builddir)/test
# Add target alias
.PHONY: test
test: $(builddir)/test

# Add executable to "all" target.
.PHONY: all
all: $(builddir)/test

13 changes: 13 additions & 0 deletions test/fixtures/expected-linux/ninja/test.ninja
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
defines =
includes = -I../../include
cflags =
cflags_c =
cflags_cc =
arflags =

build obj/test.test.o: cxx ../../test.cc

ldflags =
libs = -L../../mylib
build test: link obj/test.test.o
ld = $ldxx
3 changes: 3 additions & 0 deletions test/fixtures/include/test.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#pragma once

int foo();
17 changes: 17 additions & 0 deletions test/fixtures/integration.gyp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
'targets': [
{
'target_name': 'test',
'type': 'executable',
'sources': [
'test.cc',
],
'include_dirs': [
'include',
],
'library_dirs': [
'mylib'
],
},
]
}
9 changes: 9 additions & 0 deletions test/fixtures/test.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include "test.h"

int main() {
return foo();
}

int foo() {
return 0;
}
70 changes: 70 additions & 0 deletions test/integration_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#!/usr/bin/env python3

"""Integration test"""

import os
import re
import shutil
import unittest

import gyp

fixture_dir = os.path.join(os.path.dirname(__file__), "fixtures")
gyp_file = os.path.join(os.path.dirname(__file__), "fixtures/integration.gyp")

supported_sysnames = {"darwin", "linux"}
sysname = os.uname().sysname.lower()
expected_dir = os.path.join(fixture_dir, f"expected-{sysname}")


class TestGyp(unittest.TestCase):
def setUp(self) -> None:
if sysname not in supported_sysnames:
self.skipTest(f"Unsupported system: {sysname}")
shutil.rmtree(os.path.join(fixture_dir, "out"), ignore_errors=True)

def assert_file(self, actual, expected) -> None:
actual_filepath = os.path.join(fixture_dir, actual)
expected_filepath = os.path.join(expected_dir, expected)

with open(expected_filepath) as in_file:
expected_bytes = re.escape(in_file.read())
expected_bytes = expected_bytes.replace("\\*", ".*")
expected_re = re.compile(expected_bytes)

with open(actual_filepath) as in_file:
actual_bytes = in_file.read()

try:
self.assertRegex(actual_bytes, expected_re)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comparing assert re.search(expected_re, actual_bytes) and self.assertRegex(actual_bytes, expected_re), when there is a mismatch, self.assertRegex provides more information on the regex and the input:

E   AssertionError: Regex didn't match: '\\#\\ This\\ file\\ is\\ generated\\ by\\ gyp;\\ do\\ not\\ edit\\.\\\n\\\nTOOLSET\\ :=\\ target\\\nTARGET\\ :=\\ test\\\nDEFS_Default\\ :=\\\n\\\n\\#\\ Flags\\ passed\\ to\\ all\\ source\\ files\\.\\\nCFLAGS_Default\\ :=\\ \\\\\\\n\\\t\\-fasm\\-blocks\\ \\\\\\\n\\\t\\-mpascal\\-strings\\ \\\\\\\n\\\t\\-Os\\ \\\\\\\n\\\t\\-gdwarf\\-2\\ \\\\\\\n\\\t\\-arch\\ \\\\\\\n\\\tx86_64\\\n\\\n\\\n\\#\\ Flags\\ passed\\ to\\ only\\ C\\ files\\.\\\nCFLAGS_C_Default\\ :=\\\n\\\n\\#\\ Flags\\ passed\\ to\\ only\\ C\\+\\+\\ files\\.\\\nCFLAGS_CC_Default\\ :=\\\n\\\n\\#\\ Flags\\ passed\\ to\\ only\\ ObjC\\ files\\.\\\nCFLAGS_OBJC_Default\\ :=\\\n\\\n\\#\\ Flags\\ passed\\ to\\ only\\ ObjC\\+\\+\\ files\\.\\\nCFLAGS_OBJCC_Default\\ :=\\\n\\\nINCS_Default\\ :=\\ \\\\\\\n\\\t\\-I\\$\\(srcdir\\)/include\\\n\\\nOBJS\\ :=\\ \\\\\\\n\\\t\\$\\(obj\\)\\.target/\\$\\(TARGET\\)/test\\.o\\\n\\\n\\#\\ Add\\ to\\ the\\ list\\ of\\ files\\ we\\ specially\\ track\\ dependencies\\ for\\.\\\nall_deps\\ \\+=\\ \\$\\(OBJS\\)\\\n\\\n\\#\\ CFLAGS\\ et\\ al\\ overrides\\ must\\ be\\ target\\-local\\.\\\n\\#\\ See\\ "Target\\-specific\\ Variable\\ Values"\\ in\\ the\\ GNU\\ Make\\ manual\\.\\\n\\$\\(OBJS\\):\\ TOOLSET\\ :=\\ \\$\\(TOOLSET\\)\\\n\\$\\(OBJS\\):\\ GYP_CFLAGS\\ :=\\ \\$\\(DEFS_\\$\\(BUILDTYPE\\)\\)\\ \\$\\(INCS_\\$\\(BUILDTYPE\\)\\)\\ \\ \\$\\(CFLAGS_\\$\\(BUILDTYPE\\)\\)\\ \\$\\(CFLAGS_C_\\$\\(BUILDTYPE\\)\\)\\\n\\$\\(OBJS\\):\\ GYP_CXXFLAGS\\ :=\\ \\$\\(DEFS_\\$\\(BUILDTYPE\\)\\)\\ \\$\\(INCS_\\$\\(BUILDTYPE\\)\\)\\ \\ \\$\\(CFLAGS_\\$\\(BUILDTYPE\\)\\)\\ \\$\\(CFLAGS_CC_\\$\\(BUILDTYPE\\)\\)\\\n\\$\\(OBJS\\):\\ GYP_OBJCFLAGS\\ :=\\ \\$\\(DEFS_\\$\\(BUILDTYPE\\)\\)\\ \\$\\(INCS_\\$\\(BUILDTYPE\\)\\)\\ \\ \\$\\(CFLAGS_\\$\\(BUILDTYPE\\)\\)\\ \\$\\(CFLAGS_C_\\$\\(BUILDTYPE\\)\\)\\ \\$\\(CFLAGS_OBJC_\\$\\(BUILDTYPE\\)\\)\\\n\\$\\(OBJS\\):\\ GYP_OBJCXXFLAGS\\ :=\\ \\$\\(DEFS_\\$\\(BUILDTYPE\\)\\)\\ \\$\\(INCS_\\$\\(BUILDTYPE\\)\\)\\ \\ \\$\\(CFLAGS_\\$\\(BUILDTYPE\\)\\)\\ \\$\\(CFLAGS_CC_\\$\\(BUILDTYPE\\)\\)\\ \\$\\(CFLAGS_OBJCC_\\$\\(BUILDTYPE\\)\\)\\\n\\\n\\#\\ Suffix\\ rules,\\ putting\\ all\\ outputs\\ into\\ \\$\\(obj\\)\\.\\\n\\\n\\$\\(obj\\)\\.\\$\\(TOOLSET\\)/\\$\\(TARGET\\)/%\\.o:\\ \\$\\(srcdir\\)/%\\.cc\\ FORCE_DO_CMD\\\n\\\t@\\$\\(call\\ do_cmd,cxx,1\\)\\\n\\\n\\#\\ Try\\ building\\ from\\ generated\\ source,\\ too\\.\\\n\\\n\\$\\(obj\\)\\.\\$\\(TOOLSET\\)/\\$\\(TARGET\\)/%\\.o:\\ \\$\\(obj\\)\\.\\$\\(TOOLSET\\)/%\\.cc\\ FORCE_DO_CMD\\\n\\\t@\\$\\(call\\ do_cmd,cxx,1\\)\\\n\\\n\\$\\(obj\\)\\.\\$\\(TOOLSET\\)/\\$\\(TARGET\\)/%\\.o:\\ \\$\\(obj\\)/%\\.cc\\ FORCE_DO_CMD\\\n\\\t@\\$\\(call\\ do_cmd,cxx,1\\)\\\n\\\n\\#\\ End\\ of\\ this\\ set\\ of\\ suffix\\ rules\\\n\\#\\#\\#\\ Rules\\ for\\ final\\ target\\.\\\nLDFLAGS_Default\\ :=\\ \\\\\\\n\\\t\\-arch\\ \\\\\\\n\\\tx86_64\\ \\\\\\\n\\\t\\-L\\$\\(builddir\\)\\ \\\\\\\n\\\t\\-Lmylib\\\n\\\nLIBTOOLFLAGS_Default\\ :=\\\n\\\nLIBS\\ :=\\\n\\\n\\$\\(builddir\\)/test:\\ GYP_LDFLAGS\\ :=\\ \\$\\(LDFLAGS_\\$\\(BUILDTYPE\\)\\)\\\n\\$\\(builddir\\)/test:\\ LIBS\\ :=\\ \\$\\(LIBS\\)\\\n\\$\\(builddir\\)/test:\\ GYP_LIBTOOLFLAGS\\ :=\\ \\$\\(LIBTOOLFLAGS_\\$\\(BUILDTYPE\\)\\)\\\n\\$\\(builddir\\)/test:\\ LD_INPUTS\\ :=\\ \\$\\(OBJS\\)\\\n\\$\\(builddir\\)/test:\\ TOOLSET\\ :=\\ \\$\\(TOOLSET\\)\\\n\\$\\(builddir\\)/test:\\ \\$\\(OBJS\\)\\ FORCE_DO_CMD\\\n\\\t\\$\\(call\\ do_cmd,link\\)\\\n\\\nall_deps\\ \\+=\\ \\$\\(builddir\\)/test\\\n\\#\\ Add\\ target\\ alias\\\n\\.PHONY:\\ test\\\ntest:\\ \\$\\(builddir\\)/test\\\n\\\n\\#\\ Add\\ executable\\ to\\ "all"\\ target\\.\\\n\\.PHONY:\\ all\\\nall:\\ \\$\\(builddir\\)/test\\\n\\\n' not found in '# This file is generated by gyp; do not edit.\n\nTOOLSET := target\nTARGET := test\nDEFS_Default :=\n\n# Flags passed to all source files.\nCFLAGS_Default := \\\n\t-fasm-blocks \\\n\t-mpascal-strings \\\n\t-Os \\\n\t-gdwarf-2 \\\n\t-arch \\\n\tx86_64\n\n# Flags passed to only C files.\nCFLAGS_C_Default :=\n\n# Flags passed to only C++ files.\nCFLAGS_CC_Default :=\n\n# Flags passed to only ObjC files.\nCFLAGS_OBJC_Default :=\n\n# Flags passed to only ObjC++ files.\nCFLAGS_OBJCC_Default :=\n\nINCS_Default := \\\n\t-I$(srcdir)/include\n\nOBJS := \\\n\t$(obj).target/$(TARGET)/test.o\n\n# Add to the list of files we specially track dependencies for.\nall_deps += $(OBJS)\n\n# CFLAGS et al overrides must be target-local.\n# See "Target-specific Variable Values" in the GNU Make manual.\n$(OBJS): TOOLSET := $(TOOLSET)\n$(OBJS): GYP_CFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE))  $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE))\n$(OBJS): GYP_CXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE))  $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE))\n$(OBJS): GYP_OBJCFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE))  $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE)) $(CFLAGS_OBJC_$(BUILDTYPE))\n$(OBJS): GYP_OBJCXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE))  $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE)) $(CFLAGS_OBJCC_$(BUILDTYPE))\n\n# Suffix rules, putting all outputs into $(obj).\n\n$(obj).$(TOOLSET)/$(TARGET)/%.o: $(srcdir)/%.cc FORCE_DO_CMD\n\t@$(call do_cmd,cxx,1)\n\n# Try building from generated source, too.\n\n$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj).$(TOOLSET)/%.cc FORCE_DO_CMD\n\t@$(call do_cmd,cxx,1)\n\n$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj)/%.cc FORCE_DO_CMD\n\t@$(call do_cmd,cxx,1)\n\n# End of this set of suffix rules\n### Rules for final target.\nLDFLAGS_Default := \\\n\t-arch \\\n\tx86_64 \\\n\t-L$(builddir) \\\n\t-Lmylib\n\nLIBTOOLFLAGS_Default :=\n\nLIBS :=\n\n$(builddir)/test: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE))\n$(builddir)/test: LIBS := $(LIBS)\n$(builddir)/test: GYP_LIBTOOLFLAGS := $(LIBTOOLFLAGS_$(BUILDTYPE))\n$(builddir)/test: LD_INPUTS := $(OBJS)\n$(builddir)/test: TOOLSET := $(TOOLSET)\n$(builddir)/test: $(OBJS) FORCE_DO_CMD\n\t$(call do_cmd,link)\n\nall_deps += $(builddir)/test\n# Add target alias\n.PHONY: test\ntest: $(builddir)/test\n\n# Add executable to "all" target.\n.PHONY: all\nall: $(builddir)/test\n\n'

On the other hand, assert re.search does not print all the inputs

E           assert None
E            +  where None = <function search at 0x104bf31a0>(re.compile('\\#\\ This\\ file\\ is\\ generated\\ by\\ gyp;\\ do\\ not\\ edit\\.\\\n\\\nTOOLSET\\ :=\\ target\\\nTARGET\\ :=\\ test\\\nDEFS_Default\\ :=\\\n\\\n\\#\\ Flags\\ passed\\ to\\ all\\ source\\ files\\.\), '# This file is generated by gyp; do not edit.\n\nTOOLSET := target\nTARGET := test\nDEFS_Default :=\n\n# Flags passed to all source files.\nCFLAGS_Default := \\\n\t-fasm-blocks \\\n\t-mpascal-strings \\\n\t-Os \\\n\t-gdwarf-2 \\\n\t-arch \\\n\tx86_64\n\n# Flags passed to only C files.\nCFLAGS_C_Default :=\n\n# Flags passed to only C++ files.\nCFLAGS_CC_Default :=\n\n# Flags passed to only ObjC files.\nCFLAGS_OBJC_Default :=\n\n# Flags passed to only ObjC++ files.\nCFLAGS_OBJCC_Default :=\n\nINCS_Default := \\\n\t-I$(srcdir)/include\n\nOBJS := \\\n\t$(obj).target/$(TARGET)/test.o\n\n# Add to the list of files we specially track dependencies for.\nall_deps += $(OBJS)\n\n# CFLAGS et al overrides must be target-local.\n# See "Target-specific Variable Values" in the GNU Make manual.\n$(OBJS): TOOLSET := $(TOOLSET)\n$(OBJS): GYP_CFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE))  $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE))\n$(OBJS): GYP_CXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE))  $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE))\n$(OBJS): GYP_OBJCFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE))  $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE)) $(CFLAGS_OBJC_$(BUILDTYPE))\n$(OBJS): GYP_OBJCXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE))  $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE)) $(CFLAGS_OBJCC_$(BUILDTYPE))\n\n# Suffix rules, putting all outputs into $(obj).\n\n$(obj).$(TOOLSET)/$(TARGET)/%.o: $(srcdir)/%.cc FORCE_DO_CMD\n\t@$(call do_cmd,cxx,1)\n\n# Try building from generated source, too.\n\n$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj).$(TOOLSET)/%.cc FORCE_DO_CMD\n\t@$(call do_cmd,cxx,1)\n\n$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj)/%.cc FORCE_DO_CMD\n\t@$(call do_cmd,cxx,1)\n\n# End of this set of suffix rules\n### Rules for final target.\nLDFLAGS_Default := \\\n\t-arch \\\n\tx86_64 \\\n\t-L$(builddir) \\\n\t-Lmylib\n\nLIBTOOLFLAGS_Default :=\n\nLIBS :=\n\n$(builddir)/test: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE))\n$(builddir)/test: LIBS := $(LIBS)\n$(builddir)/test: GYP_LIBTOOLFLAGS := $(LIBTOOLFLAGS_$(BUILDTYPE))\n$(builddir)/test: LD_INPUTS := $(OBJS)\n$(builddir)/test: TOOLSET := $(TOOLSET)\n$(builddir)/test: $(OBJS) FORCE_DO_CMD\n\t$(call do_cmd,link)\n\nall_deps += $(builddir)/test\n# Add target alias\n.PHONY: test\ntest: $(builddir)/test\n\n# Add executable to "all" target.\n.PHONY: all\nall: $(builddir)/test\n\n')
E            +    where <function search at 0x104bf31a0> = re.search

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you running the tests with pytest (which does assertion rewriting) or with unittest?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm running with pytest -vv.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. The rewriting might be limited inside a unittest.TestCase. Thanks for the nice work on this one.

except Exception:
shutil.copyfile(actual_filepath, f"{expected_filepath}.actual")
raise

def test_ninja(self) -> None:
rc = gyp.main(["-f", "ninja", "--depth", fixture_dir, gyp_file])
assert rc == 0

self.assert_file("out/Default/obj/test.ninja", "ninja/test.ninja")

def test_make(self) -> None:
rc = gyp.main(
[
"-f",
"make",
"--depth",
fixture_dir,
"--generator-output",
"out",
gyp_file,
]
)
assert rc == 0

self.assert_file("out/test.target.mk", "make/test.target.mk")

def test_cmake(self) -> None:
rc = gyp.main(["-f", "cmake", "--depth", fixture_dir, gyp_file])
assert rc == 0

self.assert_file("out/Default/CMakeLists.txt", "cmake/CMakeLists.txt")
Loading